私はgoogleマップの助けを借りてこのアプリを作っています。私は正常にwaypoints
をルートに追加し、それらの間のルートを作っています。しかし、dbclick
私はマップからその方法のポイントを削除します。今私はルートを作るときそれは削除されたwaypoint
を含んでいる。事実のため、配列waypoint
からは削除されません。ウェイポイント - Googleマップから特定のウェイポイントを削除するにはどうすればよいですか?
質問は、特定のwaypoint
をウェイポイントアレイから削除する方法です。私は何かのindex
を持っていない。
押してウェイポイント
/* Whenever a user taps a pin it goes into pinwapypts */
pinwaypts.push({
location: $scope.destination_route,
stopover: true,
});
は
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);
});
マップ
google.maps.event.addListener(marker, 'dblclick', function() {
$scope.markers.pop().setMap(null);
});
からウェイポイントマーカーを削除するマップにウェイポイントを追加します。
配列から特定のwaypoint
を削除するにはどうすればよいですか?
完全なコード
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);
}
});
}
あなたのルートを取得する前に、あなたが追加したすべてのウェイポイントのために対応する一つのマーカーが同じ順序であるのでしょうか? – henrisycip
私のフルコードをご覧ください –