Is it possible to have two popups in the map?

1832
6
12-29-2016 05:52 PM
RolandoFlorez
New Contributor III

Hi,
In my application I have several layers with respective popup, which I can (en/dis)able from layerList widget. But, at same time I can (en/dis)able other popup (in a widget apart) for basemap layer. Here is when I want to make this, have two popups, in case the user clicks the layer, would appear these popups.

6 Replies
RobertScheitlin__GISP
MVP Emeritus

The JS API only allows one popup at a time, it is a singleton class.

RolandoFlorez
New Contributor III

Robert,

Is there an alternative to this? or is necessary decide which is going to show?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Just to be sure. Are you wanting two popups on the map at the same time? If that is the case then no.

0 Kudos
RolandoFlorez
New Contributor III

Yeah, now I'm working in other alternative.
When I click the map, it will only appear a marker in the map (a graphic) and the information will be in the widget space.

But there is an inconvenience, if I enable the popups for other layers. So when I click the map, besides the marker, also appear the popup at same place. It's something like confusing. They mix.

Is there some relation between graphics and symbols? Why is happening this?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rolando,

   If this is some tool you are activating to add the marker to the map and then adding the info to the widget then you likely want to disable popups when your tool is chosen.

    disableWebMapPopup:function(){
      if(this.map){
        this.map.setInfoWindowOnClick(false);
      }
    },

    enableWebMapPopup:function(){
      if(this.map){
        this.map.setInfoWindowOnClick(true);
      }
    },
RolandoFlorez
New Contributor III

Robert,
That's not working like I want. Because, if I disable the infoWindow, the layer (that has enabled that popup) not listen that event. And the user will be confused.
So, is there some event listener to this? I want to know when the popup is enabled or disabled and when I disable that from checkbox widget the LayerList widget must know and the option 'disable popup' must change to 'enable popup' again like the begining.
Or also, when I enable a popup, the checkbox widget should change to disabled.

I think this problem can be solved by some of the above solutions.

Now I have this code:

if(this.map.infoWindow.isShowing){ //change to true if any popup is enabled
   this.checkedFunction(false); //change the widget appearance
   this.checkbox.set('checked', false); //uncheck checkbox
   this.map.graphics.clear(); //erase the marker
   this.map.setInfoWindowOnClick(false); //disable popup
   return;
}

What do you think? or What do you know about this?

0 Kudos