Select to view content in your preferred language

more infoWindow fun

616
2
11-01-2010 07:23 AM
timgogl
Deactivated User
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 ?
0 Kudos
2 Replies
timgogl
Deactivated User
i guess i need to spend more time working on solutions before posting here......

heh, but typing this stuff out seems to help me come up with the answer.

so, incase anyone else runs into something similar, and searches for an answer, here is what i have:

       var newPoint = esri.geometry.toScreenGeometry(map.extent,map.width,map.height,mousePoint);


were mousePoint is the point i calculate from the extent of my points / polys.
0 Kudos
TimRourke
Emerging Contributor
This will also work:

var screenPoint = map.toScreen(mapPoint);
0 Kudos