Template:Fragoria Map

From FragoriaWiki

(Difference between revisions)
Jump to: navigation, search
Line 74: Line 74:
// Add a move listener to restrict the bounds range
// Add a move listener to restrict the bounds range
-
// GEvent.addListener(map, "move", function() {
+
GEvent.addListener(map, "move", function() {
-
// checkBounds();
+
checkBounds();
-
// });
+
});
// The allowed region which the whole map must be within
// The allowed region which the whole map must be within
-
// var allowedBounds = new GLatLngBounds(new GLatLng(0,0), new GLatLng(16,32));
+
var allowedBounds = new GLatLngBounds(new GLatLng(0,0), new GLatLng(16,32));
        
        
// If the map position is out of range, move it back
// If the map position is out of range, move it back
-
// function checkBounds() {
+
function checkBounds() {
// Perform the check and return if OK
// Perform the check and return if OK
-
// if (allowedBounds.contains(map.getCenter())) {
+
if (allowedBounds.contains(map.getCenter())) {
-
// return;
+
return;
-
// }
+
}
// It`s not OK, so find the nearest allowed point and move there
// It`s not OK, so find the nearest allowed point and move there
-
//        var C = map.getCenter();
+
        var C = map.getCenter();
-
//        var X = C.lng();
+
        var X = C.lng();
-
//      var Y = C.lat();
+
      var Y = C.lat();
-
//        var AmaxX = allowedBounds.getNorthEast().lng();
+
        var AmaxX = allowedBounds.getNorthEast().lng();
-
//        var AmaxY = allowedBounds.getNorthEast().lat();
+
        var AmaxY = allowedBounds.getNorthEast().lat();
-
//        var AminX = allowedBounds.getSouthWest().lng();
+
        var AminX = allowedBounds.getSouthWest().lng();
-
//        var AminY = allowedBounds.getSouthWest().lat();
+
        var AminY = allowedBounds.getSouthWest().lat();
-
//        if (X < AminX) {X = AminX;}
+
        if (X < AminX) {X = AminX;}
-
//        if (X > AmaxX) {X = AmaxX;}
+
        if (X > AmaxX) {X = AmaxX;}
-
//        if (Y < AminY) {Y = AminY;}
+
        if (Y < AminY) {Y = AminY;}
-
//        if (Y > AmaxY) {Y = AmaxY;}
+
        if (Y > AmaxY) {Y = AmaxY;}
//alert ("Restricting "+Y+" "+X);
//alert ("Restricting "+Y+" "+X);
-
//        map.setCenter(new GLatLng(Y,X));
+
        map.setCenter(new GLatLng(Y,X));
-
// }
+
}
</script>
</script>

Revision as of 17:38, 3 April 2015

Fragoria Map

Personal tools
Date/Time
Server & Cross

Super-Cross Server