0

Using a client-side webmapping library (openlayers3 or leaflet), I want my user to be able to add one marker on the map. I will then be able to retrieve long/lat coordinates.

From that, I want to know if it is located inside a polygon (from another layer) and retrieve polygon attributes. Is that possible ?

2
  • It is possible, for sure, try some online demo and we can help somehow. You can fork a clean map and work on it. Commented May 29, 2015 at 11:18
  • Thanks for your answer Jonatas. For now I just wanted to know if that was possible and I would have been happy with a clue.
    – simo
    Commented May 29, 2015 at 12:21

1 Answer 1

1

Yes that's possible. With leafletjs you can use this Mapbox API: leaflet-pip

Once you have captured the users clicked coordinates you can use them like in the example linked above:

var userCoords = ????
var gjLayer = L.geoJson(statesData);
var results = leafletPip.pointInLayer(userCoords, gjLayer);

This will give you an array of polygons that contain that point, along with all the polygons attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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