[OpenLayers-Dev] popup moveto problems

Vito Tafuni vitotafuni at gmail.com
Tue Jun 22 12:37:09 EDT 2010


anyone interested in the solution of this problem:
moveTo use layerPx info instead of ViewPortPx so

  pos = map.getLayerPxFromViewPortPx(map.getViewPortPxFromLonLat(pos));

solved the problem!


-Vito-



--
-----------
Tafuni Vito
vito at vitotafuni.com
---------------------------------------------
"Verba volant, scripta manent... data corrupted"


2010/6/21 Vito Tafuni <vitotafuni at gmail.com>

> i'm playing with the drag control and i would like to display the feature
> position while dragging
>
> onDrag: function(feature, pixel){
>
>                     var pos =
> feature.geometry.getBounds().getCenterLonLat();
>
>                     if(!feature.coordPopup){
>                         var coordPopup = new
> OpenLayers.Popup.Anchored("coords",pos,null,"", {
>                             offset: new OpenLayers.Pixel(0,20),
>                             size: new OpenLayers.Size(0,0)
>                         });
>                            coordPopup.calculateRelativePosition =
> function(){return "tr";}
>
>                            feature.coordPopup = coordPopup;
>                         map.addPopup(feature.coordPopup);
>                     };
>
>
>                     pos = map.getViewPortPxFromLonLat(pos);
>                     feature.coordPopup.setContentHTML(pos);
>                     feature.coordPopup.updateSize();
>
>
>                     feature.coordPopup.moveTo(pos);
>                 },
>                 upFeature: function(pixel){
>                            map.removePopup(this.feature.coordPopup);
>                         this.feature.coordPopup.destroy();
>                         this.feature.coordPopup = null;
>                 }
>
> everything is ok
> popup moves as the feature is dragged and shows the current position
> BUT when i pan the map the popup is drawn at different position even if the
> viewportpx is the same
>
> for example
> before pan: popup at 100,100
> after pan: same position (popup display 100,100) but popup is drawn at
> 150,70
>
> what i'm doing wrong??
>
>
> Vito
>
>
>
>
>
> --
> -----------
> Tafuni Vito
> vito at vitotafuni.com
> ---------------------------------------------
> "Verba volant, scripta manent... data corrupted"
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20100622/091a1871/attachment.html


More information about the Dev mailing list