【问题标题】:Getting a list of markers with jQuery/gmap3 when using the Directions service使用方向服务时使用 jQuery/gmap3 获取标记列表
【发布时间】:2012-08-18 00:54:39
【问题描述】:

我今天开始使用 gmap3 jQuery 插件,但在获取标记列表时遇到了问题。 只要我手动添加所有标记(使用 addMarker 或 addMarkers)都可以正常工作并且:

.gmap3({action:'get', name:'marker', all:true});

给出正确的标记列表。

但是,如果我使用 action:getRoute 和 addDirectionsRenderer - 上面粘贴的代码不能“获取”标记。

我用于显示路线的代码如下 - 它可以正常工作并在地图上正确显示。唯一的问题是我无法从中获取任何标记,因此我可以在创建后处理它们。

var optionDirections = {
        origin: startcoord,
        destination: stopcoord,
        waypoints: coordsAllGoogleStyle,
        optimizeWaypoints: true,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
};
....
.gmap3({
    action:'getRoute',
    options: optionDirections,
    callback: function(results) {
        if (!results) { alert('nodata'); return; }
        $(this).gmap3(
            {
                action:'addDirectionsRenderer',
                options:{
                    preserveViewport: false,
                    draggable: false,
                    directions:results
                }
            }
        );
        var res = $(this).gmap3({action:'get', name:'marker', all:true});
        alert('Found: '+res.length+' markers');
    }
});

【问题讨论】:

    标签: google-maps-markers directions jquery-gmap3


    【解决方案1】:

    为了简单起见,我联系了这个 api 的作者,它不再支持它,因为“现在人们使用 angular”

    不错吧……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-23
      • 1970-01-01
      • 1970-01-01
      • 2013-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-02
      相关资源
      最近更新 更多