[OpenLayers-Users] Going nuts: getDataExtent

Jan Martin janmartin3 at googlemail.com
Tue Jun 9 04:00:10 EDT 2009


Finally I got zooming -kind of - working.
But It works only on the LAST track added to the map.

When I take my test4 example and reverse the order of tracks, it zooms in on
the smaller, red one:

http://mybestprojects.com/data/test4/test4.html

However it should work on data of all tracks. Zooming in on the "largest".

Your thoughts please?

To Christopher:
I understood the 4 arguments of  'options' are optional, and set to "true"
by default?

Also I am not complaining at all about nothing.
And yes, there are "usage errors".
Mostly from copying code from various examples (on and offsite
openlayers.org), which seem to be out of date and/or not reflecting best
practise. It's called learning. Levels of skills are different after all.
Again, not complaining.

I intend to update a few of those examples once I got it together myself.

Thanks,
Jan


On Tue, Jun 9, 2009 at 12:12 AM, Christopher Schmidt <
crschmidt at metacarta.com> wrote:

> On Mon, Jun 08, 2009 at 11:52:27PM +0200, Jan Martin wrote:
> > Yes I did,
> >
> > it's as frustrating as all the examples at
> > http://openlayers.org/dev/examples
> >
> > All the lat, lon and zoom are always hardcoded. Not dynamic as I need it.
> > So not helpfull.
> >
> > Please find a screenshot of what I did using shell and perl scripts I
> wrote
> > today and gpsbabel:
> >
> > From thousands of lines like this:
> > 1244296533    1    8.664075    49.993945    172.012836
> >
> > to this:
> > http://mybestprojects.com/data/test3/Skytraq-Venus_6-GPS_tracks.png
> >
> > Nice eh?
> > Now how to make this zoom working?
>
>
>
> http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/GML-js.html#OpenLayers.Layer.GML.OpenLayers.Layer.GML
>
> Parameters
>  name    {String}
>  url {String} URL of a GML file.
>  options {Object} Hashtable of extra options to tag onto the layer.
>
> You have four arguments. As a result, your 'options' is a string --
> meaning that you haven't configured your GML layer to parse GPX. As a
> result, there are no features on your layer -- and therefore, nothing
> rawn, and nothing to zoom to.
>
>
> Additionally, you're using data in 4326 on a map in 900913, and haven't
> put in a projection option on your layer
> (
> http://docs.openlayers.org/library/spherical_mercator.html#reprojecting-vector-data),
> so this won't work until you do that as well.
>
> I appreciate that our documentation is imperfect. (Help welcome on that
> front.) However, complaining about that when you have clear usage errors
> is frustrating to people who might help you.
>
> (I will give you credit for following
> http://docs.openlayers.org/help/minimize.html#publishing-your-problem at
> least, since without that, there's no way we'd see the problem.)
>
> -- Chris
>
>
> > Jan
> >
> > On Mon, Jun 8, 2009 at 11:32 PM, Vivien Deparday
> > <vivien.deparday at gmail.com>wrote:
> >
> > > 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 <
> arnd.wippermann at web.de<mailto:
> > >> 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>
> > >>    [mailto: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 <mailto: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 <mailto: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 <mailto:Users at openlayers.org>
> > >>            http://openlayers.org/mailman/listinfo/users
> > >>
> > >>
> > >>
> > >>
> > >>
> ------------------------------------------------------------------------
> > >>
> > >> _______________________________________________
> > >> Users mailing list
> > >> Users at openlayers.org
> > >> http://openlayers.org/mailman/listinfo/users
> > >>
> > >>
> > >
> > >
>
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
>
>
> --
> Christopher Schmidt
> MetaCarta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090609/2bfe0e84/attachment.html


More information about the Users mailing list