InfoWindoLite popup spilling off of map on mobile or small browser window

3258
4
07-02-2013 11:09 AM
MartynSmith
New Contributor
Hi there, looking for some assistance with the InfoWindowLite, perhaps also applies to regualar InfoWindow.  I'm using the InfoWindoLite for graphics popups on a mobile map I'm working on using API v3.5compact.  The problem is for features in the middle of the screen, when a graphic is clicked the popup spills off of the screen either to the left or the right. 

To reproduce this error you can pull up the InfoWindowLite sample, resize your browser window to be a bit wider than the popup, then click near center of the map.  Perhaps this is a bug because I'm assuming this popup is intended more for mobile use.

Is there a way to either:

a) move (pan) the map to center around the popup OR
b) not move (pan) the map and show the popup in the center of the screen disregarding the anchor graphic

Thanks for any help
0 Kudos
4 Replies
BrittneyGibbons
New Contributor III
This probably isn't the most elegant solution, but it worked okay for me. I wanted to show the infoWindow when a user performed a query by clicking a point on the map. The easiest way I found was to define a global variable (I used centerPoint) and set this equal to the evt geometry. Then I tapped into the infoWindow show event and used it to call for the map to recenter. This way worked the best for me because it reduced conflicts between the infoWindow show event and the map recentering which caused the infoWindow to display in the wrong location.

This was included in my function that executed on map click:
          centerPoint = new esri.geometry.Point(evt.mapPoint.x,evt.mapPoint.y,evt.mapPoint.spatialReference);

And this was included in my function that ran on initialization:
          dojo.connect(map.infoWindow, "onShow", function() {
             if (clickX == 1) {
                map.centerAt(centerPoint);
                clickX = 0;
             }
          });

I used clickX as a switch because I only wanted recentering to occur when a user clicked on a point (I also had the infoWindow show when users hover over a point), but you can probably take this part out if you want the map to recenter every time the infoWindow opens.

          dojo.connect(map.infoWindow, "onShow", function() {
                map.centerAt(centerPoint);
          });

Hope this is helpful!
0 Kudos
MartynSmith
New Contributor
I know the Javascript folks are probably at the UC this week, but I'm going to bump this anyway. 

Suggestions?
0 Kudos
MartynSmith
New Contributor
One more bump, any ideas?
0 Kudos
SteveCole
Frequent Contributor
You can try the code that Stephen Lead provides in this thread. I could not get it to work with my desktop application, however.

I did discuss this with one of the devs at the ESRI UC and the good news is that they recognize that this needs improvement, and they are working on it. The bad news is that I don't know the timeframe is for a fix. The APIs seem to be updated every 5-6 weeks so maybe in a few months? At least that's my hope. 😉
0 Kudos