【问题标题】:Hide other location on google map在谷歌地图上隐藏其他位置
【发布时间】:2017-08-09 02:48:29
【问题描述】:

如何在谷歌地图上隐藏其他酒店位置,我只想在我的项目中显示酒店位置。我尝试了许多不同的方式,比如能见度:关闭等等......但它也隐藏了我的酒店位置。请帮助纠正这个问题。我想我错过了什么。 API key在这里的作用是什么?

<script>
function initMap() {
   var map = new google.maps.Map(document.getElementById('map'), {
   center: {lat:-0.0044766 , lng: 51.5374279}, 
   zoom: 16,
   styles: [
   {
      featureType: 'poi',
      elementType: 'business',
      stylers: [{visibility :'Off'}]
   },
   ]
});

}

【问题讨论】:

    标签: api dictionary location hide


    【解决方案1】:

    您可以使用Place details获取有关您酒店的详细信息。

    像这个例子:

    function initMap() {
      var map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -33.8667904, lng: 151.1957624},
        zoom: 18,
        styles: 
          [{
            "featureType": "poi.business",
            "stylers": [{"visibility": "off"}]
          }]
      });
    
      var infowindow = new google.maps.InfoWindow();
      var service = new google.maps.places.PlacesService(map);
    
      service.getDetails({
        placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4'
      }, function(place, status) {
        if (status === google.maps.places.PlacesServiceStatus.OK) {
          var marker = new google.maps.Marker({
            map: map,
            position: place.geometry.location
          });
          alert(place.name+' '+ place.formatted_address);
    
        }
      });
    }
    

    基于Styled Map Wizard,隐藏你的酒店后,所有那种建筑物也会被隐藏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 2014-02-18
      • 2012-12-17
      • 1970-01-01
      相关资源
      最近更新 更多