[OpenLayers-Users] Adjusting Zoom Level Based on Points
BalaVignesh Kasinathan
kbalavignesh at gmail.com
Thu Nov 10 11:52:36 EST 2011
Hi,
I got solution based on Tac & Sveen reply. I have selected min and max
values of x & y from all points. And i set that as extent like follow,
map.zoomToExtent(new OpenLayers.Bounds(minx,miny,maxx,maxy))
Thanks for the Solution.
Regards,
Bala
On Tue, Nov 8, 2011 at 7:35 PM, Sveen Atle Frenvik (Geomatikk IKT) <
Atle.Frenvik.Sveen at geomatikk.no> wrote:
> **
> I guess something along these lines should do the trick (not tested)
>
>
> //create map etc..
>
>
> var vectorLayer = new OpenLayers.Layer.Vector("vectors");
> map.addLayer(vectorLayer);
>
> var draw = new
> OpenLayers.Control.DrawFeature(vectorLayer,OpenLayers.Handler.Path);
>
> map.addControl(draw);
>
>
> draw.events.register("featureadded",this,function(feature){map.zoomToExtent(feature.geometry.getBounds());});
>
>
>
>
>
> On 2011-11-08 14:55, Imran Rajjad wrote:
>
> if the points are in your vector layer, you can get the extent of that
> layer and set zoom accordingly
>
> On Tue, Nov 8, 2011 at 4:48 PM, Tac Tacelosky <tacman at gmail.com> wrote:
>
>> As you're going through the points, keep track of the min/max x and y,
>> then use those values to set the extent (the boundaries).
>>
>> While you can do this in Javascript, we ended up doing that calculation
>> in the server-side call that got the points, and sending it over with the
>> json that used to populate the array of points.
>>
>> Tac
>>
>> On Tue, Nov 8, 2011 at 8:30 AM, BalaVignesh Kasinathan <
>> kbalavignesh at gmail.com> wrote:
>>
>>> Hi,
>>> I want to draw the line (route using x,y coordinate points) over
>>> the map as vector layer. After route drawn on map, i want to adjust the
>>> zoom level to show the complete route. How can i do this? Is there any
>>> direct way to do this? If not how to do using math calculations?
>>>
>>> Regards,
>>> Bala
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>
>>
>
>
> --
> I.R
>
>
> _______________________________________________
> Users mailing listUsers at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
>
> --
> Atle Frenvik Sveen
> Utvikler
> Geomatikk IKT AS
> tlf: 45 27 86 89atle.frenvik.sveen at geomatikk.no
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111110/0f730cad/attachment.html
More information about the Users
mailing list