Template:Fragoria Map

From FragoriaWiki

(Difference between revisions)
Jump to: navigation, search
Line 45: Line 45:
new google.maps.LatLng(50, -80)
new google.maps.LatLng(50, -80)
);
);
-
var lastValidCenter = map.getCenter();
+
var boundLimits = {
 +
maxLat : allowedBounds.getNorthEast().lat(),
 +
maxLng : allowedBounds.getNorthEast().lng(),
 +
minLat : allowedBounds.getSouthWest().lat(),
 +
minLng : allowedBounds.getSouthWest().lng()
 +
};
 +
var lastValidCenter = map.getCenter();
 +
var newLat, newLng;
google.maps.event.addListener(map, 'center_changed', function() {
google.maps.event.addListener(map, 'center_changed', function() {
-
if (allowedBounds.contains(map.getCenter())) {
+
center = map.getCenter();
-
// still within valid bounds, so save the last valid position
+
if (allowedBounds.contains(center)) {
 +
// still within valid bounds, so save the last valid position
lastValidCenter = map.getCenter();
lastValidCenter = map.getCenter();
-
return;  
+
return;
}
}
-
// not valid anymore => return to last valid position
+
newLat = lastValidCenter.lat();
-
map.panTo(lastValidCenter);
+
newLng = lastValidCenter.lng();
 +
if(center.lng() > boundLimits.minLng && center.lng() < boundLimits.maxLng){
 +
newLng = center.lng();
 +
}
 +
if(center.lat() > boundLimits.minLat && center.lat() < boundLimits.maxLat){
 +
newLat = center.lat();
 +
}
 +
map.panTo(new google.maps.LatLng(newLat, newLng));
});
});

Revision as of 21:23, 3 April 2015

Fragoria Map

Personal tools
Date/Time
Server & Cross

Super-Cross Server