admin管理员组

文章数量:1290421

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

map.setMapTypeId("SATELLITE");

or

map.setMapTypeId(SATELLITE);

or

map.setMapTypeId(mapTypeId:Satellite);

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

.html#Map

I'm trying to change the maptype in google maps from roadmap to satellite when a user clicks on a marker, but I'm getting errors. I've 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./apis/maps/documentation/javascript/reference.html#Map

Share Improve this question edited Dec 7, 2013 at 7:29 Kara 6,22616 gold badges53 silver badges58 bronze badges asked May 17, 2011 at 17:11 mheaversmheavers 30.2k62 gold badges200 silver badges326 bronze badges 1
  • "but I'm getting errors" - what errors? – slandau Commented May 17, 2011 at 17:14
Add a ment  | 

1 Answer 1

Reset to default 11

You want:

google.maps.MapTypeId.SATELLITE

which evaluates to "satellite" - but you're better off using the API version, in case they ever change the string constant. Full call:

map.setMapTypeId(google.maps.MapTypeId.SATELLITE);

本文标签: javascriptgoogle maps api v3 setMapType issueStack Overflow