我正在使用Styled Map Wizard为我的 map 样式设置 JSON。但我们的客户希望将任何自行车道或步行道设为虚线。我似乎找不到一种方法来使路径成为虚线。这可能吗?
最佳答案
是的:
Dashed lines
You can achieve a dashed line effect by setting the opacity of your polyline to 0, and overlaying an opaque symbol over the line at regular intervals.
示例代码
// Define a symbol using SVG path notation, with an opacity of 1.
var lineSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4
};
// Create the polyline, passing the symbol in the 'icons' property.
// Give the line an opacity of 0.
// Repeat the symbol at intervals of 20 pixels to create the dashed effect.
var line = new google.maps.Polyline({
path: [{lat: 22.291, lng: 153.027}, {lat: 18.291, lng: 153.027}],
strokeOpacity: 0,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '20px'
}],
map: map
});
希望这有帮助
关于javascript - Google map 主题样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37874949/