Map does not pan over to show infowindow...

739
1
05-23-2012 08:44 AM
GISAdmin1
New Contributor III
When a map div is narrow, and you click on a feature to show an infowindow, the map does not pan over to display the full infowindow.  Instead, the infowindow gets cut off and the user cannot close it without panning the map (see attached image).  Any ideas how I can solve this issue?

You can replicate the issue using this sample:

http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_infowindow.html
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_infowindow.html

Thanks in advance,

Mark
0 Kudos
1 Reply
GISAdmin1
New Contributor III
This little hack works like a charm:


var screenPt = evt.screenPoint;
var mapPt = map.toMap(screenPt);

if (Math.abs(screenPt.x - 335) < 55) {
 if(screenPt.x < 335) {
    screenPt.x = 270;
 } else {
       screenPt.x = 400;
 }
}

var mapPtNew = map.toMap(screenPt);
shiftX = mapPt.x - mapPtNew.x;
map.setExtent(map.extent.offset(shiftX, 0));
0 Kudos