angular-google-maps
angular-google-maps copied to clipboard
refreshing markers on the map
Hi, first of all many thanks for the library! its cutting my dev time to a fraction!
I have an issue with redrawing markers on the map when the model updates... I'm listening on bounds_changed (or idle) event, and pass the new bounds to a backend call to fetch corresponding markers. The map doesn't refresh with the new data right away, it takes a drags on the map for the markers to finally refresh.
I'm using the cluster and dorebuildall:
ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="map.options" bounds="map.bounds" events="{bounds_changed:reloadMarkers}">
ui-gmap-markers models="markers" coords="'self'" icon="'icon'" doCluster="true" events="map.markersEvents" dorebuildall="true">
in the controller:
$scope.reloadMarkers = function () {
var box = {
"swlng" : $scope.map.bounds.southwest.longitude,
"swlat" : $scope.map.bounds.southwest.latitude,
"nelng" : $scope.map.bounds.northeast.longitude,
"nelat" : $scope.map.bounds.northeast.latitude
};
dataService.fetchMarkers(box).then(function(result) {
$scope.markers = [];
$scope.markers.push.apply($scope.markers, result.data);
});
}
Help is greatly appreciated! thanks!
+1
+100, Have you solved it in any other way ? refresh a marker's icon ?
I am also facing the same issue. Has anybody solved it ?