Select to view content in your preferred language

Editor widget

992
1
09-11-2012 07:36 AM
VIKRANTKRISHNA
Regular Contributor
Seems like editor digit (with toolbar) does not display the info window correctly, info window goes out of the map if you click on a feature  located in the upper, left or right portion of the map. It does not happen with attribute inspector though. Is there a way I can fix the position of the info window?
0 Kudos
1 Reply
JohnGravois
Deactivated User
its not exactly the same as forcing the infoWindow to utilize a different anchor, but I was able to pan the map to ensure that the entire infoWindow is displayed using the following code...

//set a global fixed anchor for the infoWindow when the application loads (initEditing might be a good place)
map.infoWindow.setFixedAnchor(esri.dijit.InfoWindow.ANCHOR_UPPERRIGHT);

//afterwards wire up the event handling to make sure the map will pan if the entire infoWindow isn't going to fit on the screen
dojo.connect(map.infoWindow, "onShow", function() {
   //Determine the upper right, and center, coordinates of the map
   var maxPoint = new esri.geometry.Point(map.extent.xmax, map.extent.ymax)
   var centerPoint = new esri.geometry.Point(map.extent.getCenter());

   //Convert these to screen coordinates
   var maxPointScreen = map.toScreen(maxPoint);
   var centerPointScreen = map.toScreen(centerPoint);

   //Subtract the size of the infoWindow, including a buffer.
   //This will show whether the infoWindow would spill out of the current view.
   var xDiff = Math.abs(maxPointScreen.x - map.infoWindow.coords.x) - 435;
   var yDiff = Math.abs(maxPointScreen.y - map.infoWindow.coords.y) - 285;

   //If required, recalculate a new centerpoint which accounts for the infoWindow
   if (xDiff < 0) {centerPointScreen.x -= xDiff;}
   if (yDiff < 0) {centerPointScreen.y += yDiff;}
   
   //Pan the map to the new centerpoint (in map coordinates)
   centerPoint = map.toMap(centerPointScreen);
   map.centerAt(centerPoint);
});
0 Kudos