Edit mode allows intersection even when polygon: {allowIntersection: false} #131

stuporglue opened this Issue Apr 24, 2013 · 9 comments


None yet
8 participants

I have specified
polygon: { allowIntersection: false }
in my constructor.

For creating new features this is respected correctly.

When editing existing features intersections are allowed. It seems that edit mode should respect the allowIntersection parameter.


jacobtoye commented Apr 25, 2013

Ah yes, currently edit doesn't support this functionality :( The code subsides in Draw.Polyline.js, Need to update Edit.Polyline to support allowIntersection as well.

@jduhls jduhls referenced this issue in Turfjs/turf Feb 28, 2014


polygons that intersect themselves #92

jduhls commented Mar 8, 2014

I would also like to see this fixed. It is currently limiting my ability to use turf.js (morganherlocker/turf#92)

josephj commented Sep 11, 2014

I am trying to add this feature. I created an dragEnd event to check if it's intersected. If it is, then restoring the dragged marker back to previous position, also redrawing the polylines.

It's almost done. However, when I drag next or previous markers to trigger intersection, the restored polygon would lack of several points.

Anyone possibly to give me a hint?

    _onMarkerDragEnd: function (e) {

        // Allow intersection, stop here
        if (this.options.allowIntersection) {

        var marker = e.target,
            intersects = false,
            polyLatLngs = this._poly.getLatLngs(),
            latlngs = [],

        for (i in polyLatLngs) {
            if (polyLatLngs.hasOwnProperty(i)) {
                polyLatLng = polyLatLngs[i];
                if (this._poly.newLatLngIntersects(polyLatLng, true)) {
                    intersects = true;
                    polyLatLng = new L.LatLng(marker._srcLatLng.lat, marker._srcLatLng.lng);

        // No intersection, stop here
        if (!intersects) {

        // Reset this point in Polygon points array.

        // Reset related markers

josephj commented Sep 14, 2014

I think it's all good now. The only thing left is I don't know how to make the allowIntersection:false option working when it instantiates.

Hi @josephj! Is your solution already working?

josephj commented Oct 16, 2014

@linyatis I still don't know how to make this option being configurable, but the feature works pretty good. You can check my commit. josephj/Leaflet.draw@9425d3b

Any news on this? I need this thingy configurable... don't know how to do it, either. ((


I am using leaflet 1.0.3 version and leaflet draw 2.0.4 vrsion. the allowIntersection parameter is not working while creating a region.
currentDrawingRegion = new L.Draw.Rectangle(mapInstance, {
title: 'Draw a polygon!',
allowIntersection: false,
drawError: {
color: '#b00b00',
timeout: 2000
shapeOptions: {
// color: '#64b900',
color: '#fff',
weight: 1.5,
opacity: 0.2,
fillOpacity: 0.1,
fill: false
showArea: true

Please help me out .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment