Hi all, I found that there is a way to convert a WgsPoint to its MapPos using the "getMapPosition" method in BasicMapComponent.
But it seems that there is no function to convert the MapPos back to WgsPoint in BasicMapComponent/MapComponent. I would like to ask is there any solution to convert MapPos to WgsPoint to do such thing?
Besides, I saw that the "getMapPosition" method is "not part of public API". Does it means I need to do somethings to make this function works on my blackberry device? Thank you.
ps. "not part of public API" means that this method can change in future versions, even through you can use it and probably it also works fine. On some platforms (J2ME) these non-public methods are also obfuscated, so you will not find them so easily, on some others (RIM, Android) we cannot obfuscate them.
Public method for similar function should be
map.getMap().wgsToMapPos(new WgsPoint(-71.023865,42.416867).toInternalWgs(),zoom);
Note that these conversions are using current map service, so result depends on map projection.
Can you please also describe for what exactly do you need these methods. Usually we expect that you do not need to see or manipulate pixel space coordinates, and most features can be done some other way with less coding, using custom placemarks, labels etc.
Actually, I want to calculate the latitude and longitude difference in one pixel in difference zoom level. I found that I have went to a wrong way to do the calculation and I have find a better solution to do so. Anyway, thanks for your help.
I want to ask one more question, now I'm using the OpenStreetMap, is there any ways to take away the "OpenStreetMap" watermark on the map?
To remove OpenStreetMap try something like:
map.setmap(new OpenStreetMap(new StringCopyright(""),"http://tile.openstreetmap.org/",256,0,19));
For what do you really need it? Maybe you want scalebar line to the map?
For example, I create the map using the WgsPoint(x, y) with screen width "i" and screen height "j". I want to add a place on the map at the point (x+i/4, y+j/5) without knowing the WgsPoint of the place. So, I need to know the latitude and longitude difference in one pixel in difference zoom level.
Now, I need to draw some lines on the map and regularly update the lines. Therefore, I created a timertask to call "removeLines" and "addLines" functions at a fixed interval, let's say 5 seconds.
The timertask works fine in the first 5 seconds, and then throw a NullPointerException in the next five seconds.
I'm wondering why this is happened. Will calling the "addLines" function immediately after calling the "removeLines" function create this problem? Or maybe the error was created by my own code. Thank you.
Perhaps I shouldn't be replying in this thread, but I have a similar issue with the lines.
If I want to add another point to a line, I remove the line, add my new point to the list points for the line, and then add the new line.
It works without issue for a while and then throws null pointer exceptions.
I fixed the problem, you should better lock the map component first before you draw lines or remove lines on it.
Hi
Can you please share how to calculate per pixel lat,lon distance at a particular zoom level.
try:
/JaakL