Select to view content in your preferred language

Issues with FeatureLayer and Polygons

128
4
Jump to solution
Tuesday
jtcrash
New Contributor

My issue stems around polygons on a feature layer. I switched to a feature layer from graphic layer because I wanted the baked in labels. I am creating an angular app and the map I am working on displays a circle (polygon) with a line that shows the radius (in miles). I got the line and label showing up decently well, circles over 500 miles the line isn't exactly in the middle, but I assume that is a geodesic vs map projection issue and the distortion of that conversion.

My problem is, my polygon circle is filled with a transparent color 0.2 transparency, with a solid color border around it. When zooming in on the circle, the transparency is all over the place, if I had to guess it ranges from 0.2 to maybe 0.8 or 0.9. Having the circle nearly opaque is a deal breaker and I would prefer that circle remain transparent at the same level all the way through.

I did notice the UID on the poly changes on every zoom, but I assume this is not unusual. I have tried implementing my own color on zoom using renderer color stops, but that doesn't fix the problem at all.

I have also noticed the performance compared to graphic layer isn't great, the line and label doesn't always fully render on zoom

0 Kudos
1 Solution

Accepted Solutions
jtcrash
New Contributor

Ok, well, it seems that removing and recreating the FeatureLayer from within the effect() flow seems to do the trick. The circle poly is no longer fluctuating alpha on zoom. I suppose there could be some sort of context issue from Angular signal effects or something but likely that will require a smarter dev than me to figure out. The idea of the design is as follows:

When the effect detects change on the data ([{ lat, lon, radius, radiusUnit }, { ... }])
1. Delete the FeatureLayer containing any existing circles (areas) and delete the FeatureLayer containing the polylines with the radiusUnit label
2. Recreate the FeatureLayers
3. Loop through the area circles and polylines to create the graphics
4. applyEdits (addFeatures) the array of areas and lines to each layer respectively
5. Profit

View solution in original post

0 Kudos
4 Replies
Noah-Sager
Esri Regular Contributor

Hi @jtcrash, thanks for posting your question here. Do you have a simplified app that reproduces the issue?

0 Kudos
jtcrash
New Contributor

Noah, I am fairly certain this issue is a result of the angular environment I am working in. I am able to add a poly without the issue, it seems to be an issue when I load data for the poly via apply edits. I will report back once I figure out what is causing the fluctuation in alpha.

0 Kudos
jtcrash
New Contributor

@Noah-Sager it seems that adding a poly to a FeatureLayer from an Angular signal Effect is the cause of my issue. The code is a little complicated to post, but the idea is this:

- Once data changes (within the effect()) and contains lat, lon, radius as a minimum
- Remove any existing features using applyEdits
- applyEdit addfeature Circle graphic to the feature layer that has a simple renderer with transparent fill

If I add the circle using the same code directly from ngAfterViewInit, no problem; from the effect() the poly has the fluctuation on zoom.

0 Kudos
jtcrash
New Contributor

Ok, well, it seems that removing and recreating the FeatureLayer from within the effect() flow seems to do the trick. The circle poly is no longer fluctuating alpha on zoom. I suppose there could be some sort of context issue from Angular signal effects or something but likely that will require a smarter dev than me to figure out. The idea of the design is as follows:

When the effect detects change on the data ([{ lat, lon, radius, radiusUnit }, { ... }])
1. Delete the FeatureLayer containing any existing circles (areas) and delete the FeatureLayer containing the polylines with the radiusUnit label
2. Recreate the FeatureLayers
3. Loop through the area circles and polylines to create the graphics
4. applyEdits (addFeatures) the array of areas and lines to each layer respectively
5. Profit

0 Kudos