Wednesday 21 November 2018

In OpenLayers zoom to extent of all overlays


In Openlayers I can zoom to the bounding box of all layers like this:


map.zoomToExtent();

I can also zoom to the bounding box of a single layer:


map.zoomToExtent(layer_name.getDataExtent());

Is there an easy way of zooming to the extent of all layers except the base layer? In other words showing the extent of all overlays.



Answer





  1. for-loop over all of your layers

    1. Skip the base layer [per your requirement]

    2. Use bounds.extend(...) to build the all-encompassing bounds object API



  2. Zoom to the resulting bounds API


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...