My script adds markers to the map. When I want remove the last I click back button http://tests.uk4u.pl/goomap/goomap_markers/ Everything works OK but I started something similar with poliline. After many possible changes of my code I cant achieve the same like with my markers. I want remove last line of poliline with back button. After removing last one I want to have possibility to start from this point like with my markers. Please help me cos I cant find solution anywhere and I tried last two days.
var testInput;
var path=[];
var map;
var mapOptions = {
center: new google.maps.LatLng(53.153691, -2.011640),
zoom: 15
};
var poly;
var polyOptions = {
strokeColor: 'red',
strokeOpacity: 0.8,
strokeWeight: 4
};
function initialize() {
testInput = document.getElementById('test_input');
testInput.value = '';
map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(document.getElementById('menu'));
poly = new google.maps.Polyline(polyOptions);
google.maps.event.addListener(map, 'click', function(event) {
poly.setMap(map);
var myLatLng = event.latLng;
var lat = myLatLng.lat();
var lng = myLatLng.lng();
addLatLng(event);
});
path = poly.getPath();
function addLatLng(event) {
path.push(event.latLng);
testInput.value = path.toString();
}
}
function deleteMarker() {
poly.setMap(null);//remove from map
path = [];
}
google.maps.event.addDomListener(window, 'load', initialize);