I have data coming from a Json file and I created a layer based on this Json file using markerClusterGroup. I am hitting the wall trying to do two things:

1 - Select some markers based on some Json's feature ("temperatura", "salinidade","corrente", "profundidade" e "geofisico") in xbt.json and using a select list in the HTML:

<select name="sometext" >
  <option value="temperatura">temperatura</option>
  <option value="salinidade">salinidade</option>
  <option value="corrente">corrente</option>
  <option value="profundidade">profundidade</option>
  <option value="geofisico">geofisico</option>

2 - Change the marker icon using the function and code below;

var greenIcon = L.icon({
    iconUrl: 'icon/leaf-green.png',
    shadowUrl: 'icon/leaf-shadow.png',

    iconSize:     [38, 95], // size of the icon
    shadowSize:   [50, 64], // size of the shadow
    iconAnchor:   [22, 94], // point of the icon which will correspond to marker's location
    shadowAnchor: [4, 62],  // the same for the shadow
    popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor

That is how I am adding the json to the map using popups and makercluster:

var xbt = getJson('geojson/xbt.json');
var markers_xbt = L.markerClusterGroup();
var estacoes_xbt = L.geoJson(xbt, { 
        onEachFeature: function (feature, layer) //functionality on click on feature
            layer.bindPopup("Navio: "+feature.properties.navio+"<br>"+"Comissao: "+feature.properties.comissao+"<br>"+ "Bandeira do Navio:"+feature.properties.naviobandeira+"<br>"+"Equipamento: "+feature.properties.equipamento+"<br>"+ "Inicio da Comissao:"+feature.properties.iniciocomissao+"<br>"+"Fim da Comissao : "+feature.properties.fimcomissao+"<br>"+"Data de Lancamento: "+ feature.properties.estacaodata+"<br>"+"Hora de Lancamento: " +feature.properties.estacaohora+"<br>"+"Quadrado de Marsden: "+feature.properties.quadrado+"<br>"+"Subquadrado de Marsden: "+feature.properties.subquadrado ); //just to show something in the popup. could be part of the geojson as well!

    markers_xbt.addLayer(estacoes_xbt); // add it to the cluster group
    map.addLayer(markers_xbt);      // add it to the map
    map.fitBounds(markers_xbt.getBounds()); //set view on the cluster extend

closed as too broad by PolyGeo Oct 9 '15 at 3:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Would you be able to take the Tour to familiarize yourself with how the site works, please? Although you have not included any question marks, it looks like you are trying to ask two questions and, as per the Tour, there should be only one question per question. – PolyGeo Oct 9 '15 at 3:50