Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Latest news

Last at Tue, 6 Dec 2011 18:37:53
Topic: New BlackBerry sample app
See more news »

MapComponent.getBoundingBox() returning incorrect values

2 replies [Last post]
gthornejr
User offline. Last seen 1 year 30 weeks ago. Offline
Joined: 04/14/2010

Hi,

I am porting code from a BlackBerry MGMaps project over to Android. On the BlackBerry, MapComponent.getBoundingBox() could be used to get the WgsMin and WgsMax parameters of the map. Unfortunately, on the Android it keeps returning the same values for WgsMin and WgsMax, which seems to be the center point of the map. I tried adding the following code to the textopia sample :

mapComponent.startMapping();
WgsBoundingBox wgs = mapComponent.getBoundingBox();

and the values for WgsMin in the debugger are 59.91304 and 10.734844. The values for WgsMax are the same.

Any help would be appreciated.

Thanks,
Gary Thorne

jaak
User offline. Last seen 1 day 11 hours ago. Offline
Joined: 06/19/2008

I guess the issue is that your defined initial size of map is 1x1 pixels, and this is used as basis to get the bounding box. During startup map does not know yet real size, it depends on screen configuration. This is defined with first call to MapView.onDraw() method.

I suspect that if you ask bounding box some time later (when map is properly displayed) then you will get better values. Or try to set more sensible initial map size, if possible.

To know better some debugging would be needed with your specific code.

/JaakL

gthornejr
User offline. Last seen 1 year 30 weeks ago. Offline
Joined: 04/14/2010

Thank you! You were right : I initialized the BasicMapComponent using width and height of 1 as in the samples. I changed the code to use the actual screen size, which is close enough to get me starting bounding box values at startup :

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
mapComponent = new BasicMapComponent(Constants.NUTITEQ_KEY, "Systems", "Tour", metrics.widthPixels, metrics.heightPixels, new WgsPoint(lon, lat), 10);