Googlemap Api V3 Catch event

前端 未结 1 1490
情书的邮戳
情书的邮戳 2021-01-28 07:35

How do I catch if map type was changed?

  • catch if maptype id = roadmap/satellite/hybrid/terrain
  • catch if streetview was used
相关标签:
1条回答
  • 2021-01-28 08:21

    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");
      }
    });
    
    0 讨论(0)
提交回复
热议问题