Google maps (V3) - Map container selector (using jquery)

前端 未结 1 764
礼貌的吻别
礼貌的吻别 2020-12-28 20:17

I\'m trying to solve a tricky problem in Google Maps (api V3)

Works nicely:

var map = new google.maps.Map(document.getElementById(\"map_container\"),         


        
相关标签:
1条回答
  • 2020-12-28 20:58

    It expects a DOM element, but $('#map_container') returns a jQuery object. If you want to use a jQuery selector, do:

    var map = new google.maps.Map($('#map_container')[0], myOptions);
    

    Or you can also use .get(0) instead of [0], this returns the actual DOM object.

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