问题描述
有人知道是否可以为Terrain地图创建自定义浮雕样式吗?您显然可以为法线贴图创建自定义样式,但我也想更改地形的默认色带,
Does anyone know if it is possible to create custom relief styles for Terrain maps? You can obviously create custom styles for normal maps but I would like to change the default colour ramps for terrain too,
非常感谢
推荐答案
您确实可以设置地形图的样式.我在这里有一个JSFiddle演示了这一点:
You can indeed style terrain maps. I have a JSFiddle here demonstrating this:
https://jsfiddle.net/w77bycw0/
在我的样本中,我只是将水体变成白色只是为了说明您可以为地形图设置样式.请注意,您需要添加自己的API密钥才能使其正常工作!
In my sample I just turned bodies of water white just to demonstrate that you can style a terrain map. Please note that you will need to add your own API key for it to work!
设置地形图的样式与设置道路图的样式几乎相同,只需指定地形图即可:
The way you can style a terrain map is about the same way you style the road map, you just specify terrain map:
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.674, lng: -73.945},
zoom: 12,
mapTypeId: 'terrain',
styles: [
{
featureType: 'water',
elementType: 'geometry',
stylers: [{color: '#FFFFFF'}]
},
{
featureType: 'water',
elementType: 'labels.text.fill',
stylers: [{color: '#515c6d'}]
},
{
featureType: 'water',
elementType: 'labels.text.stroke',
stylers: [{color: '#17263c'}]
}
]
});
我希望这会有所帮助!
这篇关于Google Maps API v3:地形地图的自定义样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!