Oops, bit wrong.
google.maps.event.addListener.

On 9月24日, 午前9:12, "Masashi.K" <[email protected]> wrote:
> google.maps.event.addListenerOnce(map, "maptypeid_changed", function()
> {
>         var currentMapTypeId = map.getMapTypeId();
>         var mapTypeReg = map.mapTypes;
>         var mapTypeId, mapType;
>         for(var i in google.maps.MapTypeId){
>                 mapTypeId = google.maps.MapTypeId[i];
>                 if (mapTypeId.substr(0, 1) != "_") {
>                         mapType = mapTypeReg.get(mapTypeId);
>                         if (typeof(params.minZoom) == "number") {
>                                 mapType.minZoom = params.minZoom;
>                         }
>                         if (typeof(params.maxZoom) == "number") {
>                                 mapType.maxZoom = params.maxZoom;
>                         }
>                 }
>         }
>
> });
>
> On 9月24日, 午前12:35, Francisco Ramos <[email protected]> wrote:
>
>
>
> > The only problem with that way is the length of the slider, it doesn't
> > change, keeping the same length from 0 to 20, and you are checking the
> > zoom level in every zoom_changed
>
> > Have a look at this snippets and give it a try:
>
> > minZoom = 5;
> > maxZoom = 15;
>
> > map = new google.maps.Map(...);
>
> > google.maps.event.addListener(map, "maptypeid_changed", function () {
>
> >     map.mapTypes[map.getMapTypeId()].minZoom = minZoom;
> >     map.mapTypes[map.getMapTypeId()].maxZoom = maxZoom;
>
> >     google.maps.event.trigger(map, "zoom_changed");
>
> > });
>
> > /
> > *************************************************************************** 
> > **************/
>
> > function setMinZoom (zoom) {
> >     map.mapTypes[map.getMapTypeId()].minZoom = zoom;
> >     google.maps.event.trigger(map, "zoom_changed");
>
> > }
>
> > function setMaxZoom (zoom) {
> >     map.mapTypes[this._map.getMapTypeId()].maxZoom = zoom;
> >     google.maps.event.trigger(map, "zoom_changed");
>
> > }
>
> > On Sep 23, 3:28 pm, korky <[email protected]> wrote:
>
> > > Finally managed to do it. For those who're interested :
>
> > > maxZoom = 19;
> > > minZoom = 13;
> > >         google.maps.event.addListener(map, 'zoom_changed', function(){
> > >            if(map.getZoom() < maxZoom){
> > >                         map.setZoom(maxZoom);
> > >                 }else if(map.getZoom() > minZoom){
> > >                         map.setZoom(minZoom);
> > >                 }
> > >         });
>
> > > On 23 sep, 14:46, korky <[email protected]> wrote:
>
> > > > Hi, I'm new at coding with the API V3 and I'm actually trying to set
> > > > maxZoom and minZoom values on my map, but can't find any way to do it.
> > > > The point of this would be to restrict the user to a max and a min
> > > > zoom on the map, thus if he reaches the value of maxZoom he can't
> > > > scroll further and the same for minZoom.
>
> > > > It must be kind of by using MapType ? But where do I declare all this
> > > > stuff?
>
> > > > Thanks.
>
> > > > By the way, this is a part of my actual code, I guess I would've to
> > > > declare the max and min Zoom nearby?
>
> > > > function initialize()
> > > > {
> > > >         geocoder = new google.maps.Geocoder();
>
> > > >         var mapCenter = new google.maps.LatLng(arrMapOptions[0].lat,
> > > > arrMapOptions[0].lng);
> > > >         var mapOptions = {
> > > >                 zoom: arrMapOptions[0].zoom,
> > > >                 center: mapCenter,
> > > >                 mapTypeId: google.maps.MapTypeId.ROADMAP
> > > >                 };
>
> > > >         map = new google.maps.Map(document.getElementById('mapcanvas'),
> > > > mapOptions);
>
> > > > }

-- 
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