Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google.maps.Map Javascript API V3 compatibilty with jquery

I am trying to figure out why this will work by adding a map on a div of id="google_map"

map = new google.maps.Map(document.getElementById("google_map"), googleMapOptions);

but this wont work

var our_map = $("#google_map");
map = new google.maps.Map(our_map, googleMapOptions); 

I get this console error on firebug

TypeError: Argument 1 of Window.getComputedStyle does not implement interface Element.


...(a,b,c){c=c&&1==b;Jt.H?Yn(a[w],c?"":b):(b="alpha(opacity="+Jd(100*b)+")",rn(a[w]...
like image 337
John Kariuki Avatar asked Dec 21 '25 04:12

John Kariuki


1 Answers

Map constructor expect Node as the first parameter: Map(mapDiv:Node, opts?:MapOptions).

Instead of

map = new google.maps.Map(our_map, googleMapOptions); 

you have to use

map = new google.maps.Map(our_map[0], googleMapOptions); 
like image 191
Anto Jurković Avatar answered Dec 23 '25 19:12

Anto Jurković