title: Way-points - How can i remove a specific way-point from google maps?
body: <p>I am making this app with the help of google maps, i am successfully adding <code>waypoints</code> in a route and making a route between them. But on <code>dbclick</code> i remove that way point from the map. Now when i make the route it includes the deleted <code>waypoint</code> too. Because of the fact it does not delete from the <code>waypoint</code> array.</p>
  
  <p>The question is how can i remove a specific <code>waypoint</code> from the waypoint array. I dont have any <code>index</code> of something. </p>
  
  <p><strong>pushing waypoints</strong></p>
  
  <pre><code>/* Whenever a user taps a pin it goes into pinwapypts */
          pinwaypts.push({
            location: $scope.destination_route,
            stopover: true,
  
          });
  </code></pre>
  
  <p><strong>Add waypoints in map</strong></p>
  
  <pre><code> infowindow.open($scope.map, marker);
          $scope.markers.push(marker);
          google.maps.event.addListener(marker, 'click', function () {
            infowindow.setContent($scope.results[0].formatted_address);
            infowindow.open($scope.map, this);
          });
  </code></pre>
  
  <p><strong>removing waypoint marker from map</strong></p>
  
  <pre><code>google.maps.event.addListener(marker, 'dblclick', function () {
            $scope.markers.pop().setMap(null);
  
          });
  </code></pre>
  
  <p>Now how can i remove a specific <code>waypoint</code> from its array ?</p>
  
  <p><strong>full code</strong></p>
  
  <pre><code>  function getClickLoc(latlng) {
    var geocoder = new google.maps.Geocoder;
    geocoder.geocode({
      'location': latlng
    }, function (results, status) {
      $scope.results = results;
      //console.log(results);
      if (status === 'OK') {
        if (results[0]) {
          $scope.map.setZoom(12);
          var marker = new google.maps.Marker({
            position: latlng,
            map: $scope.map
          });
  
  
          infowindow.setContent(results[0].formatted_address);
  
          $scope.destination_route = latlng;
  
          /* Whenever a user taps a pin it goes into pinwapypts */
          pinwaypts.push({
            location: latlng,
            stopover: true
  
          });
  
          $scope.$apply();
  
          infowindow.open($scope.map, marker);
          $scope.markers.push(marker);
  
          google.maps.event.addListener(marker, 'dblclick', function () {
            infowindow.setContent($scope.results[0].formatted_address);
            infowindow.open($scope.map, this);
          });
  
          google.maps.event.addListener(marker, 'dblclick', function () {
            $scope.markers.pop().setMap(null);
          });
  
          //$ionicLoading.hide();
        } else {
          window.alert('No results found');
        }
      } else {
        window.alert('Something went wrong, Please try again.');
        //window.alert('Geocoder failed due to: ' + status);
      }
    });
  }
  </code></pre>