Template:Fragoria Map

From FragoriaWiki

(Difference between revisions)
Jump to: navigation, search
Line 17: Line 17:
                 normalizedCoord.x + '.jpg';
                 normalizedCoord.x + '.jpg';
         },
         },
-
         tileSize: new google.maps.Size(128, 128),
+
         tileSize: new google.maps.Size(256, 256),
         maxZoom: 4,
         maxZoom: 4,
         minZoom: 1,
         minZoom: 1,
Line 51: Line 51:
         // tile range in one direction range is dependent on zoom level
         // tile range in one direction range is dependent on zoom level
         // 0 = 1 tile, 1 = 2 tiles, 2 = 4 tiles, 3 = 8 tiles, etc
         // 0 = 1 tile, 1 = 2 tiles, 2 = 4 tiles, 3 = 8 tiles, etc
-
         var tileRange = 1 << zoom;
+
         var tileRange = 2<< zoom;
         // repeat across y-axis (vertically)
         // repeat across y-axis (vertically)
Line 70: Line 70:
       }
       }
 +
      // Add a move listener to restrict the bounds range
 +
      GEvent.addListener(map, "move", function() {
 +
        checkBounds();
 +
      });
 +
 +
      // The allowed region which the whole map must be within
 +
      var allowedBounds = new GLatLngBounds(new GLatLng(49.5,-10), new GLatLng(59,2.6));
 +
     
 +
      // If the map position is out of range, move it back
 +
      function checkBounds() {
 +
        // Perform the check and return if OK
 +
        if (allowedBounds.contains(map.getCenter())) {
 +
          return;
 +
        }
 +
        // It`s not OK, so find the nearest allowed point and move there
 +
        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;}
 +
        //alert ("Restricting "+Y+" "+X);
 +
        map.setCenter(new GLatLng(Y,X));
 +
      }
 +
    }
       </script>
       </script>
<body onload="initialize()">   
<body onload="initialize()">   

Revision as of 14:47, 3 April 2015

Fragoria Map

Personal tools
Date/Time
Server & Cross

Super-Cross Server