traffordDataLab / leaflet.reachability

Plugin for the Leaflet JavaScript library to show areas of reachability based on time or distance for different modes of travel using the openrouteservice isochrones API.
MIT License
64 stars 7 forks source link

Polygons are overlapping each other #9

Closed webmap2015 closed 2 years ago

webmap2015 commented 2 years ago

Hi, There is a major problems. The polygons are overlapping each other. In this link; https://digital-geography.com/openrouteservice-api-a-leaflet-example-for-isochrones/ It creates a difference polygon by subtracting the smaller polygons from the bigger ones in a loop.

var difference=[];
for (i=0; i<(data.features.length-1); i++){
        difference.push(turf.difference(data.features[i+1],data.features[i]));
}
difference.push(data.features[0]);
data.features=difference;

Before access_poly1

After access_poly2

How can we add this to plugin? Thanks.

itsozz commented 2 years ago

Hi,

I don't think this is a major problem exactly, rather just a function of the Openrouteservice API returning one complete polygon for each reachability area. I have ensured that the smaller polygons are drawn last so that they are selectable and not hidden under larger ones etc. However I can understand that for certain cases, such as colouring/shading, that it's not desirable that they overlap. Your solution for creating difference polygons is very elegant!

I really appreciate your interest in this plugin and your suggestions for improvement. The only problem is that I don't have a lot of time to work on this unfortunately. It was developed to fulfil a specific requirement and then made available as we like to work openly. Development is still continuing (albeit very slowly due to more urgent requirements), however my current focus with it is to improve the accessibility. It might be better/faster for you to fork the repo and make the alterations you require as I cannot guarantee when I'm able to work on it. Sorry about this, and thanks again for your feedback.

webmap2015 commented 2 years ago

I made it.