问题
How do I catch if map type was changed?
- catch if maptype id = roadmap/satellite/hybrid/terrain
- catch if streetview was used
回答1:
Both of these are pretty straightforward - you simply listen to the proper events:
Map Type Changed:
google.maps.event.addListener(map, 'maptypeid_changed', function() {
console.log("map type changed");
});
Streetview Activated:
var pano = map.getStreetView();
google.maps.event.addListener(pano, 'visible_changed', function() {
if (pano.getVisible()) {
console.log("street view visible");
}
});
来源:https://stackoverflow.com/questions/10548246/googlemap-api-v3-catch-event