【问题标题】:Marker handle in angular-leaflet-directive角度传单指令中的标记句柄
【发布时间】:2015-11-17 08:29:53
【问题描述】:

当我在页面上的其他地方有 ng-mouseover 时,我需要获取标记的句柄以便设置图标。

我像这样将我的标记放入传单中:

angular.extend($scope, 
    {markers: 
        {'id1': {lat:foo, lng:bar}, 
         'id2': {lat:foo, lng:bar}, ...
        }
    });

$scope.markers['id1'] 返回正确的 lat/lng 字典。在这里,我需要标记对象,所以我可以执行 marker.setIcon()。

看了一下leafletMarkersHelpers,但没有成功......

希望有任何起点。

感谢

最好的

/B

【问题讨论】:

    标签: angularjs leaflet angular-leaflet-directive


    【解决方案1】:

    为此有一个leafletData 服务。当您调用 leafletData.getMarkers() 时,您获得的 Promise 将使用对象中的 Leaflet 标记对象解析,并使用您的作用域中的键。

    leafletData.getMarkers().then(function (markers) {
        markers.id1.setIcon(...);
    });
    

    【讨论】:

    • Thanx - 传单数据很好 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多