[OpenLayers-Users] openlayer markers located at the wrong place

maven apache apachemaven0 at gmail.com
Fri May 31 05:09:10 PDT 2013


Mario Danelli:

It worked, thanks!. This is what I did:

*OpenLayers.Marker.prototype.setPosition = function(lonlat) {
    if (this.map)

this.moveTo(this.map.getLayerPxFromViewPortPx(this.map.getPixelFromLonLat(lonlat)));
};*


2013/5/31 Mario Danelli <mario.danelli at gmail.com>

> Dear Maven,
>
> > `OpenLayers.Marker` have no native support methods like `setPosition()`
> > or something else to update its position.
> >
> > Since in my opinion, destroy-create-destroy.. will be a performance
> consuming problem, that is why I keep one object of  `Marker` to reuse it.
> >
>
> I found a solution.
>
> It seems the problem isn't in the "moveTo" function but what is passed to
> it.
>
> I just tried the following new "updateMarker" version and it works as
> expected.
>
> ----------------> BEGIN
>
> function updateMaker(myMarkerIn, pos) {
>
> myMarkerIn.moveTo(map.getLayerPxFromViewPortPx(map.getPixelFromLonLat(pos)));
> }
>
> <---------------- END
>
> Regards
>
> Mario Danelli
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130531/5cd3b4b6/attachment.html>


More information about the Users mailing list