Hello,
I am trying to use the ArcGIS Online REST API to add an item for a WMS map service via an HTTP POST to:
<base url>/content/users/<username>/addItem
by posting the following data in the POST body:
{"culture": "en-us",
"f": "json",
"token": token,
"type": "WMS",
"title": title,
"url": "...my WMS url here...",
"text": "my JSON text here",
"extent": "-140.96, 60, -90.45,40}
using something like the following JSON as the "text" above:
{
"layers": [
{
"name": "my_layer",
"title": "my_layer"
}
],
"maxWidth": 2048,
"copyright": "copyright here",
"format": null,
"url": "...url here...",
"mapUrl": "...url here...",
"maxHeight": 2048,
"version": "1.3.0",
"title": "...title here...",
"spatialReferences": [
3857,
4326
]
}
When I substitute in an actual WMS URL and a layer name, this works -- I can successfully add the layer to ArcGIS Online, and view it on a map.
Now what I want to do is specify a WMS named style other than the default style to be applied to my layer. Said another way, I'd like ArcGIS Online to fill in the OGC WMS &STYLES=... parameter for all requests it makes to my layer. Is this possible via the ArcGIS Online REST API? Can someone provide an example of how I might modify the JSON above to specify a WMS style?
Thanks!
Hi!
It looks like you’ve got the WMS layer posting setup working perfectly, which is great. Regarding applying a specific WMS named style, ArcGIS Online REST API doesn’t provide a direct parameter in the JSON for &STYLES; you usually need to append the style directly to your WMS URL when specifying the layer. For example, modifying your "url" field to include &STYLES=yourStyleName should make ArcGIS Online apply it automatically.
On a lighter note, if you ever want a quick mental break from coding or mapping, you can try some fun puzzle games online. For instance,2048 16x16 offers a larger grid version of the classic 2048 game, perfect for sharpening your logic skills during downtime.
Hope this helps!
Hi!
It seems like your WMS layer configuration is working perfectly, which is great news. Regarding applying a specific WMS named style, the ArcGIS Online REST API doesn’t have a dedicated JSON parameter for &STYLES. The simplest solution is to include the style directly in your WMS URL. For example, you can modify your "url" field to add &STYLES=yourStyleName, and ArcGIS Online should automatically apply that style to your layer.
By the way, if you need a quick break from coding or mapping tasks, you can try some online puzzle games. For instance, 2048 16x16 is a larger grid version of the classic 2048 game, offering a fun challenge and a great way to sharpen your logic skills in downtime.
Hope this helps!