0

The method in Google Maps 'setCenter' or the Options value 'center' obviously do what whey say, set the coordinates on the map to 50% height, and 50% width of the container/canvas.

I need to make the center of the coordinates appear at 25% width (or 25% left in css speak). Does anyone know if Google Maps has an option to do it, or a way to trick Maps into setting that as the center?

PS this is being build in js.

4

1 回答 1

0

Resolved it myself:

var ne = map.getBounds().getNorthEast();
var sw = map.getBounds().getSouthWest();

var lat = sw.lat() + 0.5*(ne.lat() - sw.lat()); //height at center
var long = sw.lng() + 0.75*(ne.lng() - sw.lng()); //set width at 25% center

map.setCenter(new google.maps.LatLng(lat,long));
于 2013-09-19T13:46:22.890 回答