You can write it yourself. On map event 'idle' check the boundries and if
they not fit in your area (you will set max left, max right, max top, max
bottom) change center of the map (map.setCenter(latlng).

something like this:


    var topBound = 44.5;
    var bottomBound = 41;
    var leftBound = 22.1;
    var rightBound = 28.9;

    //drag end, center changed, bounds changed ...
    function mapIdle_Handler() {

        //limit bounds
=========================================================
        var center = map.getCenter();

        if(center.lng() < leftBound) {
            map.centerMapOn(center.lat(), leftBound);
            //console.log("out of bounds: left" + center.lat() + "/" +
leftBound);
        }

        if(center.lng() > rightBound) {
            map.centerMapOn(center.lat(), rightBound);
            //console.log("out of bounds: right");
        }

        if(center.lat() > topBound) {
            map.centerMapOn(topBound, center.lng());
            //console.log("out of bounds: top");
        }

        if(center.lat() < bottomBound) {
            map.centerMapOn(bottomBound, center.lng());
            //console.log("out of bounds: bottom");
        }
        // end limit bounds
====================================================

    }

 google.maps.event.addListener(map, 'idle', mapIdle_Handler);




On Tue, Jan 11, 2011 at 10:25 PM, [email protected] <[email protected]
> wrote:

> On Jan 11, 10:36 am, davejuk <[email protected]> wrote:
> > Hi
> >
> > My application deals with quite a small geographical area (the Severn
> > Estuary, UK).
> >
> > I want to keep the view within the general area without the user feeling
> too
> > restricted. Is there any built in functionality for doing this?
> >
> > If not, how would you suggest I go about doing this?
> >
> > I have a pretty good grasp of the API, so I'm just looking for
> suggestions
> > of how to do it in a user-friendly way.
>
> Have you tried porting Mike Williams' example from v2?
>
>  -- Larry
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to