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
내 전체 코드를 참조하십시오. –