3

I've developed an application on Vue JS which loads the services from the ArcGIS Server via REST API.

When I load a service by the URL http://arcgis/.../query?f=json&outFields=*, the layers are added with a given color.

Is there a way to change the color of the features on the map, without editing on the server? It's done somehow here via the Change style option.

Now I'm solving this by adding the polygons with chosen colors on the features, however, this is awful regarding the performance.

8
  • Possible duplicate of Change WMS symbology
    – wfgeo
    Commented Aug 15, 2018 at 6:30
  • The query operation returns features only, no colors. Whatever color you see is determined by the client software you are using. If you tell us what that software is, someone might be able to help you. Another thing: In the query you specified returnGeometry=false, meaning only the attributes are returned. So even with color information, there is nothing to draw.
    – Berend
    Commented Aug 15, 2018 at 6:52
  • @1saac ArcGIS Server via REST API isn't a WMS so the question is not a duplicate
    – nmtoken
    Commented Aug 15, 2018 at 9:22
  • 1
    View the source on this example: developers.arcgis.com/javascript/3/samples/…
    – enolan
    Commented Aug 22, 2018 at 14:55
  • Loaded features in an application, right? Check out the source code of the map in the link. Is changing the colors of loaded features.
    – enolan
    Commented Aug 22, 2018 at 17:03

1 Answer 1

2
+50

I don't think you can transform the properties of a REST service via GET. You can update the drawingInfo of a feature service using Update Definition via POST:

https://developers.arcgis.com/rest/services-reference/update-definition-feature-layer-.htm

Example 3 shows how the post body will be formatted. For example: { "drawingInfo": { "renderer": { "type": "uniqueValue", "field1": "symbolid", "field2": null, "field3": null, "fieldDelimiter": ", ", "defaultSymbol": null, "defaultLabel": null, "uniqueValueInfos": [ { "symbol": { "type": "esriSLS", "style": "esriSLSSolid", "color": [ 0, 0, 0, 255 ], "width": 2 } .... The JSON response will be related to the update definition request itself. So, 'Success' : true. You will need to capture the JSON of the layer, modify the color property and send the entire body with your changes. See this URL for an example: https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2

10
  • Do you administer the service? If so, you should consider the Edit Service function: developers.arcgis.com/rest/enterprise-administration/server/…
    – psl
    Commented Aug 22, 2018 at 23:54
  • I don't want to edit on the server. Does this approach edit on the server?
    – Leeloo
    Commented Aug 23, 2018 at 6:47
  • Yes, both options edit the properties of the service on a server. You should modify your question to include more information regarding ' load a service ' and ' user side '. What language or framework are you using to load your service and make client-side modifications?
    – psl
    Commented Aug 23, 2018 at 17:48
  • I showed an example from arcgis.com in the question, which changes the colors on the user side only (via the Change style option)
    – Leeloo
    Commented Aug 23, 2018 at 17:58
  • 1) Create a FeatureLayer using ESRI's Javascript API 2) Apply the renderer property to your feature layer, as suggested by @enolan developers.arcgis.com/javascript/latest/api-reference/…
    – psl
    Commented Aug 23, 2018 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.