I want to automate and test some aspects of my map application in OpenLayers 3. I mainly want to automate clicking on markers and other vector features(ideally through the DOM using XPath like SVG). In OpenLayers 3 right now, this is almost impossible to do, since the vector features are not present in DOM due to the canvas. I can visually see them of course.

I tried doing this in Leaflet while using the SVG renderer for vectors and selenium web driver, and it was a piece of cake.

Is there any way to automate the canvas based vector layers right now?

Also would it be possible to render vector features in SVG instead of canvas in the future for OL3? (like it used to be in OL2)


There are no plans to create a SVG vector renderer for OpenLayers 3. If you want to programmatically get the features at a click location, you can use ol.Map#forEachFeatureAtPixel(). See http://openlayers.org/en/v3.3.0/apidoc/ol.Map.html#forEachFeatureAtPixel.

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.