Add features to the infoWindow from feature service that are not in the map

825
3
Jump to solution
03-12-2018 10:08 AM
mileshitchen1
New Contributor II

Hi,

Some background:

I have a Web App built using the Developer Edition of WAB, and have customized it slightly (using Dojo inheritance), so all my customizations live in a separate Widgetxx.js to the OOTB version (Smart Editor widget).

Question:

I have feature services that I don't want in the map, but do want to use to populate the infoWindow when a user clicks on the map. I haven't got a clue how to do this!

I have tried hooking into the set-features event of the popup and changing the features to use a deferred that returns the features from a query on the feature service, and this sort of works - it displays the selceted geometry associated with the feature, but the popup itself is not displayed.

I expect this is probably the worst way to try and achieve what I want. So, is it possible to add features to the existing popup associated with the map, or do I need to create a custom widget that has it's own custom popup and custom metohds for populating the content?

Thanks in advance,

Miles.

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Your approach is exactly what I would do. Listening for the setFeatures event is the best method. 

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Miles,

   What you are wanting to do is absolutely possible. But you need to have a custom widget or add your logic (ie. map click event handler > query > display results in popup) to an existing file such as the jimu/MapManager.js.

mileshitchen1
New Contributor II

Hi Robert,

Thanks for getting back to me. I don't think I made my problem very clear. What I want to do is add features to the existing popup, here's the scenario:

Action: User clicks on map.

Response: Standard popup is displayed showing features (contained in the maps layers) at the clicked location, and also features returned from a REST call to other feature services (that aren't represented as layers in the map).

I have written something now that does this (in a inherited SmartEditor Widget), but really need some verification that my approach is appropriate and there isn't a better way to do this. Basically my code does this:

Listen for the SetFeatures event of the maps InfoWindow.

Use an array of deferreds (and Dojo's 'all' method) to return an array features from the REST services.

Call the SetFeatures method on the maps InfoWindow, passing in the existing features plus those just retrieved from the REST services.

Call the Show method on the maps InfoWindow (having to do this as the previous SetFeatures seems to hide the popup).

I've also got logic in there that ensures the process doesn't get into an infinite loop!

So, in your opinion is this a good way to do what I want? Feel free to slate my approach, any constructive criticism is much appreciated.

Thanks,

Miles.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Your approach is exactly what I would do. Listening for the setFeatures event is the best method.