I draw polygon vectors and I can find intersection to each other:


but I want to find which layer elements this polygon intersects.

How can I find it?


I have vector layer like this:

layerArray = new OpenLayers.Layer.WMS(wms_layer_configs[i].label, "http://somelink/geoserver/wms",
        // srs: 'EPSG:xxxx',
            layers: workspace + ":" + wms_layer_configs[i].name,
            tilesOrigin: map.maxExtent.left + ',' + map.maxExtent.bottom,
            format: 'image/png',
            transparent: true
        }, {
            opacity: 0.75,
            isBaseLayer: false,
            visibility: false

than I draw polygon and want to display on the map features from layer which intersects this drawn polygon

  • Hi @Iliaka, can you share the code that you used for fetching the layer elements that intersects with the Vector Polygon? – Sam007 Sep 17 '12 at 17:23

What you meant saying "layer elements"? If layer elements is features you can use the following approach:

result = []
testPolygon = vectorTest.features[0].geometry;
for (var i=1; i<vectorTest.features.length; i+=1) {
    if testPolygon.intersects(vectorTest.features[i].geometry) {
  • NO, intersection to each other is not problem for me. I have another layers where I have geom objects and I want to find intersection between this geom objects to the drawn polygon – Lazonaden May 11 '12 at 16:34
  • I edited my question – Lazonaden May 11 '12 at 16:40
  • Use needed layer inside for loop: for (var i=1; i<LAYERNAME.features.length; i+=1) – drnextgis May 11 '12 at 16:41
  • I tried but did not work, I'll try again now – Lazonaden May 11 '12 at 16:42
  • 3
    WMS is not vector layer and you cannot check intersection on client side. – drnextgis May 11 '12 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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