Hi Vivien,<br>hi all,<br><br>unfortunately it did not work.<br><br>Changed file here:<br><a href="http://mybestprojects.com/data/test2/tracks_layers.html">http://mybestprojects.com/data/test2/tracks_layers.html</a><br><br>
I also would prefer the "try to register the same function but before adding the layer" method, and NOT "within the constructor".<br><br>Thanks,<br>Jan<br><br><div class="gmail_quote">On Mon, Jun 8, 2009 at 5:47 PM, Vivien Deparday <span dir="ltr"><<a href="mailto:vivien.deparday@gmail.com">vivien.deparday@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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.<br>
<br>
var lgpx = new OpenLayers.Layer.GPX("20090606175533.gpx", "separated/20090606175533.gpx", "#FF0000",{eventListeners: {'loadend': function(){this.zoomToExtent(lgpx.getDataExtent()) }}});<br>
<br>
Let me know if it helps.<br>
<br>
Vivien Deparday<br>
<br>
Jan Martin wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
Hi all,<br>
<br>
I am going nuts over not beeing able to figure out how to make getDataExtent work for me.<br>
<br>
This is my page NOT working yet:<br>
<a href="http://mybestprojects.com/data/test/tracks_layers.html" target="_blank">http://mybestprojects.com/data/test/tracks_layers.html</a><br>
<br>
I try to model after<br>
<a href="http://oms.wff.ch/ol_track.htm" target="_blank">http://oms.wff.ch/ol_track.htm</a> (tracks work fine, just zoom in on the red point manually.)<br>
and<br>
<a href="http://nuug.no/kart.shtml" target="_blank">http://nuug.no/kart.shtml</a> (automatic zoom by getDataExtent not working for me.)<br>
<br>
Code in question might be:<br>
if( ! map.getCenter() ){<br>
lgpx.events.register('loadend', map, function(){this.zoomToExtent(lgpx.getDataExtent())});<br>
map.setCenter(null, null);<br>
<br>
<br>
}<br>
or check out whole page source at <a href="http://mybestprojects.com/data/test/tracks_layers.html" target="_blank">http://mybestprojects.com/data/test/tracks_layers.html</a><br>
<br>
What's wrong?<br>
<br>
Thanks,<br>
Jan<br>
<br>
<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<br>
</blockquote>
<br>
</blockquote></div><br>