Select to view content in your preferred language

SceneView Source Polygons No Popup

1655
8
Jump to solution
06-12-2017 01:03 AM
JoakimClivemo
Emerging Contributor

Hi,

I've developed a 4.3 application where the users can choose to mark random point or areas on a map. The graphics are fetched by queries on the server side and pushed down to the client. There can be many layers and the user also can choose 2D or 3D. I am using a simple PopupTemplate, set on the layer, to display info from the graphics.

Since there can be several layers I need to use FeatureLayer and it's source attribute in order to get all the bells and whistles I need.

My problem is that on 3D views, the SceneView implementation, the Popup does not work for Polygons, it just won't pop up!

All other combinations work just fine, 2D with Polygons, 2D with Points and even 3D with Points works.

Just not 3D with Polygons, anyone out there with an idea?

Cheers,

Joakim

0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Frequent Contributor

Thanks for the sample.

It looks like there's two bugs here: the first (not relevant to you) is that 'on-the-ground' graphics in a graphics layer only use a popup template set on the individual graphic, they don't look for a popupTemplate on the layer itself.

The second (relevant to you) concerns how feature layers constructed from a source are searched.  Since there's no backend resource for these feature layers, the search is done in the client.  This works fine for geometries that are not 'on-the-ground,' but for anything that is draped on the ground, there are a few issues.

Here's a workaround that may fix this issue for you, for now:

// layer is any feature layer you create from a source.
// this code should be placed somewhere after the layer has been created
layer.createQuery = function(){
  let q = layer.__proto__.createQuery.call(layer);
  q.outFields = null;
  q.where = null;
  return q;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Please let me know if that helps.

View solution in original post

8 Replies
ThomasSolow
Frequent Contributor

I'll take a look at this, it may have to do with hitTest.  Can you provide a sample with the layer in question in a scene view?

Could you also be more specific about what you mean by using the source for a feature layer?

0 Kudos
JoakimClivemo
Emerging Contributor

Thanks for looking at this!

I can try to create a pure JavaScript sample, my current solution is far to complex to attach as an understandable sample.

I'll have to get back to you on that one, but here's some info anyway...

By "source for a feature layer" I mean that I use the source attribute, rather than using an URL.

In short:

Depending on user actions I generate one or several JSON-strings containing "Graphic" elements on the server side which is then pushed to the browser.

The browser JavaScript then basically do:

var g = Graphic.fromJSON(myJSON);
myFeaturLayer.source.add(g);  // Hence the "FeatureLayer and it's source attribute"

The FeatureLayer has been configured and added to the map earlier.
The FeatureLayer and the Graphics are created and added using the same code regardless of 3D or 2D.
0 Kudos
ThomasSolow
Frequent Contributor

Okay, after looking at this: can you try setting the popupTemplate on each graphic?  It can be on the layer also, but please check to see if setting it on the graphic changes anything.

0 Kudos
JoakimClivemo
Emerging Contributor

Attached you'll find an example.

No, adding the popup template to the Graphic does not help.

/Joakim

ThomasSolow
Frequent Contributor

Thanks for the sample.

It looks like there's two bugs here: the first (not relevant to you) is that 'on-the-ground' graphics in a graphics layer only use a popup template set on the individual graphic, they don't look for a popupTemplate on the layer itself.

The second (relevant to you) concerns how feature layers constructed from a source are searched.  Since there's no backend resource for these feature layers, the search is done in the client.  This works fine for geometries that are not 'on-the-ground,' but for anything that is draped on the ground, there are a few issues.

Here's a workaround that may fix this issue for you, for now:

// layer is any feature layer you create from a source.
// this code should be placed somewhere after the layer has been created
layer.createQuery = function(){
  let q = layer.__proto__.createQuery.call(layer);
  q.outFields = null;
  q.where = null;
  return q;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Please let me know if that helps.

JoakimClivemo
Emerging Contributor

Great job, almost there!

I got it to work in the example code, but for some obscure reason it does not work in my real application.

More clever ideas? Does it matter when the fix is applied, before the layer is added to the map?

0 Kudos
JoakimClivemo
Emerging Contributor

My bad!

Type-o, missed to change the call parameter name.

It works great now! You have saved my day!

Thanks a million!

0 Kudos
TonyGraham
Occasional Contributor

This also fixed my popup problem.  Thank you! 

However, I still have a problem in that, for an almost identical situation, I need a hit test to work.  It does for MapView, but not SceneView.  If I add the following code to Joakim's example, I'll get the "GRAPHIC FOUND" message when mousing over Sweden only with a MapView.

view.on("pointer-move", function(event){

    view.hitTest(event).then(function(response){

        if (response.results.length) {

            var resultWithGraphic = response.results.find(function (result) {

                return result.graphic != null;

            });                                   

            if (resultWithGraphic)

                document.getElementById("hitTestResult").innerHTML = "[GRAPHIC FOUND]";

            else

                document.getElementById("hitTestResult").innerHTML = "--";

        }

    });

});

And, elsewhere:

<span id="hitTestResult"></span>
 
 For a SceneView, I'll get the result.mapPoint, but the result.graphic is always null.
0 Kudos