Any way to hide an infoWindow on a mouse click?

3281
16
Jump to solution
05-13-2012 08:21 AM
JayGregory
New Contributor III
Was curious if anyone's found a way to hide an infoWindow when a user clicks outside the infoWindow (instead of having to click the "x" or click on another map graphic which displays another infoWindow. 
I tried setting a dojo.connect event handlers like dojo.connect(map, "onClick", map.infoWindow.hide()); but that doesn't seem to work. 

Thanks!

Jay
0 Kudos
16 Replies
DavidTreering
New Contributor II
Still not working.  Is a polygon tiled layer used as a basemap considered a graphic?  Or only the dynamic feature layer?
0 Kudos
StephenLead
Regular Contributor III
Is a polygon tiled layer used as a basemap considered a graphic?  Or only the dynamic feature layer?


Hi David,

No, a tiled or dynamic layer isn't considered a graphic. A feature layer is, as is a graphics layer, or a single graphic.

Can you post your whole code, or a link to your site?

Cheers,
Steve
0 Kudos
DavidTreering
New Contributor II
Steve, Here's my code...this is a work in progress.  Not everything works.  Please let me know if my services are coming through alright or if you cannot see them load.
Thanks,
David
0 Kudos
DavidTreering
New Contributor II
I'll also want to hide the infoWindow if scale changes beyond the visible scale range for the layer.   Hmmmm.
I appreciate your time, and any ideas would be a great help.
0 Kudos
DavidTreering
New Contributor II
I've tried opening it up.  Can you try again?
0 Kudos
StephenLead
Regular Contributor III
Hi David,

I think the map's onClick handler isn't being initiated because it's not sitting inside a function. Try moving that listener immediately underneath the map declaration (eg around line 368).


I'll also want to hide the infoWindow if scale changes beyond the visible scale range for the layer



This is a bit trickier since the API doesn't directly tell you whether a layer is "on but outside its scale range". See the post here for some pointers you may be able to use.

You may need to hard-code something in your code, then check the current scale range on each zoom change.

Good luck,
Steve
0 Kudos
DavidTreering
New Contributor II
Try moving that listener immediately underneath the map declaration


That worked, thanks!

I'll try to
hard-code something in your code, then check the current scale range on each zoom change
, and post what I do.  I'll probably choose to store variables rather than send a query every onZoomChange.
0 Kudos