tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 635 forks source link

Marker Update - Too Slow #1020

Closed guchan closed 9 years ago

guchan commented 9 years ago

Hi, I am new to leaflet-directive. I am trying to update the markers dynamically a) with show/hide buttons b) with real time data. In both cases I am trying to update markers in a function like this: $scope.marker["some_id"] = {lat: .... lng:... } and to delete I simply use $scope.marker["some_id"] = {}

However, this simple update takes too long, 1-2sec. I don't know if I am doing something wrong or this is the normal behavior ?

$scope.drawMapVehicles = function(){ $scope.markers = {}; angular.forEach($scope.vehicles, function(vehicle, vehicle_key){
$scope.markers[vehicle.vehicle.id] = { lat:parseFloat(vehicle.trips[0].trip.attributes.EndLat), lng:parseFloat(vehicle.trips[0].trip.attributes.EndLon), draggable: false
}

});

}

PS: vehicle array only has 2 vehicles so there isn't any overload in above loop.

Thanks!

tombatossals commented 9 years ago

Hi @guchan , could you provide a jsfiddle showing this behaviour? You could use this jsfiddle as a starting point:

http://jsfiddle.net/maistho/9jymzymu/

I'm actually reworking all the code to make it compatible with Leaflet 1.0 and start the compatibility with Angular 2.0, but I can take a look at your problem if it's a bug generic enough.

I will reopen this issue if you provide the jsfiddle. Thanks

guchan commented 9 years ago

Thanks for your quick response! Actually, I figured my problem out just now. It was mainly because of too many asynchronous calls.