0
Q
風格谷歌地圖
A
回答
0
請按照此代碼。
在這裏你需要在下面的鏈接添加你的谷歌API密鑰。
src="https://maps.googleapis.com/maps/api/jskey=Your_api_key&callback=initMap"
這是代碼。
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: new google.maps.LatLng(38.769671, -9.097975),
mapTypeId: 'roadmap',
styles : [
{
"elementType": "geometry",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#bdbdbd"
}
]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [
{
"color": "#eeeeee"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [
{
"color": "#e5e5e5"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
},
{
"featureType": "road",
"elementType": "geometry",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{
"color": "#dadada"
}
]
},
{
"featureType": "road.highway",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
},
{
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [
{
"color": "#e5e5e5"
}
]
},
{
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [
{
"color": "#eeeeee"
}
]
},
{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{
"color": "#c9c9c9"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
}
]
});
var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var icons = {
info: {
icon: 'https://novo2.rhp.pt/map.png'
}
};
var features = [
{
position: new google.maps.LatLng(38.769671, -9.097975),
type: 'info'
}
];
// Create markers.
features.forEach(function(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map,
content:'<div>Test</div>'
});
});
}
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
如果你想改變還是那麼地圖樣式請點擊此鏈接https://mapstyle.withgoogle.com/,創造任何你想要的,只是複製整個JSON代碼及以上styles
對象替換英寸
希望這會有所幫助。
+0
謝謝。有效! – lordpicard
相關問題
- 1. Subgurim谷歌地圖風格的地圖
- 2. 風格使用谷歌地圖API
- 3. 聚合物風格谷歌地圖
- 4. 谷歌地圖api風格的地圖與衛星水
- 5. 谷歌地圖API風格的地圖 - 顏色問題
- 6. 谷歌地圖API - 將融合表層到風格圖層
- 7. 在谷歌地圖上顯示風向
- 8. Java谷歌地圖谷歌地圖
- 9. 添加谷歌地圖infoBubble內的手風琴(從谷歌地圖工具庫)
- 10. 谷歌風格嚮導
- 11. 谷歌Python風格指南
- 12. 如何實現谷歌地圖yelp.com風格?
- 13. 谷歌地圖磚 - 街道和標籤覆蓋着風格?
- 14. ie7和ie6似乎沒有風格在谷歌地圖api v3
- 15. jquery-ui-map(谷歌地圖jquery插件)風格infowindow
- 16. 谷歌地圖層onclick更改風格多邊形
- 17. 如何嵌入風格的谷歌地圖在您的網站
- 18. Yelp風格的谷歌地圖,沿用戶上下頁面
- 19. 如何使用openInfoWindowTabsHtml爲谷歌地圖泡泡賦予風格?
- 20. 谷歌地圖API的信息窗口風格誤差
- 21. 自定義風格到谷歌地圖V3覆蓋
- 22. 如何修改谷歌地圖導航器的控制風格
- 23. 谷歌地圖的地址格式
- 24. 谷歌地圖V3:風格化的地圖突然失去了他們的風格?
- 25. 谷歌地圖谷歌地點類型
- 26. 谷歌地圖
- 27. 谷歌地圖
- 28. 谷歌地圖
- 29. 谷歌地圖,如地圖
- 30. 同步谷歌電子表格和谷歌(我)地圖
你想在RHP圖像中添加銀色風格的地方? –
嗨。感謝您的回覆。我想在地圖本身添加樣式 - 我已經添加了成本管腳,因爲你看到它。我只需要添加銀色風格。 – lordpicard
此鏈接將對您有用https://developers.google.com/maps/documentation/android-api/styling和https://mapstyle.withgoogle.com/。 –