【问题标题】:Is there a way to display Google Maps without the existing places/buildings and only with custom places/buildings?有没有办法在没有现有地点/建筑物的情况下仅显示自定义地点/建筑物的谷歌地图?
【发布时间】:2017-08-22 18:47:11
【问题描述】:

有没有办法在没有现有地点/建筑物的情况下仅显示自定义地点/建筑物的 Google 地图?

我想保留道路、街道、大道。但对于建筑物,我想专门从我们的数据库中获取所有内容。

【问题讨论】:

标签: google-maps google-maps-api-3


【解决方案1】:

您可以使用样式隐藏地图上的某些功能。此处描述了此方法:

https://developers.google.com/maps/documentation/javascript/styling

查看以下隐藏兴趣点(地点)和建筑物的示例:

var map;
function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 41.394035, lng: 2.190287},
    zoom: 17,
    styles: [
      {
        "featureType": "administrative.land_parcel",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      },
      {
        "featureType": "landscape.man_made",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      },
      {
        "featureType": "poi",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      }
    ]
  });
}
#map {
  height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU&callback=initMap"
    async defer></script>

我希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-22
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    相关资源
    最近更新 更多