marker click event not firing second time in google maps (ui-gmap-google-map)
I am using ui-gmap-google-map AngularJs directive and ui-gmap-marker for marker with a ng-repeat and a click event calling a function in the controller. Everything seems to work. The Map loads up with marker and marker click firing for all markers for the first time when I click on each of the markers. But from the second attempt on any of the marker to click does not trigger the click event. Version: AngularJS v1.2.8 , angular-google-maps 2.1.0 Here are code snippets replace greater than sign with } and less than sign with {
{ui-gmap-google-map center="map.center" zoom="map.zoom"} {ui-gmap-markers models="map.markers" fit="true" coords="'self'" icon="'icon'" idkey='m.id'} {ui-gmap-marker ng-repeat="m in map.markers" coords="m" icon="m.icon" ng-click='onMarkerClicked(m.sequenceId)' idkey='m.id'} {/ui-gmap-marker} {/ui-gmap-markers} {/ui-gmap-google-map}
..... same result for 'click' and 'ng-click' events ..
$scope.generateMarkers = function (referencePoints) { $scope.map.markers.length = 0; for (i = 0; i < referencePoints.length; i++) { var record = referencePoints[i]; var marker = { latitude: record.Lat, longitude: record.Long, title: record.RoadName, id: record.ID, icon: { url: '/content/images/roundcyan.png' },//pin_url(record.ID)// sequenceId:i }; $scope.map.markers.push(marker); } }; .... ..
$scope.onMarkerClicked = function (sequenceId) { if ($scope.selectedSequenceId >=0) { $scope.map.markers[$scope.selectedSequenceId].icon = { url: 'http://localhost:xxxxx/content/images/roundcyan.png' }; } $scope.selectedSequenceId = sequenceId; $scope.map.markers[sequenceId].icon = { url: 'http://localhost:xxxxx/content/images/roundcyanplus.png' }; $scope.$apply(); };
Heya, if I understand your issue correctly you might find your answer here: https://github.com/angular-ui/angular-google-maps/issues/1349
@hasanfar Closing this one. Feel free to follow-up with details and a running example if the question wasn't answered by @sphaso's issue resolution. Thanks.