[OpenLayers-Users] Strange behaviour after panning

Christopher Schmidt crschmidt at metacarta.com
Wed Apr 9 20:44:07 EDT 2008

On Wed, Apr 09, 2008 at 08:51:32PM -0300, Pedro Simonetti Garcia wrote:
> 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?

The biggest reason is the same reason we maintain a difference between
getPixelFromLonLat and its underlying function call: in that case, we
(just today) changed the underlying method to not round numbers, but we
can change the API wrapper so that it continues to behave the same, with
no affect on existing applications. If, for example, we wanted to change
the library in the future so that getLonLatFromPixel could, as an
option, transform from the map projection to an actual lon/lat, we could
do this in tis function without affecting 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.

This performance cost is not important in the big sheme of things. A
single DOM reflow can be hundreds of times more expensive than a
function call. There is no real reason to change this from the way it
currently is. 

Christopher Schmidt

More information about the Users mailing list