What is the function to close a popup window?

8810
12
Jump to solution
03-29-2016 02:39 PM
NMWater
Regular Contributor

I have a popup that works perfectly fine. Whenever I switch layers though, the popup still hangs around along with its outline. How does one close it, say by clicking a button? I tried adding the function "map.infoWindow.hide();" to my code but that doesn't seem to be working. I set my infowindow in the map to popup. Any help would be greatly appreciated!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

NM Water,

  The maps infowindow by default is a popup dijit so you can use:

map.infoWindow.clearFeatures();

View solution in original post

0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus

NM Water,

  The maps infowindow by default is a popup dijit so you can use:

map.infoWindow.clearFeatures();

0 Kudos
NMWater
Regular Contributor

Hi Robert!

Thanks for your reply! Unfortunately, this isn't working: I get the following error.

" Uncaught TypeError: Cannot read property 'clearFeatures' of undefined"

I believe this might be an error of how my code is being placed? Have you ever experienced this before?

Thanks for all your help!

Francisco O

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Francisco,

Can you verify that you have access to map.infoWindow by using console.info(map.infoWindow);

0 Kudos
NMWater
Regular Contributor

Hi Robert,

Thanks for your response. I do indeed have access to the console.info: it gives the following result.

Here are some snipps of my code.

I think it might be an issue of how I'm placing my code.

0 Kudos
KristianEkenes
Esri Regular Contributor

Do you have a link or jsbin you can share that shows your issue?

FYI, in the 4.0 API you will be able to do view.popup.close() to accomplish this.

0 Kudos
NMWater
Regular Contributor

I don't have a link working yet. But I attached some snipps in the previous reply.

Thanks for all your help!!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

NM Water,

  Did you put the console statement in the closepopup function, to ensure you have access to the map.infoWindow inside that function

0 Kudos
NMWater
Regular Contributor

Hi Robert,

After some more careful look at my code, I got it to work. However, would there be a way to completely close the popup?

This is what I get with map.infoWindow.clearFeatures();

Before:

After:

Thanks for all your help Robert!!

Francisco

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Francisco,

  Sure use map.infoWidow.hide();