views:

180

answers:

1

hello my friends,

i put this plug in into my website, how i do define a region and restrict visitors to can not going out of ?

I don't have access http://code.google.com for political reasons. please help me in your answer and don't Refers to that!

thank advance

+1  A: 

The following example will limit the panning of the map to predefined bounds, if that is what you intend doing:

// 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(); });
Daniel Vassallo
hi Daniel,thank for answer. i want a reference for Google Map API . do you can help me. I don't have access http://code.google.com for political reasons. my country is Boycott ):
ali moharrami
@ali: The Google Maps API reference is just a single long page, so it should be quite easy to print or to store as a PDF. Do you manage to get access from this proxy: http://anonymouse.org/cgi-bin/anon-www.cgi/http://code.google.com/apis/maps/documentation/reference.html ? ... The normal url is: http://code.google.com/apis/maps/documentation/reference.html, just in case you can find some proxy to get around the ban.
Daniel Vassallo