开发者

google maps api v3 setMapType issue

开发者 https://www.devze.com 2023-03-06 08:35 出处:网络
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:

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.se开发者_StackOverflow社区tMapTypeId("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


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号