Search code examples
javascriptmapsleafletreact-leaflet

How to display 2 values on leaflet control search result(tooltip)


i'm using leaflet-control-search to search for markers. https://opengeo.tech/maps/leaflet-search/examples/outside.html markers are stored in json like this

[{"loc":["lat","lng"],"title":"black","region":"West-Kilimajaro"}]

in the script above its only displaying 1 value:screen shot

i want to display 2(two) values 'title and 'colour';


Solution


  • i finally found the solution second attribute is suppose to be added as follows

     for(i in data) {
     var title = data[i].title,region=data[i].region,
     loc = data[i].loc, 
     marker = new L.Marker(new L.latLng(loc), {title: title,region:region} );
     marker.bindPopup('title: '+ title );
     markersLayer.addLayer(marker);}
    

    markers are stored in json should look like this

    {"loc":[-3.3869, 36.6830], "title": "aquamarinee", "region": "West-Kilimanaro"}