Googlemap Api V3 Catch event

廉价感情. 提交于 2021-02-17 05:33:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!