Ray
Ray

Reputation: 59

How to know latitude and longitude of the corners of a styled map

I used the wizard at this link
http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html to create a styled map with no labels or roads giving the styled map output http://maps.googleapis.com/maps/api/staticmap?center=31.48138,75.801544&zoom=9&format=png&sensor=false&size=640x480&maptype=roadmap&style=feature:road|visibility:off&style=element:labels|visibility:off

Now I wish to know the latitude and longitude of the corners of the static styled map. Any help is appreciated. Thanks.

Upvotes: 0

Views: 269

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117314

The returned staticmap always has the same size(640x480).

So all you have to do when you use this tool is to set the site of the map inside the tool to the same size.

Then you'll be able to retrieve the bounds of the map inside the tool, which will be the same for the staticmap.

for a convenient usage run this inside the console when you use the wizard:

document.getElementById('map').style.cssText='width:640px;height:480px;left:'+
     ((document.body.offsetWidth-640)/2)+'px';
google.maps.event.trigger(map,'resize');
google.maps.event.addDomListener(document.getElementById('staticMapButton'),
  'click',
  function(){
  prompt('bounds',map.getBounds().toString());
 });

you'll be prompted with the bounds now when you click the staticMap-button

Upvotes: 2

Related Questions