使用JavaScript在Google地图上绘制虚线圆圈

时间:2017-07-19 10:45:08

标签: javascript google-maps

我是google maps api的新手我不知道如何在谷歌地图上创建虚线圆圈。我使用以下代码在谷歌地图上创建了圆圈

circle = new google.maps.Circle({
strokeColor: Settings.CircleRadius.strokeColor, 
strokeOpacity: Settings.CircleRadius.strokeOpacity,
strokeWeight: Settings.CircleRadius.strokeWeight,
fillColor: #0000FF,
fillOpacity: Settings.CircleRadius.fillOpacity,
center: click_latlon, 
map: map,
//clickable: true,
radius: radius_m   //Radius in meters 
});

有人可以帮我解决如何在谷歌地图上绘制虚线圆圈的问题。

1 个答案:

答案 0 :(得分:0)

以下是虚线折线的代码,您可以尝试类似圆圈

 // 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
    });