user3052526
user3052526

Reputation: 681

Openlayers zoomToExtent

I am using openlayers to draw some boundaries based on a list of lon and lat using the following code

        var style = OpenLayers.Util.applyDefaults({
            label:areaName, 
            fontColor: "black",
            fontSize: "15px",
            fontFamily: "Arial",
            fontWeight: "bold",
            labelOutlineColor: randomColor(),
            labelOutlineWidth: 1,
            labelAlign:"lt",
            xOffset:-20,
            yOffset:-20,
            fillColor: randomColor(),
            strokeColor : randomColor()
        },OpenLayers.Feature.Vector.style['select']);

        var polygonFeature = new EMS.Feature.Vector(response.geometry, {}, style);

        vectorLayer.addFeatures([polygonFeature]);

All is working great and i get back the boundingBox which is an object that when i call into zoomToExtent and pass it zooms to the area around that region.

My problem is: If i have more than 2 boundingBoxes how do i calculate the region to zoomToExtent to.

Hope i am clear enough

Upvotes: 0

Views: 253

Answers (1)

user3052526
user3052526

Reputation: 681

And i found it

map.zoomToExtent(vectorLayer.getDataExtent());

Upvotes: 3

Related Questions