Google maps api 3 仅将符号路径图标置于当前位置

Google maps api 3 仅将符号路径图标置于当前位置,google-maps-api-3,Google Maps Api 3,我试图将符号路径图标放在路线的当前位置,但图标没有显示在地图上 var carPath = new google.maps.MVCArray(); for ( var i = 0; i < path_start.length; i++) { if(i === 0) { carPath.push(path_start[i]); carPolyline.setPath(carPath); } else { setTimeout((functio

我试图将符号路径图标放在路线的当前位置,但图标没有显示在地图上

 var carPath = new google.maps.MVCArray();
 for ( var i = 0; i < path_start.length; i++) {
   if(i === 0) {
      carPath.push(path_start[i]);
     carPolyline.setPath(carPath);
   } else {
      setTimeout((function(latLng) {
      return function() {
        new google.maps.Marker({
                            map: map,
                            icon:{
                                path:google.maps.SymbolPath.FORWARD_CLOSED_ARROW,

                                scale:3,
                                strokeColor: 'white',
                                strokeWeight: 1,
                                fillOpacity: 0.8,
                                fillColor: 'orange',
                                offset: '100%'

                            },
                            position: path_start[i],

                        });
           carPath.push(latLng);
        };
      })(path_start[i]), 100 * i);
    }
   }
var carPath=new google.maps.MVCArray();
对于(变量i=0;i
先谢谢你


在匿名函数中,保存google.maps.LatLng对象的变量名是
LatLng
,而不是
path\u start[i]

更改:

    new google.maps.Marker({
                        map: map,
                        icon:{
                            path:google.maps.SymbolPath.FORWARD_CLOSED_ARROW,

                            scale:3,
                            strokeColor: 'white',
                            strokeWeight: 1,
                            fillOpacity: 0.8,
                            fillColor: 'orange',
                            offset: '100%'

                        },
                        position: path_start[i]
                    });
致:

更有可能是你想要的

将图标添加到多段线,不要使其成为标记

var lineSymbol = {
  path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
};
   var carPolyline = new google.maps.Polyline({
        map: map,
        geodesic : true,
        strokeColor : '#FF0000',
        strokeOpacity : 1.0,
        strokeWeight : 2,
        icons: [{
          icon: lineSymbol,
          offset: '100%'
        }],
    });
var lineSymbol = {
  path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
};
   var carPolyline = new google.maps.Polyline({
        map: map,
        geodesic : true,
        strokeColor : '#FF0000',
        strokeOpacity : 1.0,
        strokeWeight : 2,
        icons: [{
          icon: lineSymbol,
          offset: '100%'
        }],
    });