[OpenLayers-Users] Strange behaviour after panning
Pedro Simonetti Garcia
pedrosimonetti at gmail.com
Wed Apr 9 19:51:32 EDT 2008
>
> >
> > After some investigations, I found how to fix it.
> >
> > I've changed the piece of the code where it calculates the coordinates,
> > from:
> >
> > var lonlat = map.getLonLatFromLayerPx(evt.xy);
> >
> > To:
> >
> > var lonlat = map.getLonLatFromViewPortPx(evt.xy);
> >
> > Now it works fine.
> >
> > I'm just wondering, what's the difference of "getLonLatFromLayerPx", and
> > "getLonLatFromViewPortPx"? I've looked at the docs but I still don't get
> it.
> > At first glance, I thought that these methods were similars.
>
> The answer is actually: "THey're the same insofar as you shouldn't need
> to use either one of them" :)
Thanks! I knew I was missing something! =)
Both of these are really designed to be internal methods: I've just
> changed their definition from APIMethod to Method. The one you *shoul*
> be using is the more nicely named getLonLatFromPixel: this hides the
> fact that you have to worry about any of this stuff.
Good. I think this will help other users looking for some info about this in
the documentation.
In any case: We providedd getLonLatFromPixel as the main 'API' property
> so that people wouldn't have to use a funky-named property: it's a
> wrapper around getLonLatFromViewPortPx.
>
Just a suggestion. Considering that the "getLonLatFromPixel " is a
wrapper around "getLonLatFromViewPortPx", why not renaming it as
"getLonLatFromPixel", and use this in the rest of the library?
As JavaScript is a interpreted language, all function calls has a cost,
and because of this, is not recommended to use wrappers and getters
since they will just call another function, with a higher performance cost.
But, of course, changing this will require a refactoring and many files,
so one have to analyze well the benefits of making such a change,
before starting the refactoring.
Thanks for the helpfull answer!
my best regards,
Pedro Simonetti.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080409/a07aca58/attachment.html
More information about the Users
mailing list