How to get a list of all available map types?

436 views
Skip to first unread message

Pil

unread,
May 31, 2010, 3:03:15 PM5/31/10
to Google Maps JavaScript API v3
I'm searching for an aequivalent for

the v2 method getMapTypes()

I tried

map.mapTypes( google.maps.MapTypeRegistry() );

And because v3 constantly wants to use google.maps I tried also

google.maps.mapTypes( google.maps.MapTypeRegistry() );

But this was all to no other avail than errors

"Error: map.mapTypes is not a function"

William

unread,
May 31, 2010, 5:44:53 PM5/31/10
to Google Maps JavaScript API v3
On Jun 1, 5:03 am, Pil <wolf...@gmail.com> wrote:
> "Error: map.mapTypes is not a function"
it's a property which can be accessed directly, for example to get the
current MapType

var currentMapType = map.mapTypes[map.getMapTypeId()];

there doesn't seem to be any similar method getMapTypes() on the
MapTypeRegistry, and the registry contains other objects besides the
MapTypes, so there would need to be a function like this:

http://www.william-map.com/20100601/1/map.htm

...

Pil

unread,
Jun 1, 2010, 2:38:07 AM6/1/10
to Google Maps JavaScript API v3
Thanks for the illustrative example.
Ahh ya, mapTypes is an object that also contains a lot of other things
besides the map types. In your example you are looking for the
property tileSize to extract the map types. It is not documented that
the name of these extracted map type objects can be accessed with the
property name. There is also no method getName() like in v2.


Do you know if the mapTypes object will also contain a previously
added additional map type?

I'm asking because the reference seems not clear in this case. Another
map property besides mapTypes is mentioned, namely overlayMapTypes.

William

unread,
Jun 1, 2010, 2:55:20 AM6/1/10
to Google Maps JavaScript API v3
On Jun 1, 4:38 pm, Pil <wolf...@gmail.com> wrote:
>
> In your example you are looking for the
> property tileSize to extract the map types.
>

the doco for the MapType "object" specification says "This interface
defines map type. Immutable", and I first tried "instanceof
google.maps.MapType" but this doesn't work because there is no
constructor for MapType. This needs further investigation into how
google implements concepts like "immutable" and "interface" using
javascript.

>
> Do you know if the mapTypes object will also contain a previously
> added additional map type?
>

yeah I tried it with a Styled Map Type and it was in the list.

...
Reply all
Reply to author
Forward
0 new messages