[OpenLayers-Users] How to calculate lat, lon, zoom dynamically from a (.gpx) track?

Jan Martin janmartin3 at googlemail.com
Sat Jun 6 15:10:12 EDT 2009


OK, I am answering this one myself:

In
http://wiki.openstreetmap.org/wiki/Openlayers_Track_example
right after
map.addLayer(lgpx);

one needs to add:
lgpx.events.register("loadend", lgpx, function() {
this.map.zoomToExtent(this.getDataExtent()) } );

That's all folks.

Jan

On Sat, Jun 6, 2009 at 8:45 PM, Jan Martin <janmartin3 at googlemail.com>wrote:

> Hi all,
>
> I am getting more and more frustrated.
>
> After checking out all the examples at http://openlayers.org/dev/examples/
> I noticed that in all examples the variables "lat", "lon" and "zoom" are
> hard-coded.
>
> However I'd like to load a .gpx file like here:
> http://wiki.openstreetmap.org/wiki/Openlayers_Track_example
>
> Then dynamically calculate the "lat", "lon" and "zoom" variables from the
> .gpx data, so the map will always just fit.
>
> I mean, websites like http://www.gpsvisualizer.com and
> http://utrack.crempa.net handle tracks this way, so why not openlayers?
>
> Thanks,
> Jan
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090606/a0fb4aa6/attachment.html


More information about the Users mailing list