Select to view content in your preferred language

Jagged polygons at large scales - how to smooth them out?

3796
17
01-13-2012 07:35 AM
MikeOnzay
Frequent Contributor
Are the concepts that are presented in the generalize and performance samples under feature layers going to solve the problem of jagged edges at large scales?

I have one featurelayer (150 mb featureclass) that displays 1-4 features at a time at most. At large scales I get really jagged edges. The source data, as viewed in ArcMap, is more detailed. I have included the maxAllowableOffset parameter as described in the generalize features sample. This does help with the speed of initially displaying some of the larger features based on what I am seeing in firebug. However, I'm struggling to make sense of the two samples and how I should implement the code in my own application.

It seems that the code in the generalize sample might be all I need:

    var maxOffset = function maxOffset(map, pixelTolerance) {
      return Math.floor(map.extent.getWidth() / map.width) * pixelTolerance;
    };

but the performance sample uses a different calculation:

function calcOffset() {
        return (globals.map.extent.getWidth() / globals.map.width);
        // console.log('extent changed...maxOffset: ', globals.maxOffset);
      }

I'm not sure what to do or whether it will fix this problem.
0 Kudos
17 Replies
MikeOnzay
Frequent Contributor
Post your code? Is your server endpoint public?


I'm hoping to have the endpoint public next week. And, when jsfiddle is back up I will post my code there. Until then I thought you might have another idea I could try.
0 Kudos
derekswingley1
Deactivated User
Do you see this in all browsers?
0 Kudos
MikeOnzay
Frequent Contributor
Do you see this in all browsers?


Firefox 9.01, 10 - yes;
Chrome 17.0.963.46 m - it does draw but it is really slow
IE 7,8 - I get a popup with "out of memory at line: 48" (the console shows this as line 48 in the javascript api). This is new. My app usually loads and brings in the interface and the basemap in IE. I had not checked IE for a while so it is possible that something I did the other day is causing this problem.
0 Kudos
derekswingley1
Deactivated User
Sounds like you're trying to push too much data to the client. It would be helpful to see exactly how you're setting maxAllowableOffset. Also, are you drawing especially large features (features that are much larger than the extent of the map that's viewed at one time)? You might want to explore setting up scale dependencies if that's the case because large features can sometimes overwhelm older browsers even when maxOffset is used correctly.
0 Kudos
DonCaviness
Occasional Contributor
I have been trying to implement this functionality myself without any luck.  I am adding a county polygon layer that has 82 features in the layer.  The features get generalized when they are loaded but not when the map is zoomed.  The onZoomEnd event listener is getting called but the setMaxAllowableOffset for the feature layer is not getting recalculated.  What am I missing here?

Here is the code I am using.


               var maxOffset = function maxOffset(map, pixelTolerance) {
          return Math.floor(map.extent.getWidth() / map.width) * pixelTolerance;
        };

               var highlightCountyLayer = new esri.layers.FeatureLayer("countyURL", {
           mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
    maxAllowableOffset: maxOffset(map,1) 
         });
 
  dojo.connect(highlightCountyLayer, "onLoad", function() {
       dojo.connect(map, "onZoomEnd", function() {
   console.log('onZoomEnd highlightCountyLayer')
       highlightCountyLayer.setMaxAllowableOffset(maxOffset(map,1));
       });
  });
     
  map.addLayer(highlightCountyLayer);
0 Kudos
derekswingley1
Deactivated User
Hi Don,

At 2.7, we do this by default for feature layers in ONDEMAND mode so you no longer listen for onZoomEnd and update your features. Can you move to 2.7?
0 Kudos
DonCaviness
Occasional Contributor
Hi Don,

At 2.7, we do this by default for feature layers in ONDEMAND mode so you no longer listen for onZoomEnd and update your features. Can you move to 2.7?


Thanks Derek! I was using version 2.6. Using 2.7 solves the issue i was having. If i were to use SNAPSHOT mode, would I need to use the onZoomEnd method for recalculating?
0 Kudos
derekswingley1
Deactivated User
Thanks Derek! I was using version 2.6. Using 2.7 solves the issue i was having.

Nice.


If i were to use SNAPSHOT mode, would I need to use the onZoomEnd method for recalculating?

SNAPSHOT pulls all features to the client when the layer is added to the map. Since you have all the features, you don't need to continuously update maxOffset.
0 Kudos