2015-11-02 89 views
2

我想要從我的谷歌地圖中刪除垂直和水平虛線。創建地圖時,我需要做些什麼來移除它們?如何從我的谷歌地圖中刪除虛線

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);

回答

0

你必須創建一個樣式化地圖刪除赤道和國際日期變更線。但請注意,它也可以刪除其他管理元素。

// Map style CODE after create $googlemap 
var cleanStyle = [{ 
    featureType: "administrative", 
    elementType: "geometry", 
    stylers: [ 
     { visibility: "off" } 
    ] 
}]; 

// Create a new Styled Map 
var styledMap = new google.maps.StyledMapType(cleanStyle); 
// Attach the styledMap with the main map 
$googlemap.mapTypes.set('cleanMap', styledMap); 
// Set the new styled map as active 
$googlemap.setMapTypeId('cleanMap'); 

這裏是一個example

2

如果你只想赤道並刪除了國際日期變更線。看起來你需要刪除所有的管理幾何。

{ 
    "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" } 
    ] 
    } 

代碼片段:

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"></script> 
 
<div id="map_canvas"></div>

+0

它的工作,谷歌的精彩選項 –