gpt4 book ai didi

javascript - 如何从我的谷歌地图中删除虚线

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:58:39 34 4
gpt4 key购买 nike

我希望能够从我的谷歌地图中删除垂直和水平虚线。在创建 map 时我需要做什么来删除它们?

enter image description here

var mapOptions = {
zoom: "",
zoomControl: "",
center: "",
disableDefaultUI: "",
draggable: "",
styles: "",
disableDoubleClickZoom: ""
}

mapOptions.zoom = 1;
mapOptions.zoomControl = false;
mapOptions.center = new window.google.maps.LatLng(mapCoordinates.latitude, mapCoordinates.longitude);;
mapOptions.disableDefaultUI = true;
mapOptions.draggable = false;
mapOptions.styles = "";
mapOptions.disableDoubleClickZoom = true;

$googlemap = new window.google.maps.Map(document.getElementById('map-canvas'), mapOptions);

最佳答案

如果您只想删除赤道和国际日期变更线。看起来您需要删除所有管理几何图形。

{
"featureType": "administrative",
"elementType": "geometry",
"stylers": [
{ "visibility": "off" }
]
}

这也删除了所有其他行政边界,要将它们放回去,您需要将它们单独添加回去:

  {
"featureType": "administrative.country",
"elementType": "geometry.stroke",
"stylers": [
{ "visibility": "on" }
]
},{
"featureType": "administrative.province",
"elementType": "geometry.stroke",
"stylers": [
{ "visibility": "on" }
]
},{
"featureType": "administrative.locality",
"elementType": "geometry.stroke",
"stylers": [
{ "visibility": "on" }
]
},{
"featureType": "administrative.neighborhood",
"elementType": "geometry.stroke",
"stylers": [
{ "visibility": "on" }
]
},{
"featureType": "administrative.land_parcel",
"elementType": "geometry.stroke",
"stylers": [
{ "visibility": "on" }
]
}

screenshot of resulting map

代码片段:

var geocoder;
var map;

function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [{
"featureType": "administrative",
"elementType": "geometry",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "administrative.country",
"elementType": "geometry.stroke",
"stylers": [{
"visibility": "on"
}]
}, {
"featureType": "administrative.province",
"elementType": "geometry.stroke",
"stylers": [{
"visibility": "on"
}]
}, {
"featureType": "administrative.locality",
"elementType": "geometry.stroke",
"stylers": [{
"visibility": "on"
}]
}, {
"featureType": "administrative.neighborhood",
"elementType": "geometry.stroke",
"stylers": [{
"visibility": "on"
}]
}, {
"featureType": "administrative.land_parcel",
"elementType": "geometry.stroke",
"stylers": [{
"visibility": "on"
}]
}]
});


}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map_canvas"></div>

关于javascript - 如何从我的谷歌地图中删除虚线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33488040/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com