Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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
up vote 3 down vote accepted

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) {
share|improve this answer
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 – Iliaka May 11 '12 at 16:34
I edited my question – Iliaka 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 – Iliaka May 11 '12 at 16:42
WMS is not vector layer and you cannot check intersection on client side. – drnextgis May 11 '12 at 16:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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