Template:Fragoria Map

From FragoriaWiki

(Difference between revisions)
Jump to: navigation, search
Line 40: Line 40:
map.setMapTypeId('moon');
map.setMapTypeId('moon');
-
  // Bounds for North America
+
// Bounds
-
  var allowedBounds = new google.maps.LatLngBounds(
+
var allowedBounds = new google.maps.LatLngBounds(
-
    new google.maps.LatLng(-50, 80),  
+
new google.maps.LatLng(-50, 80),  
-
    new google.maps.LatLng(50, -80));
+
new google.maps.LatLng(50, -80));
 +
// Listen for the dragend event
 +
google.maps.event.addListener(map, 'dragend', function() {
 +
if (allowedBounds.contains(map.getCenter())) return;
-
  // Listen for the dragend event
+
// Out of bounds - Move the map back within the bounds
-
  google.maps.event.addListener(map, 'dragend', function() {
+
var c = map.getCenter(),
-
    if (allowedBounds.contains(map.getCenter())) return;
+
x = c.lng(),
 +
y = c.lat(),
 +
maxX = allowedBounds.getNorthEast().lng(),
 +
maxY = allowedBounds.getNorthEast().lat(),
 +
minX = allowedBounds.getSouthWest().lng(),
 +
minY = allowedBounds.getSouthWest().lat();
-
    // Out of bounds - Move the map back within the bounds
+
if (x < minX) x = minX;
 +
if (x > maxX) x = maxX;
 +
if (y < minY) y = minY;
 +
if (y > maxY) y = maxY;
-
    var c = map.getCenter(),
+
map.setCenter(new google.maps.LatLng(y, x));
-
        x = c.lng(),
+
});
-
        y = c.lat(),
+
-
        maxX = allowedBounds.getNorthEast().lng(),
+
// Limit the zoom level
-
        maxY = allowedBounds.getNorthEast().lat(),
+
google.maps.event.addListener(map, 'zoom_changed', function() {
-
        minX = allowedBounds.getSouthWest().lng(),
+
if (map.getZoom() < minZoomLevel) map.setZoom(minZoomLevel);
-
        minY = allowedBounds.getSouthWest().lat();
+
});
-
 
+
-
    if (x < minX) x = minX;
+
-
    if (x > maxX) x = maxX;
+
-
    if (y < minY) y = minY;
+
-
    if (y > maxY) y = maxY;
+
-
 
+
-
    map.setCenter(new google.maps.LatLng(y, x));
+
-
  });
+
-
 
+
-
  // Limit the zoom level
+
-
  google.maps.event.addListener(map, 'zoom_changed', function() {
+
-
    if (map.getZoom() < minZoomLevel) map.setZoom(minZoomLevel);
+
-
  });
+
var marker = new google.maps.Marker({
var marker = new google.maps.Marker({

Revision as of 21:56, 3 April 2015

Fragoria Map

Personal tools
Date/Time
Server & Cross

Super-Cross Server