Template:Fragoria Map
From FragoriaWiki
(Difference between revisions)
| Line 40: | Line 40: | ||
map.setMapTypeId('moon'); | map.setMapTypeId('moon'); | ||
| - | var marker = new google.maps.Marker({ | + | // 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({ | ||
| + | position: new google.maps.LatLng(-89.62,33.4), | ||
| + | map: map, | ||
| + | title:"Fragotown" | ||
| + | }); | ||
| + | } | ||
// Normalizes the coords that tiles repeat across the x axis (horizontally) | // Normalizes the coords that tiles repeat across the x axis (horizontally) | ||
| Line 59: | Line 76: | ||
// repeat across y-axis (vertically) | // repeat across y-axis (vertically) | ||
if (y < 0 || y >= tileRange) { | if (y < 0 || y >= tileRange) { | ||
| - | + | return null; | |
} | } | ||
Revision as of 21:15, 3 April 2015

