Select to view content in your preferred language

InfoWindows in JS API 3.x

1243
3
Jump to solution
09-16-2020 11:05 AM
NathanHeickLACSD
Frequent Contributor

How do InfoWindows get updated?  If I create a custom InfoWindow class, create a new instance, and set it as the InfoWindow of a map, is it responsible for updating its own content or does the map somehow do that?  I want to write a custom Popup class, but I don't know if something else will overwrite my changes anytime I try to set the content of the popup.  Does anyone have a diagram about the events, methods, and process that takes a map click and ultimately turns it into an updated InfoWindow?

Thanks,
Nathan

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Nathan,

  I will attempt to explain the process.

If the map has a layer with popup defined then the map will attach event listeners to the the map and fire off a query to the layers service to see if the map click has a feature or features that intersect the click point. If there are intersected features then the map sends the popup dijit (InfoWindow: Default value is an instance of a Popup) set features method the results of the query. The popup looks to see if there is an PopupTemplate defined for that feature and then formats the popup content based on that template.

If there is more than one layer that have popups defined or more then one feature of a layer that intersects the map click the the popup will have all the features sent to its features property and then show the pagination controls.

FYI: After version 3.4 the Popup is the default, so don't look down the road of InfoWindow class. 

Hope this helps.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Nathan,

  I will attempt to explain the process.

If the map has a layer with popup defined then the map will attach event listeners to the the map and fire off a query to the layers service to see if the map click has a feature or features that intersect the click point. If there are intersected features then the map sends the popup dijit (InfoWindow: Default value is an instance of a Popup) set features method the results of the query. The popup looks to see if there is an PopupTemplate defined for that feature and then formats the popup content based on that template.

If there is more than one layer that have popups defined or more then one feature of a layer that intersects the map click the the popup will have all the features sent to its features property and then show the pagination controls.

FYI: After version 3.4 the Popup is the default, so don't look down the road of InfoWindow class. 

Hope this helps.

NathanHeickLACSD
Frequent Contributor

That was really helpful.  The map identifies which features were clicked and sets the features on the popup.  Then, the popup updates itself accordingly.  I kept seeing the method setContent and thought the map was doing all the work.  Is the popup then like a whiteboard that is constantly being erased and rewritten on?  If you use setContent anywhere in your code to load arbitrary HTML into the popup, would that then be replaced after the next map click or other event updates it?  I'd like to determine if we can add tabs to our popups and populate some of the tabs with tables of related records.  I just wanted to figure out where I could insert the logic to query the related records and build the tables.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yes, like a whiteboard.

I have not personally added tab to a popup but it should be possible as you can pretty much add anything to the popups content.

0 Kudos