Change Google Maps v3 mapOptions object after load

前端 未结 3 626
小蘑菇
小蘑菇 2020-12-29 22:55

How can i modify a V3 map\'s mapOptions (after the initial map has been loaded)?

Specifically, I would like to be able to flip the

draggable: false
         


        
相关标签:
3条回答
  • 2020-12-29 23:01

    If you have already created the map previously, you can set several options ( https://developers.google.com/maps/documentation/javascript/reference#MapOptions ) at once like this:

    var myOptions = {
                        zoom:11,
                        center: new google.maps.LatLng(-34.397, 150.644),
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        panControl: false
                    };
    
    map.set(myOptions);
    
    0 讨论(0)
  • 2020-12-29 23:13

    Google Maps JavaScript API V3.25 update

    Note that map.set() does not work in newer versions of Maps API. You have to use map.setOptions()

    Source: Google Maps Reference

    0 讨论(0)
  • 2020-12-29 23:25

    Found that I don't even need jQuery for this – it's already part of the Google Maps API. Simply do:

    map.set('draggable', true);
    

    Too easy! Hope it helps someone.

    0 讨论(0)
提交回复
热议问题