[英]Dashed polygons Google Maps
I'm asking because I've searched everywhere online and this is all I have been able to find.我问是因为我在网上到处搜索,这就是我所能找到的。 So far I've been able to make dashed lines on google maps with the following code.
到目前为止,我已经能够使用以下代码在谷歌地图上制作虚线。
app.config.dashSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4,
},
new google.maps.Polyline({
map:map,
path:polygon.getPath ? polygon.getPath() : polygon,
strokeColor: vue.Projects[projectID].ContractorColor,
strokeOpacity:0,
icons:[{
icon:app.config.dashSymbol,
offset:'0',
repeat:'20px'
}],
})
That all works fine, but is there a way that I can make a Polygon object with a dashed outline?一切正常,但是有没有办法制作一个带有虚线轮廓的 Polygon 对象? I tried this, by it doesn't work
我试过了,它不起作用
new google.maps.Polygon({
map:map,
paths:polygon.getPath ? polygon.getPath() : polygon,
fillColor: vue.Projects[projectID].ContractorColor,
strokeColor:vue.Projects[projectID].ContractorColor,
strokeOpacity:0,
icons:[{
icon:app.config.dashSymbol,
offset:'0',
repeat:'20px'
}]
})
I don't think you can.我不认为你可以。 But you could overlay a Polyline on top of the Polygon.
但是您可以在多边形的顶部叠加一条折线。
function initialize() { var mapOptions = { zoom: 4, center: new google.maps.LatLng(40, 9), mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); var path = [ new google.maps.LatLng(39, 4), new google.maps.LatLng(34, 20), new google.maps.LatLng(44, 20), new google.maps.LatLng(39, 4) ]; var lineSymbol = { path: google.maps.SymbolPath.CIRCLE, fillOpacity: 1, scale: 2 }; var polygon = new google.maps.Polygon({ strokeOpacity: 0, strokeWeight: 0, fillColor: '#00FF00', fillOpacity: .6, paths: path, map: map }); var polylineDotted = new google.maps.Polyline({ strokeColor: '#000000', strokeOpacity: 0, icons: [{ icon: lineSymbol, offset: '0', repeat: '10px' }], path: path, map: map }); } initialize();
#map-canvas { height: 180px; }
<div id="map-canvas"></div> <script src="//maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.