Javascript 如何在google maps v3中使用点设置多段线,这些点将线与粗体点连接起来

Javascript 如何在google maps v3中使用点设置多段线,这些点将线与粗体点连接起来,javascript,google-maps-api-3,Javascript,Google Maps Api 3,多段线是否支持点,使其显示如下: 我正在尝试实现它,但我能想出如何设置点。使用此代码: polyline = new google.maps.Polyline({ path: coordinates, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 4 }); map.setCenter(new google.maps.LatLng(response[centerIndex

多段线是否支持点,使其显示如下:

我正在尝试实现它,但我能想出如何设置点。使用此代码:

polyline = new google.maps.Polyline({
    path: coordinates,
    strokeColor: "#FF0000",
    strokeOpacity: 1.0,
    strokeWeight: 4
});

map.setCenter(new google.maps.LatLng(response[centerIndex].Lat, response[centerIndex].Long));
polyline.setMap(map);
我只能这样做:


您将看到线之间没有显示点。可以显示点吗?

可以使用点和数组保存点,然后可以沿多段线创建自定义标记。

要在多段线的顶点上放置标记,请执行以下操作:

 polyline = new google.maps.Polyline( {
    path          : coordinates,
    strokeColor   : "#FF0000",
    strokeOpacity : 1.0,
    strokeWeight  : 4
 } );

 for ( var i = 0; i < polyline.getPath().getLength(); i++ ) {
    var marker = new google.maps.Marker( {
       icon     : {
           // use whatever icon you want for the "dots"
           url     : "https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png",
           size    : new google.maps.Size( 7, 7 ),
           anchor  : new google.maps.Point( 4, 4 )
       },
       title    : polyline.getPath().getAt( i ),
       position : polyline.getPath().getAt( i ),
       map      : map
    } );
}

map.setCenter( new google.maps.LatLng( 
   response[ centerIndex ].Lat,
   response[ centerIndex ].Long ) );
polyline.setMap( map );