Skip to main content

ResymbolizeLayer

Comments

4 comments

  • Zack Robison
    The parameter needs to be an object, so you should use the Newtonsoft library to serialize your text.

     

    The "id" param needs to be renamed to "gcxLayer" though IIRC the function in the viewer is a bit deceptive here... that arg takes a string id for the GCE map service id (not the layer), and I'm not sure how the viewer gets the layer from there.  I myself have modified the .js so that the gcxLayer arg in this specific function would take a string pair denoting not only the map service but also the layer id in that argument; perhaps someone from LatGeo knows a better way to handle this though.  Maybe the source arg will do the trick, but glancing at the definition of that command today makes me think that it only takes two args but then my js skills are a tad rusty.

     

    Modding the viewer js is a bit of an advanced solution, so be sure to have a comfotable backup situation before embarking if you decide to head that route.

     

    The "drawingInfo" param needs to be called "renderer" and IIRC it only takes the renderer definition, so you can jettison the extra info there.

     

    Finally, it's completely possible that the renderer syntax is off but I'm not comfotrable or patient enough to figure that out haha.

     

    Good luck and let us know what works!  IMO this command could use some polish but its workable if you're willing to roll up your sleeves well past your elbows.
    0
  • Luuk Schaminée
    Hi Zack,

     

    thanks for your response. I tried to translate your reply into a working solution. But I did not succeed.

     

    I tried running the "ResymbolizeLayer" command from within a workflow in a Run External Command Activity with the parameter Newtonsoft.Json.Linq.JObject.Parse("{'gcxLayer': {'mapService': 3, 'source':{'type':'mapLayer', 'mapLayerId': 3}},'renderer': {'type': 'simple', 'symbol': {'type': 'esriSFS','style': 'esriSFSSolid','color': [0,255,0,0],'outline': {'type': 'esriSLS','style': 'esriSLSSolid','color': [0,0,255,255],'width': 2}}}}") I also tried 'gcxLayer': {'id': 3, 'mapService':3, 'type': 'FEATURE_LAYER'}, but no difference. If I leave the mapService part out of the JSON I get the error "TypeError: t.mapService is undefined".

     

    The mapservice I use is dynamic. I also use a renderer in the Dynamic Definition of the layer I am trying to change.

     

    I hope this helps to get it working. I think I am almost there, but am missing a small piece of the puzzle to solve it completely.
    0
  • Permanently deleted user
    Thanks Luuk for asking the question two years ago. I also want to know how to use the command to save me create dozens of layers from the same data unnecessarily in map service for different categories. Could the Geocortex support team provide some clear answer? thank you
    0
  • Berend Veldkamp

    A bit late for the party, but here is how it works in case anyone is still using GVH.

     

    The JSON passed to JObject.Parse() should contain two items:

    1. gcxLayer: This is the ID of the mapservice as a string
    2. renderer: A string representation of the renderer

     

    This only seems to work with FeatureLayers and therefore, no layerId is necessary. The Id represents the Id of the mapservice that you can find in the designer. A FeatureLayer mapservice only contains a single layer in GVH.

    Note that this doesn't mean you can't use a MapService, it's just that when you add it to the map, you should select a single layer and click "Add as FeatureLayer"

    The renderer is in JSON format, but it's encoded as a string, so you must escape " and \ characters. Luuk's example uses single quotes, but that's not valid JSON.

    {
        "gcxLayer": "1",
        "renderer": "{\"type\":\"simple\",\"symbol\":{\"type\":\"esriPMS\",\"url\":\"https://example.com/image.png\",\"width\":75,\"height\":75}}"
    }

     

    The above example should be passes as a string to JObject.Parse(), so this means you need to escape again. To prevent going insane, I suggest to save the text as a file somewhere in the Sites directory, and use the Read File activity, with a filename like gcxfile:///MySite/MyFile.json

    0

Please sign in to leave a comment.