Display a popupTemplate on Multipoint (JavaScript 4.4)

1116
3
Jump to solution
08-24-2017 05:35 AM
MichaelLodes2
Occasional Contributor

Hello together,

I already managed to display a single Point (from client side) including a popupTemplate. But how can I display a popupTemplate on a big amount of Points (a few thousand) efficiently?

I tried to do this by adding single Points to a MultiPoint object, but failed. The points are displayed in the map, but without the popup by clicking on the point.

You can see a code snippet below. If I put the single Point into the Graphic object, the popupTemplate is displayed in the map. But when I put the Point into the MultiPoint object, and that MultiPoint into the Graphic, that doesn't work.

Could you tell me the best practice for this case please?

      var multipoint = new Multipoint({
          spatialReference: { wkid: 4326 }
      });
      

      var point = new Point({
        longitude: -49.97,
        latitude: 41.73

      });
      
      multipoint.addPoint(point);
      
      
 
      var markerSymbol = new SimpleMarkerSymbol({
        color: [226, 119, 40],
        outline: { 
          color: [255, 255, 255],
          width: 2
        }
      });


      var pointGraphic = new Graphic({
        geometry: multipoint,
        symbol: markerSymbol,
                popupTemplate: {

        title: "Point 1",

        content: "Content"

      }
      });

     view.graphics.addMany([pointGraphic]);

Thank you very much!

Michael

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Occasional Contributor III

Try using a graphics layer instead of view.graphics.  Your popup should work if you do that.  This is a longstanding bug.

As far having different attributes for each point in a multipoint, there's no built-in way to do this that I'm aware of.  I would suggest using many point graphics instead of a multipoint if you need this.  Instantiating many different geometries and graphics can be expensive but only if there are a relatively large number of graphics.  For most users this isn't an issue.

If it is an issue for you, one solution would be to have a dictionary that maps [x, y] to popup templates and at some point in the opening popup process that occurs on click, you could do a lookup in this map and change the content/title of the popup template.

View solution in original post

3 Replies
MichaelLodes2
Occasional Contributor

I additionally want to show point specific attributes in that popupTemplate 🙂

0 Kudos
ThomasSolow
Occasional Contributor III

Try using a graphics layer instead of view.graphics.  Your popup should work if you do that.  This is a longstanding bug.

As far having different attributes for each point in a multipoint, there's no built-in way to do this that I'm aware of.  I would suggest using many point graphics instead of a multipoint if you need this.  Instantiating many different geometries and graphics can be expensive but only if there are a relatively large number of graphics.  For most users this isn't an issue.

If it is an issue for you, one solution would be to have a dictionary that maps [x, y] to popup templates and at some point in the opening popup process that occurs on click, you could do a lookup in this map and change the content/title of the popup template.

MichailMarinakis1
Occasional Contributor II

Hi @ThomasSolow , 

I have noticed that we have the same issue with a multipoint feature layer and the popup for version 4.21 of the ArcGIS JS API.

We create a feature layer based on a feature service with feature access. We set the popuptemplate for this service in the code. We load the layer in a mapview. When we click on one of the multipoint features to open the popup, then it doesn't open. 

In the same feature service we have more layers with polygons and lines. We load these layers too in the mapview and the popup works perfectly. 

We have also noticed that when we create a new feature from the multipoint feature layer, using the Editor widget, then the popup appears until we refresh the page. I guess there is a temporary graphic created? 

Can you please confirm if the popup for multipoint feature services works fine with the latest version of the API (4.21) ? 

Thanks! 

 

0 Kudos