I use Leflet maps and I want to import data from layer to layer If the first layer is points and the other polygons I want to get the data from the polygon layer to the points if the layer of dots is inside the polygon layer Is there any help in that?

closed as too broad by BERA, artwork21, LaughU, Mark Ireland, xunilk Jan 2 at 15:49

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.

  • 4
    Please edit your question and tell us what you have tried, why it did not work and add your code attempt. – BERA Jan 2 at 13:01

Here's an option, I have several layers in my map, when I click on the map, it reads an attribute from each of the layers and posts it back to a bootstrap modal popup or an HTML table in a sidebar.

In this example, I set a global var for a,b,c to post back the attribute I want. I set these to "No Data" by default. In my data I have city, county, state layers that I'm just grabbing names, I could create an array and push more attribute but that wasn't my task. I also created a marker to show where I clicked. I used turf to see if I was inside the layer and if so grab the attribute. If it wasn't inside the variable had "No Data" as a value.

var c = "No Data";  

        lat = e.latlng.lat;
        lon = e.latlng.lng;

  var theMarker;
  var selPoly = [];

function ProcessClick(lat,lon){

    if (theMarker != undefined) {

    theMarker = L.marker([lat,lon]).addTo(map);

    stateLayer.eachLayer(function (layer) {

        isInside =turf.inside(theMarker.toGeoJSON(), layer.toGeoJSON());

        if (isInside){
            console.log("State: " + layer.feature.properties.STATE_NAME);
            c = "State: " + layer.feature.properties.STATE_NAME;


This example only shows one layer, the other two are similar. I then sent the var's a,b,c to the modal popup at the end of this function.

Not the answer you're looking for? Browse other questions tagged or ask your own question.