lowgas

more infoWindow fun

Discussion created by lowgas on Nov 1, 2010
Latest reply on Nov 2, 2010 by tjrourke
ok, this should be easy, but it is beating me as i speak.

i have a variable mousePoint that i want to set, i will use this variable to show an infoWindow.

if i use the following code: i get the infowindow,

          mousePoint = e.screenPoint;
                        var centerPoint;
   var xtnt;
   var isPoint = (infoFeatures.geometry.type == 'point');
   
   if(isPoint){
    centerPoint = infoFeatures.geometry;
   }else{
    xtnt = infoFeatures.geometry.getExtent();
    centerPoint = xtnt.getCenter();
   }
  
   map.centerAndZoom(centerPoint,17);//be nice to have this number dynamically scale to the size of the symbol.
   mapIsZoomedIn = true;


however when the map centers and zooms, the mousepoint of course does not center with the map, so the info window shows up in the wrong spot.

if i use this code i dont get an info window at all. and firebug shows NO errors.

   var centerPoint;
   var xtnt;
   var isPoint = (infoFeatures.geometry.type == 'point');
   
   if(isPoint){
    centerPoint = infoFeatures.geometry;
   }else{
    xtnt = infoFeatures.geometry.getExtent();
    centerPoint = xtnt.getCenter();
   }
   mousePoint = centerPoint;
   map.centerAndZoom(centerPoint,17);//be nice to have this number dynamically scale to the size of the symbol.
   mapIsZoomedIn = true;


i am assuming in the second case, infowindow does not like mousepoint because mousepoint is not a screenpoint, but a mappoint ( i think). if this is in fact the case, how do i find the 'screenpoint' for the centerpoint? is it as simple as dividing height /2 and width / 2 ?

Outcomes