Tuesday, 21 August 2018

Openlayers 3 - Zoom to Selected Feature (Polygon)


I have an ol.source.ServerVector with several polygons drawn as features. I'd like for the map to zoom to the extent of the selected polygon upon selection, but I'm hitting a wall.


I was able to find this post that helped with zooming to all of the features in the source, but not the selected feature specifically


https://stackoverflow.com/questions/23682286/zoomtoextent-openlayers-3


var extent = source.getExtent();
map.getView().fitExtent(extent,map.getSize());

That works great to zoom to all of my polygons, but I can't seem to find any way to only use the selected feature's extent.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...