Moving infoWindow

1466
6
Jump to solution
05-23-2013 10:22 AM
JohnBradley
New Contributor II
I am having an issue with an infoWindow in an application where if the infoWindow is displayed and the map is panned the next identify function's infoWindow is positioned at the screen point of the previous indentify point.

The specific behavior is repeatable as follows:
- map loads normally, zoom to the extent desired with what any means
- click on a point to identify results, the identify data is dynamically loaded into the infoWindow with setContent, title is also added
- the infoWindow is displayed with a line of code:
locmap.infoWindow.show(idLocPoint.mapPoint, locmap.getInfoWindowAnchor(idLocPoint.screenPoint));


The first time the map is loaded clicking on any point will produce the expected results: infoWindow is displayed at one of now eight positions (used to be four) with a leader. Also, naviagting the map does not effect expected performance: zooming and panning then clicking on a point all result in viewing the infoWindow at the correct point if the user closes the infoWindow before navigating the map.

If an infoWindow is left open and the map is navigated then the problem starts. So teh steps to repeat are then same as above with an added step to navigate the map.  Panning the map with the infoWindow open moves correctly but identifying another point displays the infoWindow 1st in the correct position as a blink, then infoWindow is moved back to screen position it was at for the previous identify position (appears to jump to previous spot).

What I have tried:
- locmap.reposition(); - did not change the behavior
- locmap.infoWindow.show(idLocPoint.screenPoint); - does not change position
- adding the screen coords and map coords to show new position of identify object and I can see the correct numbers but the behavior did not change.
- adding a function to alert the coords onShow event for infoWindow also shows correct screen and map coords but object is still moved (after onShow event is completed)
- infoWindow.destroy() - kills and future infoWindows from being displayed
- locmap.infoWindow.show(); - always shows infoWindow in upper left corner of map, never moves

Finally, I tried setting a delay in the display of the infoWindow and that did fix the results:
setTimeout(function () { locmap.infoWindow.show(idLocPoint.mapPoint, locmap.getInfoWindowAnchor(idLocPoint.screenPoint)); }, 400);


BUT I do NOT want to keep the delay in there.  Has anyone else ever seen this behavior and if so are there any of remedies I can try? 

Thanks for reading ...
0 Kudos
1 Solution

Accepted Solutions
JohnBradley
New Contributor II
It turns out that there is s a3 step process - I am sure that most app have this:
1. Attach the event
2. handle the map click event
3. process the results

In the process results I was verifying the map extent to make sure the the mobile device map display matched because we had an issue with the touch events firing the extent change event unexpectedly.  When I removed the extra setExtent command the infoWindow started behaving normally. Self inflicted wound.

Thanks.

View solution in original post

0 Kudos
6 Replies
ChristopherBlinn1
Occasional Contributor III
John,

If you read my last post, sorry, I've been working with Google all day and that is where my brain is.

Have you tried to .move(point) the infoWindow to the new location?

Best,
Chris B.
0 Kudos
JohnBradley
New Contributor II
I have tried the move, after the show and in the onShow event.  I can see it blink but unless I use the timer it still ends up in the previous position.

Another strange thing is I can't find anywhere that the previous position is being cached.  I tried using firebug to watch the local function variable to see if it is correct and it is always the new information. Seems like the infoWindow itself is storing it?
0 Kudos
VinayBansal
Occasional Contributor II
HI,

Have you tried by clearing the contents and hiding the infowindow and then showing it..

map.infoWindow.setTitle("");
map.infoWindow.setContent("");
map.infoWindow.hide();
map.infoWindow.setTitle("Identify");
map.infoWindow.setContent("test");
map.infoWindow.show(mapPoint, map.getInfoWindowAnchor(screenPoint));
0 Kudos
ChristopherBlinn1
Occasional Contributor III
John,

Would you mind sharing a bit more of your code?

It is very difficult to assume what may be the cause without seeing a bit more of the script.

Specifically where you set all of the objects for the infoWindow, and also the click event which fires the new infoWindow.

Thanks,

Chris B.
0 Kudos
JohnBradley
New Contributor II
I would not mind sharing the code, but it is a big app where the info window is a small part.  I am pulling the pieces into smaller files and refactoring so I can try to isolate the problem.

Thanks for you reply, I will have something shortly.
0 Kudos
JohnBradley
New Contributor II
It turns out that there is s a3 step process - I am sure that most app have this:
1. Attach the event
2. handle the map click event
3. process the results

In the process results I was verifying the map extent to make sure the the mobile device map display matched because we had an issue with the touch events firing the extent change event unexpectedly.  When I removed the extra setExtent command the infoWindow started behaving normally. Self inflicted wound.

Thanks.
0 Kudos