2010-02-09 7 views

Répondre

0

L'exemple suivant limitera le balayage panoramique de la carte de limites prédéfinies, si c'est ce que vous envisagez de le faire:

// Bounds for North America 
var allowedBounds = new GLatLngBounds(new GLatLng(48.19, -127.52), 
             new GLatLng(28.72, -68.81)); 

function checkBounds() { 
    if (allowedBounds.contains(map.getCenter())) { 
     return; 
    } 

    var c = map.getCenter(); 
    var x = c.lng(); 
    var y = c.lat(); 
    var maxX = allowedBounds.getNorthEast().lng(); 
    var maxY = allowedBounds.getNorthEast().lat(); 
    var minX = allowedBounds.getSouthWest().lng(); 
    var 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 GLatLng(y, x)); 
} 

GEvent.addListener(map, "move", function() { checkBounds(); }); 
+0

Salut Daniel, merci pour réponse. Je veux une référence pour l'API Google Map. peux-tu m'aider? Je n'ai pas accès à http://code.google.com pour des raisons politiques. Mon pays est Boycott): –

+1

@ali: La référence de l'API Google Maps est juste une longue page unique, il devrait donc être assez facile à imprimer ou à stocker au format PDF. Avez-vous réussi à obtenir l'accès à partir de ce proxy: http://anonymouse.org/cgi-bin/anon-www.cgi/http://code.google.com/apis/maps/documentation/reference.html? ... L'URL normale est: http://code.google.com/apis/maps/documentation/reference.html, juste au cas où vous pouvez trouver un proxy pour contourner l'interdiction. –