Select to view content in your preferred language

Popup for overlapped graphics [JavaScript API v4.3]

3046
5
03-21-2017 02:41 PM
IsmaelSilveira
Deactivated User

Hi. I'm having some problems with the popup in version 4.3.

In the API for JavaScript v4.2, when I click on a graphic that is overlapped to others in the map, a popup appears and it is possible to see the information of each one of those graphics, using the arrows or displaying the list of results.

Few days ago I decided to upgrade to v4.3 of the API, because I want to use some of the new features. Doing this I found that now, for the same overlapping graphics in the map, the popup no longer allows to see the information of each one.

Is it possible to have the same behavior for popups in v4.3? Otherwise, what would be the right way to do it?

Also, in the previous version it was possible to right-click to display the popup, but in v4.3 that is no longer possible. Is it possible to display the popup only using right-click?

Thanks, and sorry for my englilsh!

0 Kudos
5 Replies
ThomasSolow
Frequent Contributor

I don't know the answer here but I'm curious how you got multiple results into the popup in 4.2, I don't think I've seen that working in the 4.X API in general.

My understanding is that popups rely on hitTest to search for the feature that was clicked on.  (Although in 3D, currently, popups seem to rely on a back-end query for on-the-ground graphics).  Since hitTest only seems to return one graphic per layer view, it doesn't seem like multiple graphics in a popup should work right now.

If you get a chance, could you try to replicate how you got it working in a simple 4.2 sandbox like: JS Bin - Collaborative JavaScript Debugging ?

0 Kudos
IsmaelSilveira
Deactivated User

Thanks for your answer.

It's really odd, I tried to reproduce this behavior using 4.2 on JS Bin, but I could not do it

0 Kudos
IsmaelSilveira
Deactivated User

Thomas, I cannot replicate that behavior, but I've found an example of the API in which it happens! (FeatureLayer drawing improvements | ArcGIS API for JavaScript 4.3 )

I clicked on the map and that popup appears.

0 Kudos
thejuskambi
Frequent Contributor

As explained in another thread by Thomas Solow‌, this could happen when HitTest fails to return any record and the popup uses a fallback option to use query function to get the result. More details below.

https://community.esri.com/message/676156-re-viewhittest-bug-with-multipoint-geometry?commentID=6761... 

0 Kudos
ThomasSolow
Frequent Contributor

Thanks for digging that up.

I think the distinction here is that this map is actually querying the feature service on click, instead (or maybe in addition to) a front-end hitTest.  Querying a service has no trouble returning multiple features, which are then used to hydrate the pop-up.

Assuming you have a service to query, you should be able to manually perform a query using FeatureLayer.createQuery and FeatureLayer.queryFeatures.

One way to set this up would be adding a click event to the view and, on click, firing off a queryFeatures request to the service.  You can pass in the point where the user clicked as your query's geometry and I'd try the "intersects" spatial relationship.  The service should respond with a list of features which you can use to hydrate the popup like this:

view.popup.open({
   features: responseFromFeatureService.features, // array of features
   location: mapPoint // pop up points to this
});‍‍‍‍

You may want to call event.stopPropagation() inside your click callback to stop the client-side hitTest from occurring.

I'm not sure what exactly happened to cause this issue for you.  It does seem like this should be handled automatically and there may be some configuration setting I'm forgetting about that would take care of this.