Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Klever_Studios
Posts: 4
Registered: ‎02-23-2009
My Device: Not Specified
Accepted Solution

Get Map Extents

Is there a way to retrieve the top left and bottom right longitude and latitude?  I know you can get the center of the map, but I want to know the extents.

 

Thanks!

 

New Developer
Klever_Studios
Posts: 4
Registered: ‎02-23-2009
My Device: Not Specified

Re: Get Map Extents

Found that using the MapField class convertFieldToWorld method works to do this.  My MapField fills up pretty much the whole screen save a textfield at the top, and the following code works for the level of detail I require.

 

// top left XYPoint topLeftPoint = new XYPoint(1,1); Coordinates topLeftCoordinates = new Coordinates(0,0,0); _map.convertFieldToWorld(topLeftPoint, topLeftCoordinates); // bottom right XYPoint bottomRightPoint = new XYPoint(_map.getWidth(), _map.getHeight()); Coordinates bottomRightCoordinates = new Coordinates(0,0,0); _map.convertFieldToWorld(bottomRightPoint, bottomRightCoordinates); // displays the coordintates _addressBar1.setText("Top Left Long:" + topLeftCoordinates.getLongitude() + " Lat:" + topLeftCoordinates.getLatitude() ); _addressBar2.setText("Bot Right Long:" + bottomRightCoordinates.getLongitude() + " Lat:" + bottomRightCoordinates.getLatitude());