【发布时间】:2017-04-24 03:27:09
【问题描述】:
我正在尝试将 angular-leaflet-directive 与 Websocket 一起使用,尽管我能够成功集成,但标记的位置不会动态更新。但是如果我将鼠标移到地图上,地图的位置会更新,但在 lat-lng 值更改时不会更新。
下面是模块的sn-p代码
$scope.markers = {};
angular.extend($scope, {
bounds : $scope.bounds,
center : {},
kppaths : {},
events: {
markers:{
enable: [ 'move' ]
}
}
});
$stomp.setDebug(function(args) {
$log.info(args);
});
$scope.startWS = function() {
var connectionHeaders = {};
// Connect
$stomp.connect("/kp-ws").then(function(frame){
$log.info("connected to server")
$stomp.send('/app/start', {});
// Subscribe for message
$scope.subscription = $stomp.subscribe('/topic/kp', function(
data, headers, res) {
angular.forEach(data, function(k,v){
$scope.markers[k.markerId].lat = k.lat;
$scope.markers[k.markerId].lng = k.lng;
});
});
});
};
$scope.stopWS = function() {
$stomp.send('/app/stop', {});
$scope.subscription.unsubscribe();
$stomp.disconnect();
};
$scope.$on("leafletDirectiveMarker.move", function(event, args){
$log.info(args.model.lat);
});
} ]);
html文件
<div class="card-block">
<leaflet bounds="bounds" geojson="geojson" lf-center="center"
paths="kppaths" markers="markers" event-broadcast="events" width="100%" height="480px"></leaflet>
</div>
我是否遗漏了什么,请告诉我或建议如何解决此问题?
【问题讨论】:
-
我有同样的情况 - 地图上的标记位置不会更新,当 lat/lng 更新时。动态绑定似乎无法正常工作。不幸的是,似乎停止了对 angular-leaflet-directive 的支持,因此我认为我们无法获得任何帮助。 @Karthik Prasad - 你找到这个解决方案了吗?如果是,你介意与我们分享吗?
标签: angularjs leaflet angular-leaflet-directive