Created
September 13, 2012 15:28
-
-
Save lpdumas/3715089 to your computer and use it in GitHub Desktop.
Simple pan method for Google map API v3 to pan the map with a certain offset. In this case, used within a custom infoWindow class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CustomInfoWindow.prototype.panMap = function(marker, map) { | |
var offsetX = 100 | |
var offsetY = 75 | |
var scale = Math.pow(2,map.getZoom()) | |
var center = map.getProjection().fromLatLngToPoint(marker.getPosition()) | |
var newCenterPoint = new google.maps.Point( | |
center.x - offsetX/scale, | |
center.y + offsetY/scale | |
) | |
var newCenter = this.map.getProjection().fromPointToLatLng(newCenterPoint) | |
this.map.panTo(newCenter) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!