Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/01/2013, 10:54
vani18
 
Fecha de Ingreso: junio-2010
Mensajes: 752
Antigüedad: 14 años, 8 meses
Puntos: 5
Respuesta: borrar marcadores google maps

Cita:
Iniciado por ipraetoriux Ver Mensaje
...seguramente cuando has agregado los marcadores has creado un array para pasar cada elemento del mismo al objeto google.map.Marker y asi ubicarlos en el mapa...

supongamos que el array se llama...arrayMarcadores;

...tienes que crear una funcion que recorra el array y elimine cada marcador y luego vaciar el array...

Código Javascript:
Ver original
  1. function LimpiarMarcadores() {
  2.     for (var i = 0; i < arrayMarcadores.length; i++) {
  3.         arrayMarcadores[i].setMap(null);
  4.     };
  5.  
  6.     arrayMarcadores= [];
  7.  
  8. }


yo leo de un XML externo, creo que en mi caso no tengo un array...

coloco los marcadores en un array ??? entonces y hago lo qe me dijiste,,

Código PHP:
        $(xml).find("marker").each(function(){
        
        
                
        
        
            var 
name = $(this).find('nombre_medico').text();
        
//    var address = $(this).find('address').text();
            
var address "holaaa";
            
            
            
// create a new LatLng point for the marker
            
var lat = $(this).find('latitud').text();
            var 
lng = $(this).find('longitud').text();
            var 
point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
            
            
// extend the bounds to include the new point
            
MYMAP.bounds.extend(point);
            
            var 
marker = new google.maps.Marker({
                
positionpoint,
                
mapMYMAP.map
            
});
            
            var 
infoWindow = new google.maps.InfoWindow();
            var 
html='<strong>'+name+'</strong.><br />'+address;
            
google.maps.event.addListener(marker'click', function() {
                
infoWindow.setContent(html);
                
infoWindow.open(MYMAP.mapmarker);
            });
            
MYMAP.map.fitBounds(MYMAP.bounds);
        });