I wonder if someone here have a JavaScript function that when I draw a polygon I can see if I am drawing on another polygon?

like intersect... if polygon intersect say to me a alert...

using OpenLayers.

1 Answer 1


You can have a look at the intersection example of OpenLayers: http://dev.openlayers.org/examples/intersects.html

for(var i=0; i<features.length-1; ++i) 
    feat1 = features[i];
    for(var j=i+1; j<features.length; ++j) 
        feat2 = features[j];
        intersects12 = feat1.geometry.intersects(feat2.geometry);

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.