Template:Fragoria Map
From FragoriaWiki
(Difference between revisions)
| Line 40: | Line 40: | ||
map.setMapTypeId('moon'); | map.setMapTypeId('moon'); | ||
| - | + | // bounds of the desired area | |
| - | + | var allowedBounds = new google.maps.LatLngBounds( | |
| - | + | new google.maps.LatLng(-50, 80), | |
| - | + | new google.maps.LatLng(50, -80) | |
| + | ); | ||
| + | var lastValidCenter = map.getCenter(); | ||
| - | + | google.maps.event.addListener(map, 'center_changed', function() { | |
| - | + | if (allowedBounds.contains(map.getCenter())) { | |
| - | + | // still within valid bounds, so save the last valid position | |
| - | + | lastValidCenter = map.getCenter(); | |
| - | + | return; | |
| - | + | } | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | // | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | // not valid anymore => return to last valid position | |
| - | + | map.panTo(lastValidCenter); | |
| - | + | }); | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
var marker = new google.maps.Marker({ | var marker = new google.maps.Marker({ | ||
Revision as of 21:50, 3 April 2015

