title: Markers from one Angular ng-map re-appearing in the wrong view
body: <p>I've got an Angular 1.5 app running <code>ui-router</code> and <code>NgMap</code> to display Google Maps. </p>
  
  <p>My problem: Markers displayed on the map in one state, with one controller, are reappearing on a different map, in a different state that doesn't even use the same controller.</p>
  
  <p><a href="http://plnkr.co/edit/ZLgERtsxSYTaWA6GY7kY?p=preview" rel="nofollow">I've created a Plunker here that shows the issue.</a></p>
  
  <p>In my MapController, I have to do an <code>NgMap.getMap()</code> to add markers because I'm going to be doing some more advanced work with markers that will be beyond the capabilities of NgMap alone. Still, I don't know why these markers would be carrying over to a different map in a different controller in a different view. Does anyone know of a good way to deal with this?</p>
  
  <pre><code>var routerApp = angular.module('routerApp', ['ui.router', 'ngMap']);
  
  routerApp.config(function($stateProvider, $urlRouterProvider) {
  
      $urlRouterProvider.otherwise('/map');
  
      $stateProvider
  
          .state('map', {
              controller:"MapController",
              url: '/map',
              templateUrl: 'map.html'
          })
          .state('view', {
              controller:"ViewController",
              url: '/view/?lat&amp;lng',
              templateUrl: 'view.html'
          })
  
  
  });
  
  routerApp.controller('MapController', function($scope, NgMap, $state) {
    NgMap.getMap({id:"main-map"}).then(function(map){
      markers = [];
  
      for(i = -180; i &lt; 180; i = i + 30){
        for(j = -85; j &lt; 85; j = j + 30){
         marker = new google.maps.Marker({
            position: {
              lng: i,
              lat: j
            },
            map: map
          });
  
          marker.addListener('click', function() {
              $state.go("view", {lat: marker.getPosition().lat(), lng:marker.getPosition().lng()});
          });
  
          markers.push(marker)
        }
      }
    });
  });
  
  routerApp.controller('ViewController', function($scope, NgMap, $state, $stateParams) {
    $scope.lat = $stateParams.lat;
    $scope.lng = $stateParams.lng;
  });
  </code></pre>