[OpenLayers-Users] Going nuts: getDataExtent
Jan Martin
janmartin3 at googlemail.com
Mon Jun 8 17:17:04 EDT 2009
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 <arnd.wippermann at web.de>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:* users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
> *Im Auftrag von *Jan Martin
> *Gesendet:* Montag, 8. Juni 2009 19:15
> *An:* Vivien Deparday
> *Cc:* users at openlayers.org
> *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 <vivien.deparday at gmail.com
> > 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
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090608/152376dd/attachment.html
More information about the Users
mailing list