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
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);
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