user1166635
user1166635

Reputation: 2801

How to get bounds of Google Map?

I need to do following task: there is Google Map widget and user can move/zoom the map. When user click the button that application should show latitude & longitude of bounds of GMap (north-east corner and south-west corner). But I don't know how I can do it. I hope you can help me. Thank you for, anyway.

Upvotes: 2

Views: 1634

Answers (1)

NickT
NickT

Reputation: 23873

This should do it

Actually I meant

GeoPoint tlGpt; // Top left (NW) Geopoint
GeoPoint brGpt; // Bottom right (SE) GeoPoint

GeoPoint trGpt; // Top right (NE) Geopoint
GeoPoint blGpt; // Bottom left (SW) GeoPoint

tlGpt = mapView.getProjection().fromPixels(0, 0);
brGpt = mapView.getProjection().fromPixels(mapView.getWidth(),
            mapView.getHeight());

trGpt = mapView.getProjection().fromPixels(mapView.getWidth(), 0);
blGpt = mapView.getProjection().fromPixels(0, mapView.getHeight());

First post gave you NW and SE - this gives all 4 corners

Upvotes: 4

Related Questions