我试图使用谷歌地图制作地图。我想要只显示分隔国家的边界。
以下图片是我想要的结果:
预期结果如下:
正如您所看到的,我无法弄清楚如何展示将国家分开的边界:
这是我用来获取第二个屏幕截图的自定义样式:
[{
elementType: "geometry",
stylers: [{
color: "#cbdddd"
}]
},
{
elementType: "labels.icon",
stylers: [{
visibility: "off"
}]
},
{
elementType: "labels.text.fill",
stylers: [{
color: "#616161",
visibility: "off"
}]
},
{
elementType: "labels.text.stroke",
stylers: [{
color: "#f5f5f5",
visibility: "off"
}]
},
{
featureType: "poi.park",
elementType: "geometry",
stylers: [{
visibility: "off"
}]
},
{
featureType: "water",
elementType: "geometry",
stylers: [{
color: "#f2f6f7"
}]
},
{
featureType: "administrative",
elementType: "labels",
stylers: [{
visibility: "off"
}]
},
{
featureType: "poi",
elementType: "labels",
stylers: [{
visibility: "off"
}]
},
{
featureType: "water",
elementType: "labels",
stylers: [{
visibility: "off"
}]
}]
我的问题是,展示边界的风格是什么?
答案 0 :(得分:2)
我添加了几行:
{
featureType: "administrative.country",
elementType: "geometry.stroke",
stylers: [{
color: '#ffffff'
}]
}
阅读完这些教程和API之后:
我得到了想要的结果。
这里的完整风格:
[{
elementType: "geometry",
stylers: [{
color: "#cbdddd"
}]
},
{
featureType: "poi.park",
elementType: "geometry",
stylers: [{
visibility: "off"
}]
}, {
featureType: "water",
elementType: "geometry",
stylers: [{
color: "#f2f6f7"
}]
}, {
featureType: "administrative",
elementType: "labels",
stylers: [{
visibility: "off"
}]
}, {
// I added those line
featureType: "administrative.country",
elementType: "geometry.stroke",
stylers: [{
color: '#ffffff'
}]
}, {
featureType: "poi",
elementType: "labels",
stylers: [{
visibility: "off"
}]
}, {
featureType: "water",
elementType: "labels",
stylers: [{
visibility: "off"
}]
}
]