Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- google.maps.event.addListener(map, 'zoom_changed', function() {
- setTimeout(moveMap, 10);
- });
- function moveMap() {
- map.panBy(300, 0);
- }
- var map, // Your map object
- mapWidth = $('#map').css('width'); // Width of map container
- nCentre,
- cCentre,
- visibleWidth = 200; // Visible area in PX you want map to be centered in
- // Make sure width is an Int
- mapWidth = parseInt(mapWidth.replace(/px$/, ''), 10);
- // Get the center of viewable area
- cCentre = visibleWidth / 2;
- // Create the new position variable
- nCentre = cCentre - (mapWidth / 2);
- // Pan the map to the centre of the visible area
- if (nCentre !== 0) {
- map.panBy(nCentre, 0);
- }
Add Comment
Please, Sign In to add comment