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



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

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

您可以使用样式隐藏地图上的某些要素。此方法描述如下:

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>

我希望这有帮助!

最新更新