polygons overlapping point feature layers in html

446
3
Jump to solution
09-28-2018 09:58 AM
JaredPilbeam2
MVP Regular Contributor

I'm working on an app with a few feature layers. There are points (attractions) and polygons (preserves). Why do the polygons overlap the points? Image:

It doesn't seem to deal with the order of the feature layers in the <script>:

 //add attraction feature layer
                var attractions = new FeatureLayer({
                    url: "https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Attractions/FeatureServer/0?token=...",
                    id: "attractions",
                    zoom: 2,
                });
                //add will county boundary
                var boundary = new FeatureLayer({
                    url: "http://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Will_County_Boundary/FeatureServer/...",
                    id: "boundary",
                    zoom: 1,
                });
                //add Rt 66
                var rt66 = new FeatureLayer({
                    url: "https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Will_County_Tourist_Attractions/Fe...",
                    id: "rt66",
                    zoom: 1,
                });
                //add Canal
                var canal = new FeatureLayer({
                    url: "https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Will_County_Tourist_Attractions/Fe...",
                    id: "canal",
                });
                //add FPDWC preservs
                var preserves = new FeatureLayer({
                    url: "https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Will_County_Tourist_Attractions/Fe...",
                    id: "preserves",
                });
                //functions
                map.add(featureLayer);
                map.add(attractions);
                map.add(boundary);
                map.add(rt66);
                map.add(canal);
                map.add(preserves);
            });
    </script>

I suspect it has to do with the hosted feature layers back in AOL. The attractions feature layer was created from a CSV file, while the other feature layers were uploaded to AOL in a FGDB.

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jared,

   Order absolutely matters and using addMany is a better fit for your scenario:

map.addMany([preserves, canal, rt66, boundary, attractions]);

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jared,

   Order absolutely matters and using addMany is a better fit for your scenario:

map.addMany([preserves, canal, rt66, boundary, attractions]);
JaredPilbeam2
MVP Regular Contributor

Thanks Robert.

The order of your variables seems the wrong way round, but it did the trick! I tried this order and it didn't change anything:

map.addMany([attractions, boundary, rt66, canal, preserves]);

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jared,

  You have to think of it as layering if the first thing you add is the attractions then the following layer will be added on top of that layer. The last to be added it on top.