Did you have a look at this: http://wiki.openstreetmap.org/wiki/Openlayers_Track_example
Cheers, Vivien Jan Martin wrote: > Hi Arndt, > > OK, I should have told that the code is borrowed from > http://oms.wff.ch/ol_track.htm and http://nuug.no/kart.shtml > > So I cleaned up the file and also got rid of GPX.js as well as Ajax.js. > Still doesn't work. No zoom, not even a track anymore. > Firebug reports: bounds is null > > Check it out: > http://mybestprojects.com/data/test3/tracks_layers.html > > Thanks, > Jan > > On Mon, Jun 8, 2009 at 9:21 PM, Arnd Wippermann > <[email protected] <mailto:[email protected]>> wrote: > > Hi Jan, > > It seems, that your code GPX.js (OpenLayers.Layer.GPX) miss > something like > > this.events.triggerEvent("loadend"); > you should have mentioned, that you use own code for > OpenLayers.Layer.GPX. > > Arnd > > ------------------------------------------------------------------------ > *Von:* [email protected] > <mailto:[email protected]> > [mailto:[email protected] > <mailto:[email protected]>] *Im Auftrag von *Jan Martin > *Gesendet:* Montag, 8. Juni 2009 19:15 > *An:* Vivien Deparday > *Cc:* [email protected] <mailto:[email protected]> > *Betreff:* Re: [OpenLayers-Users] Going nuts: getDataExtent > > Hi Vivien, > hi all, > > unfortunately it did not work. > > Changed file here: > http://mybestprojects.com/data/test2/tracks_layers.html > > I also would prefer the "try to register the same function but > before adding the layer" method, and NOT "within the constructor". > > Thanks, > Jan > > On Mon, Jun 8, 2009 at 5:47 PM, Vivien Deparday > <[email protected] <mailto:[email protected]>> wrote: > > I think it's because you register your function on the event > loadend but the layer is already added and the event loadend > has already been fired. So, try to register the same function > but before adding the layer. You can even do it within the > constructor with the option eventListeners. I guess it would > look like something like this but I'm not sure as I never used > the gpx format. > > var lgpx = new OpenLayers.Layer.GPX("20090606175533.gpx", > "separated/20090606175533.gpx", "#FF0000",{eventListeners: > {'loadend': function(){this.zoomToExtent(lgpx.getDataExtent()) > }}}); > > Let me know if it helps. > > Vivien Deparday > > Jan Martin wrote: > > Hi all, > > I am going nuts over not beeing able to figure out how to > make getDataExtent work for me. > > This is my page NOT working yet: > http://mybestprojects.com/data/test/tracks_layers.html > > I try to model after > http://oms.wff.ch/ol_track.htm (tracks work fine, just > zoom in on the red point manually.) > and > http://nuug.no/kart.shtml (automatic zoom by getDataExtent > not working for me.) > > Code in question might be: > if( ! map.getCenter() ){ > lgpx.events.register('loadend', map, > function(){this.zoomToExtent(lgpx.getDataExtent())}); > map.setCenter(null, null); > > > } > or check out whole page source at > http://mybestprojects.com/data/test/tracks_layers.html > > What's wrong? > > Thanks, > Jan > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > [email protected] <mailto:[email protected]> > http://openlayers.org/mailman/listinfo/users > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
