Skip to content Skip to sidebar Skip to footer

Google Maps (V3) - Map Container Selector (using Jquery)

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'), myOptions); Doesn't Work if I tr

Solution 1:

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.


Post a Comment for "Google Maps (V3) - Map Container Selector (using Jquery)"