Как я могу настроить карту и удалить слой POI? - PullRequest
0 голосов
/ 08 апреля 2019

На встроенной карте 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>

(Я только убрал еще несколько маркеров для ясности.)

1 Ответ

0 голосов
/ 08 апреля 2019

Вы можете попробовать отключить видимость POI, используя свойство styles

    function initMap() {
      var latlng = new google.maps.LatLng(51.3267379,12.3653812);
      var myOptions = {
     zoom: 19,
     center: latlng,
     styles = [
        {
            featureType: "poi",
            elementType: "labels",
            stylers: [
                  { visibility: "off" }
            ]
        }
    ];
     mapTypeControlOptions: {
     mapTypeIds: ["roadmap", "satellite"]
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...