I try to use following code -- but the removal 'deletelast()' do's not
work:


var allmarkers = [];
var allpolyline = [];
var map;
var marker;


function deletelast() {
  alert(allmarkers.length); // for debuging -- result OK
  var i = allmarkers.length;
      map.removeOverlay(allmarkers[i-1]); // no change - all markers
remain on the map
      allmarkers.splice(count, 1);
  var i = allpolyline.length;
      map.removeOverlay(allpolyline[i-1]); // no change - all lines
remain on the map
      allpolyline.splice(count, 1);
}


function loadMap() {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setMapType(G_HYBRID_MAP ); // Hybrid ???!!

        var llt = document.details1.rks.value;
        var llt_arr = llt.split("_");
        var ll_arr = llt_arr[0].split("¦");
        var center = new GLatLng(ll_arr[0], ll_arr[1]);
        map.setCenter(center, 8);
        for (var i = 0; i < llt_arr.length; i++) {
                // alert(llt_arr[i]);
                var ll_arr = llt_arr[i].split("¦");
                var point = new GLatLng(ll_arr[0], ll_arr[1]);
                var marker = createMarker(point,ll_arr[3] +"<br><a
href='showspot.php?sp="+ll_arr[2]+"'>click here for more details<\/
a>")
                map.addOverlay(marker);
        }


        GEvent.addListener(map, "click", function(overlay, point){
                if (point && document.details1.inssp.checked == true) {
                        var marker = new GMarker(point,mark_wp)
                        map.addOverlay(marker);
                        allmarkers.push(marker);
                        var t = marker.getLatLng().toUrlValue(6);
                        var arr = t.split(",");
                        var il = wayplo.length;
                        waypla[il] = arr[0];
                        wayplo[il] = arr[1]; // wayplo.push(arr[1]);
                        if (il > 0) {
                           var polyline = new GPolyline([
                                  new GLatLng(waypla[il-1], wayplo[il-1]),
                                  new GLatLng(waypla[il], wayplo[il])
                                ], "#ff0000", 2);
                                map.addOverlay(polyline);
                                allpolyline.push(polyline);
                        }
                }
        });

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to