How to get a list of all available map types?

85 views
Skip to first unread message

Pil

unread,
Nov 23, 2012, 2:29:52 AM11/23/12
to Google Maps JavaScript API v3
https://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4791302003da168d?hl=en&noredirect=true

I'm sorry but I have to ask this question again due to API changes.

My esample is here

http://www.wolfpil.de/v3/dropdown.html

If you look inside the options list you will see that it contains a
"map type" that is no map type.

Pil

unread,
Nov 23, 2012, 6:07:29 AM11/23/12
to Google Maps JavaScript API v3
Checked a bit closer: This happens only when using the newest Chrome
and Firefox on Linux.

However, already found a workaround. Thanks.

Enoch Lau (Google Employee)

unread,
Nov 25, 2012, 5:22:04 AM11/25/12
to google-map...@googlegroups.com
When you do:

for (var prop in mts) {
}

inside the for loop, you should check:

  if (mts.hasOwnProperty(prop)) {
  }

The reason is that due to changes in how the Maps API does "inheritance" in JS, the variable prop can take on the string value 'constructor', which is not a map type.

Enoch

Pil

unread,
Nov 25, 2012, 8:39:18 AM11/25/12
to Google Maps JavaScript API v3
Thanks Enoch.

I now check for the property tileSize which is required for map types.
(Previously I looked for the name property.)

So it seems I can use these two possibilities

var mts = map.mapTypes;

for (var prop in mts) {
if (mts[prop].tileSize) ...

and

for (var prop in mts) {
if (mts[prop].hasOwnProperty("tileSize")) ...




On Nov 25, 11:22 am, "Enoch Lau (Google Employee)"
Reply all
Reply to author
Forward
0 new messages