Skip to main content

setLayerDefinition for multiple layers

Comments

7 comments

  • Zack Robison
    I don't follow you on the workflow merging layer definitions, but if you have one definition that you are trying to apply to many layers I think that your only good recourse is to loop through the layers and set each definition one by one.  If you feel comfortable in the stasis of your service/layer configuration, I would hardcode the service:layer id pairs into a dictionary and iterate through the key:value pairs in a foreach activity, so you only need to write and maintain the actual definition in one location.
    0
  • Zack Robison
    Are you telling me that any 28 layers will work work but any 29 fail? If that's the case then I don't think that I can help you.  I would personally still be inclined to ensure that this isn't the doing of one/many problem layer(s), which I would do by updating a display form within that loop to include the layer id that you'll be defining before you run that define. If it pauses consistently somewhere, you may have found a layer that doesn't like the new definition.  Also, you may also consider running a Refresh Map activity within the loop as well.
    0
  • Permanently deleted user
    Have as try using the Parallel For Each activity as seen in the linked modified workflow.

     

    You may get some time efficiencies. I think repeatedly doing a Refresh Map activity will just slow things down.

     

    Regards

     

    Ralph Price

     

    https://dl.dropboxusercontent.com/u/24636206/Geocortex/parallelForEach.xaml
    0
  • Permanently deleted user
    Hi Ralph,

     

    I've tried the Parallel For Each activity. It works well until I reach a certain number of layers, then I have the same map refreshing issue.

     

    I tried to execute the set layer definition in my custom module instead but for some reasons the layer definitions are not saved in my feature layers?

     

    I can't figure out what's missing?

     

    I've pasted my code below (typescript code) with hardcoded arguments for the purpose of my tests.

     

    Thanks as always!  ;-)

     

      filterValuesFromLayers() {   var baseUrl = this.app.site.essentialsMap.findMapServiceById("10").serviceUrl;   var listLayerIds = [76, 80, 84, 86, 88, 92, 95, 99, 100, 107, 108, 109, 112, 113, 118, 125, 127, 134, 136, 143, 144, 152, 159];    listLayerIds.forEach(function(item) { var url = baseUrl + "/" + item.toString(); var layer = new esri.layers.FeatureLayer(url); layer.setDefinitionExpression("(FILE_NUMBER='963235') AND (IND_DIFSN= 'O') AND (SCALE_VALUE=1000)"); }); this.app.site.essentialsMap.findMapServiceById("10").refresh(); }

     

     

     
    0
  • Permanently deleted user
    Use Parallel For Each activity (inside parallel) and use single RefreshMap out side of parallel. This is working for me perfectly 
    0
  • Permanently deleted user
    Hi,

     

    Thank you for all the replies. I finally found out the source of the problem and it was not from the workflows nor Geocortex but from the MapService. For some reasons something went wrong when we imported the MXD file in ArcGIS Server and the MapService URL returned from a request was corrupted and extremely long.

     

    When I was filtering a large number of layers or using a very long layer definition, the request URL returned was truncated and that's the reason why the map wasn't refreshing properly. We created a new MXD from scratch and did a new import. This time it worked and everything is running smoothly since.
    0
  • Permanently deleted user
    Glad to hear that you got it sorted.

     

    This is one of the joys of a multi-tier system as far as tracking issues down.

     

    Regards

     

    Ralph
    0

Please sign in to leave a comment.