Select to view content in your preferred language

maxAllowableOffset on operationalLayers

944
8
Jump to solution
02-06-2012 08:46 AM
DonCaviness
Occasional Contributor
I am working with flex viewer 2.1.  I am trying to recalculate the maxAllowableOffset for each feature layer that I have listed as an operational layer on the zoom_end event and I'm having an issue.  I can set the maxAllowableOffset for the feature layer on load, just not on the zoom_end event.  I know it has to be something simple.  Can anyone point me in the right direction?

private function map_zoomEndHandler(event:ZoomEvent):void
     {
          featureLayer.maxAllowableOffset = getMaxAllowableOffset();
     }
  
private function getMaxAllowableOffset(pixelTolerance:int = 1):int
     {
          return Math.floor(map.extent.width / map.width) * pixelTolerance;
     }
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Don,

   OK, then this should work:

(map.getLayer(opLayers.label) as FeatureLayer).maxAllowableOffset = getMaxAllowableOffset();


Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus
Don,

   What are you trying to do here?...
0 Kudos
DonCaviness
Occasional Contributor
I'm trying to recalculate the maxAllowableOffset for each feature layer that it is loaded as an operational layer when the map zoom_end event is fired.  Currently I am on able to recalculate the maxAllowableOffset for the last feature layer that is added to the map.  I'm needing to be able to recalculate any of the feature layers that are added.  I have around 10 feature layers that are being added to the map.  The functions that I posted have been placed in the MapManager.mxml file.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Don,

   OK, I still don't understand what you are attempting here and for what reason. The maxAllowableOffset is a attribute that allow generalizing of a layer when it is queried, so you are trying to recalculate it at the end of every map zoom for what reason?

The maximum allowable offset used for generalizing geometries returned by the Query operation.      The units are the same as the returned features.      Only applicable for layers that are not editable.


So based on the info above why would recalculating it each time the map zooms do you any good?
0 Kudos
DonCaviness
Occasional Contributor
What this does is considerably speeds up the draw time of complex polygons.  At a statewide level the polygons will be generalized on the fly, removing vertices allowing the features to be drawn faster yet maintaining the integrity of the polygon.  If the maxAllowableOffset is not recalculated on map zoom, then you will end up with extremely jagged polygons.  An example of this can be found here http://help.arcgis.com/en/webapi/flex/samples/index.html#/Generalized_data/01nq0000006s000000/. I'm just needing to apply the zoom_end eventListener to all of the layers listed in the Operational Layers not just the last one added to the map.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Don,

   OK. Then try this:

private function map_zoomEndHandler(event:ZoomEvent):void
{
    var opLayers:Array = m_configData.opLayers;
    for (var i:int = 0; i < opLayers.length; i++){
        map.getLayer(opLayers.label).maxAllowableOffset = getMaxAllowableOffset();
    }
}


Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
DonCaviness
Occasional Contributor
Thanks Robert.  That seems like it should work but it throws a compile error at this line:

map.getLayer(opLayers.label).maxAllowableOffset = getMaxAllowableOffset();


This is the error it gives: Access of possibly undefined property maxAllowableOffset through a reference with static type com.esri.ags.layers:Layer.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Don,

   OK, then this should work:

(map.getLayer(opLayers.label) as FeatureLayer).maxAllowableOffset = getMaxAllowableOffset();


Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
DonCaviness
Occasional Contributor
Thanks Robert! That did the trick.
0 Kudos