I have a dropdown list. On Selection, it will request extent of selected property to database (PostgreSQL). I am using PHP for server-side processing.
At client-side on console log gives extent output result (variable res
):
[74.3965356273929, 75.2484319931094, 35.6450698628058, 34.776235256942]
Also I am sure that coordinates are float and not string using parseFloat()
function. later I am passing that variable to OpenLayers.Bounds
.
var extent = new OpenLayers.Bounds(res);
map.zoomToExtent(extent);
OpenLayers.Bounds
gives following output:
OpenLayers.Bounds.OpenLayers.Class.initialize {left: 74.396535627393, bottom: 75.248431993109, right: 35.645069862806, top: 34.776235256942, left: null…}
Which is I guess correct. But Openlayers is not zooming to the provided extent and it is zooming to maximum zoom level at current map view only.
Best Answer
The order of attributes when you create an
OpenLayers.Bounds
object, you have to order the arguments like this: minx, miny, maxx, maxy.See the following example:
http://jsfiddle.net/KfkwV/2/