Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if polygons overlap in leaflet

I am using leaflet draw to create polygons. My requirement is when a user draws a polygon ,it should not intersect/overlap with existing polygons. I have used point in polygon leaflet to detect if point falls within the polygon and it is working, but the problem is i am not able to detect if a line crosses another polygons.In this case points lie outside the existing polygons but overlapping exists.

Below attached image can give a better picture!Polygons overlap in this

like image 850
user1533947 Avatar asked Sep 18 '14 04:09

user1533947


1 Answers

You can also probably use Turf.js. Turf is a new js GIS engine developed by the guys at Mapbox.

Here are few examples that may do the job:

  • Turf Intersects
  • Turf Overlaps
like image 150
kmandov Avatar answered Oct 06 '22 00:10

kmandov