猿问

如何自定义地图并删除“ POI图层”?

在嵌入式Google地图上(例如,这里-https://www.familienfreunde.de/4.php?Nummer=132700000302),您可以看到很多景点。


我想删除它们。


<script>

function initMap() {

  var latlng = new google.maps.LatLng(51.3267379,12.3653812);

  var myOptions = {

 zoom: 19,

 center: latlng,

 mapTypeControlOptions: {

 mapTypeIds: ["roadmap", "satellite"]

}

 };

  map = new google.maps.Map(document.getElementById("map"), myOptions);

  var box_html = "<h5>Gymnasium Gerda Taro Schule</h5><p>04107 Leipzig<br /><b><a href=\"4.php?Nummer=132700000302\">Profil anzeigen</a></b></p>";

  var icon = new google.maps.MarkerImage('/bilder/marker4.png'); 

  var marker = add_marker(51.3267379,12.3653812,'Gymnasium Gerda Taro Schule',box_html,icon);

  marker.setMap(map);

        var box_html = "<h5>Rechtsanwalt Henry Bach</h5><p>04107 Leipzig<br /><b><a href=\"22.php?Nummer=378\">Profil anzeigen</a></b></p>";

  var icon = new google.maps.MarkerImage('/bilder/marker22.png'); 

  var marker = add_marker(51.3339224,12.3741322,'Rechtsanwalt Henry Bach',box_html,icon);

  marker.setMap(map); }

function add_marker(lat,lng,title,box_html,icon) {

     var infowindow = new google.maps.InfoWindow({

     content: box_html

   });

     var marker = new google.maps.Marker({

      position: new google.maps.LatLng(lat,lng),

      map: map,

      icon: icon,

      title: title

    });

     google.maps.event.addListener(marker, 'click', function() {

   infowindow.open(map,marker);

  });

     google.maps.event.addListener(map, 'dragstart', function() {

    infowindow.close();

   });

     return marker;

    }

</script> 

<script src="https://maps.googleapis.com/maps/api/js?key=UNSERKEY&callback=initMap" async defer></script>

(为了清楚起见,我仅删除了一些其他标记。)


绝地无双
浏览 211回答 1
1回答

眼眸繁星

您可以尝试使用styles属性查看POI的可见性&nbsp; &nbsp; function initMap() {&nbsp; &nbsp; &nbsp; var latlng = new google.maps.LatLng(51.3267379,12.3653812);&nbsp; &nbsp; &nbsp; var myOptions = {&nbsp; &nbsp; &nbsp;zoom: 19,&nbsp; &nbsp; &nbsp;center: latlng,&nbsp; &nbsp; &nbsp;styles = [&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; featureType: "poi",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elementType: "labels",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stylers: [&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { visibility: "off" }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ];&nbsp; &nbsp; &nbsp;mapTypeControlOptions: {&nbsp; &nbsp; &nbsp;mapTypeIds: ["roadmap", "satellite"]&nbsp; &nbsp; }
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答