disable clickable landmark on google map

后端 未结 6 656
粉色の甜心
粉色の甜心 2020-12-03 06:56

I\'m using google map API v3. I want to disable click action on default google landmark/poi. For example, when I zoom to UCLA, the school icon shows up (that\'s fine) but I

6条回答
  •  情书的邮戳
    2020-12-03 07:29

    I understand that the OP wants a solution that persists the labels/icons but suspends the click events. I'm not sure this is possible; please star this issue

    However, some of us are drawing shapes sans Drawing Manager and labels/icons are obstructing the additions of new points. If it meets your requirements, you can temporarily remove the icons/labels. I've found that transit, poi, and landscape all need to be toggled:

    var map = new google.maps.Map(document.getElementById("map"), {});
    map.poi = function(state){
    
      var styles = [
        {
          "featureType": "transit",
          "stylers": [
            { "visibility": "off" }
          ]
        },{
          "featureType": "poi",
          "stylers": [
            { "visibility": "off" }
          ]
        },{
          "featureType": "landscape",
          "stylers": [
            { "visibility": "off" }
          ]
        }
      ];
    
      this.set("styles", (state)? {} : styles );
    
    }
    

    And the usage:

    //turn the labels/icons off
    map.poi(false);
    
    //turn them back on
    map.poi(true);
    

提交回复
热议问题