[OpenLayers-Users] Going nuts: getDataExtent

Jan Martin janmartin3 at googlemail.com
Mon Jun 8 13:14:53 EDT 2009


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/5c8d12e6/attachment.html


More information about the Users mailing list