angularjs-google-maps icon indicating copy to clipboard operation
angularjs-google-maps copied to clipboard

Change in ng-repeat model should delete existing markers

Open simonh1000 opened this issue 12 years ago • 4 comments

Instead it adds more markers to the map without deleting existing ones.

I'd love to try to submit a patch for you but I can't work out where the detection of a changed model takes place

simonh1000 avatar Sep 08 '14 11:09 simonh1000

Duplicate to #75

allenhwkim avatar Sep 08 '14 13:09 allenhwkim

I fixed this issue by adding this to marker.js on line 80:

        /**
         * set event to clean up removed marker
         */
        element.bind('$destroy', function() {
          var markers = marker.map.markers;
          for (var name in markers) {
            if (markers[name] == marker) {
              delete markers[name];
            }
          }
          marker.setMap(null);          
        });

I try to create a pull request at the weekend.

thochi avatar Sep 11 '14 13:09 thochi

wonderful

Please make sure all gulp test is passing. :)

On Sep 11, 2014, at 9:18 AM, Thomas Chille [email protected] wrote:

I fixed this issue by adding this to marker.js on line 80:

    /**
     * set event to clean up removed marker
     */
    element.bind('$destroy', function() {
      var markers = marker.map.markers;
      for (var name in markers) {
        if (markers[name] == marker) {
          delete markers[name];
        }
      }
      marker.setMap(null);          
    });

I try to create a pull request at the weekend.

— Reply to this email directly or view it on GitHub.

allenhwkim avatar Sep 11 '14 13:09 allenhwkim

Solved. example here, https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/dynamic_markers_with_ng_repeat.html

allenhwkim avatar Sep 15 '14 01:09 allenhwkim