Google maps api v3 setMapType problem

I am trying to change the maptype in google maps from a roadmap to a satellite when a user clicks on a marker, but I get errors. I tried:

map.setMapTypeId("SATELLITE");

or

map.setMapTypeId(SATELLITE);

or

map.setMapTypeId(mapTypeId:Satellite);

What am I doing wrong here? This is the documentation:

http://code.google.com/apis/maps/documentation/javascript/reference.html#Map

+3
source share
1 answer

Do you want to:

google.maps.MapTypeId.SATELLITE

which evaluates to "satellite"- but you better use the version of the API if they ever change the string constant. Full call:

map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
+11
source

All Articles