Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google.maps.MarkerShape not loaded

I'm trying to create a MarkerShape object with google maps api (the last version, 3.9.2). Unfortunately, it seems that MarkerShape api is not loaded: here is what firebug's console shows me:

>>> google.maps.version

"3.9.2"

>>> google.maps.MarkerShape

undefined

Am I doing something wrong ? The last version of gmaps documentation for MarkerShape is here: https://developers.google.com/maps/documentation/javascript/reference#MarkerShape

Thx

Edit: here is an example on jsfiddle: http://jsfiddle.net/vszHk/6/ or just go to an official example like here https://google-developers.appspot.com/maps/documentation/javascript/examples/map-simple and open firebug

like image 408
mogo Avatar asked Jan 16 '23 10:01

mogo


2 Answers

I think your problem is you are trying to treat google.maps.MarkerShape as a constructor. It's just an object, not a constructor.

So doing something like the following is wrong as there isn't a MarkerShape method in the google.maps object:

var marker_shape = new google.maps.MarkerShape(); 

To create a MarkerShape you can just create an object literal:

var marker_shape = {coords: [0,0,50,50], type: "rect"}

Then you can add this to the object literal you pass to the google.maps.Marker constructor. Eg.

marker = new google.maps.Marker({
    position: lat_lng_object,
    map: map,
    shape: marker_shape
});
like image 149
Nirrek Avatar answered May 30 '23 02:05

Nirrek


Given that 3.9.2 is the latest Nightly version, have you tried referring to an older more stable version, e.g. 3.9.1 or 3.8 (last Release version)

https://developers.google.com/maps/documentation/javascript/basics#Versioning

e.g. http://maps.googleapis.com/maps/api/js?v=3.8&sensor=false

like image 29
duncan Avatar answered May 30 '23 03:05

duncan