Template:Fragoria Map
From FragoriaWiki
(Difference between revisions)
Line 69: | Line 69: | ||
} | } | ||
+ | |||
+ | google.maps.event.addListener(map,'center_changed',function() { checkBounds(); }); | ||
+ | |||
+ | function checkBounds() { | ||
+ | if(! allowedBounds.contains(map.getCenter())) { | ||
+ | var C = map.getCenter(); | ||
+ | var X = C.lng(); | ||
+ | var Y = C.lat(); | ||
+ | |||
+ | var AmaxX = allowedBounds.getNorthEast().lng(); | ||
+ | var AmaxY = allowedBounds.getNorthEast().lat(); | ||
+ | var AminX = allowedBounds.getSouthWest().lng(); | ||
+ | var AminY = allowedBounds.getSouthWest().lat(); | ||
+ | |||
+ | if (X < AminX) {X = AminX;} | ||
+ | if (X > AmaxX) {X = AmaxX;} | ||
+ | if (Y < AminY) {Y = AminY;} | ||
+ | if (Y > AmaxY) {Y = AmaxY;} | ||
+ | |||
+ | map.setCenter(new google.maps.LatLng(Y,X)); | ||
+ | } | ||
+ | } | ||
</script> | </script> |
Revision as of 09:39, 3 April 2015