|
POST
|
So I'm stumped on this one. I've gone ahead and republished my map service in question here, and now I'm seeing even weirder behavior. But since it doesn't merely relate to the 'visible' property, I'll start a new thread. Thanks for chiming in, Dan.
... View more
09-29-2020
01:56 PM
|
0
|
0
|
2734
|
|
POST
|
Works for me when I try this: aString = "US20 EB <br> <br> FID 57 <br> RampDate 9/30/2013 \
<br> RouteId 161 <br> RouteName US20 EB <br> TownId 314 <br> \
TownName Watertown <br> IsMissingR False <br> IsMissingS False <br> \
IsMissingC True <br> InspNotes <br> DistrictId 6 <br> LegacyID \
335 <br> status 6 <br> StatusText Deficient <br> DstrctRank 669 \
<br> deficient -1 <br> GlobalID {C4BBAA58-9DFE-4953-AC74-FF3448002388} \
<br> created_us <br> created_da <br> last_edite DAVID.DINOCCO \
<br> last_edi_1 10/17/2017 <br> ReInspectn 0 <br> AssetID <br> \
ProgNotes <br> Rank 669"
aString.split("<br>")[14]
>>> ' status 6 '
len(aString.split("<br>"))
>>>27 Something wrong with the field name? Is it case sensitive? If [0] and [-1] work maybe you're indexing a list with length 1?
... View more
09-24-2020
03:34 PM
|
2
|
1
|
2458
|
|
POST
|
Sorry ,,, never a good idea to tweak things in transition from IDE to Geonet... I'm flipping the attribute to its Boolean opposite, so it should read: layer.visible = not layer.visible If it was visible to begin with, I want to hide it, and the other around. Any idea why this would fail for some layers? Thanks, Dan.
... View more
09-24-2020
02:26 PM
|
0
|
2
|
2734
|
|
POST
|
So to refine my approach after re-reading the documentation on layer properties and methods, I try this: # ... while iterating over layers
print("Layer Name: "+layer.name)
print("Layer visible: ",layer.visible)
print("Layer supports 'visible': ",layer.supports("visible"))
if layer.supports("visible"):
try:
layer.visible = !layer.visible
print("Switched Layer visibility")
except Exception as e:
print("Unable to switch visibility")
print(e)
print("Layer visible: ",layer.visible) On most cases, there result is as expected: Layer Name: My Well Behaved Layer
Layer visible: True
Layer supports 'visible': True
Switched Layer visibility
Layer visible: False But in other cases, I get this: Layer Name: My Poorly Behaved Layer
Layer visible: True
Layer supports 'visible': True
Unable to switch visibility
The attribute 'visible' is not supported on this instance of Layer.
Layer visible: True It seems that it the layer says it supports 'visible', it should do so. Would love to know how to make sense of this.
... View more
09-24-2020
01:43 PM
|
0
|
1
|
2734
|
|
POST
|
I was working on some webmap JSON massaging piece of code and wanted to get to the JSON of a Portal item. Looks like 4.x has a PortalItem class. But the closest I could there with 3.x was this: define([...,
"esri/arcgis/Portal",
"esri/request"
],
function(...,
arcgisPortal,
esriRequest)}
...
let portal = new arcgisPortal.Portal('https://my-super-awesome-portal');
let itemParams = {
q: 'id: gobbledeegobbledeegook'
};
portal.queryItems(itemParams)
.then(function(result){
let itemDataUrl = result.results[0].itemDataUrl;
let request = esriRequest({
url: itemDataUrl,
content: {f: 'json'},
handleAs: 'json',
});
request.then(function(response){
let operationalLayersJSON = response['operationalLayers'];
console.log(JSON.stringify(operationalLayersJSON));
}, function(error) {
console.log("Error: ", error.message);
});
}); Given the differences between 3.x/4.x, is the above the best way to do it? It works. Of course, it relies on me knowing and plugging the item's gobbledeegook ID. If I'm working in WAB and the item of interest is the current app's Portal web map, then I can use: this.map.itemId
... View more
09-23-2020
12:58 PM
|
0
|
1
|
1783
|
|
POST
|
Tanu Hoque, Noah Sager - so I've looked at this again, and notice that in the JSON under operational layers, in fact, I get this... "operationalLayers": [
{
"id": "defaultBasemap",
"title": "World Topographic Map",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
},
{
"id": "My_Map_365",
"title": "My_Map",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"url": "HTTPS:// ...<MapService URL>",
"layers": [
{
"id": 1,
"layerDefinition": {
"source": {
"type": "mapLayer",
"mapLayerId": 1
}
}
},
{
"id": 2,
"layerDefinition": {
"source": {
"type": "mapLayer",
"mapLayerId": 3
}
}
},
...MORE ... Since I'm trying to consume the JSON in a GP Service. The easiest to do is just to drop the "layers" key entirely. That way the GP service gets fed all the sublayers of the Map Services, which is specific by URL, and I weed through what I want to show using Python. Didn't realize this was working. I saw the additional layers and thought only those showing were passed through. If I leave the "layers" key, then I end up with duplicate layers on the Python side of the fence, which makes it unworkable. Anyway, thanks for chiming in. Now, I just need to figure out why some layers refuse to turn of using arcpy.
... View more
09-23-2020
12:29 PM
|
1
|
0
|
3263
|
|
POST
|
What determines whether an arcpy map layer that was created as part of a created created using ... result = arcpy.mp.ConvertWebMapToArcGISProject(WEB_MAP_AS_JSON) can be turned off? I'm creating a map from the above... aprx = result.ArcGISProject
mymap = aprx.listMaps()[0] But when I try turn layers invisible, I get this for some: The attribute 'visible' is not supported on this instance of Layer. The layers all derive from a Portal webmap so that they have... layer.isWebLayer = True Most of my layers don't have that issue and wilingly switch to : layer.visible = False
>> Success Is this limitation based on a setting in the webmap or in the underlying map services (item) ? Thanks.
... View more
09-23-2020
12:13 PM
|
0
|
5
|
2777
|
|
POST
|
Just what I needed. As someone who is constantly learning new Javascript stuff and API hacks at the same time, I was playing with ... document.getElementById("myElement").style.cursor = "<pointer-style>"; But the above did the trick for me!
... View more
09-17-2020
04:28 PM
|
0
|
0
|
2191
|
|
POST
|
Haha - sorry for not speaking more clearly, Noah. Basically, I want to capture the JSON for the current webmap in a variable... let webMapAsJSON = printTask._getPrintDefinition(currentMap, params);
let webMapAsJSONasString = JSON.stringify(webMapAsJSON); ... then I want to sneak in the JSON for some layers that are belong to the underlying webmap coming out of Portal but without modiifying what's showing in the map. (Working on custom widget for WAB, so I'm getting my map services via reference to a webmap item in Porta,.) I've been playing with some Javascript to basically add/modify portions of the JSON myself. I had merely hoped somebody had some ArcGIS specific snippets to share.
... View more
09-17-2020
03:52 PM
|
0
|
1
|
3263
|
|
POST
|
Let me modify the direction of my inquiry as I've thought through this further. So I have an event handler hooked up to a button that calls my printTask. I can make this same event add any layers to the map that I want passed in the JSON. But that has the seemingly inexplicable effect for the user why different layers now showing up in map and/or legend. Is there a simple way to grab the JSON, replace/update the layer info I want include and then feed it into my GP processing service, thereby avoiding the map refresh/change? Right now, the only way I can envision is by brute force string manipulation.
... View more
09-17-2020
11:43 AM
|
0
|
1
|
3263
|
|
POST
|
So I'm needing a simple clarification here: When using JSAPI to pass the webmap's JSON to a GP service, what's actually gathered by... webMapAsJSON = printTask._getPrintDefinition(currentMap, params); ... is the current state of the map, right? Layers that are turned off (hidden) won't be passed along? On a previous project I was working on, I had no trouble massaging the webmap inside my GP service to selectively turn things on/off to generate a variety of PDF products. Now, I'm noticing that the JSON is missing any layers that are turned off. Might be a no brainer but I want to confirm this is expected behavior. Workaround would be to turn on all layers before printTask is called. Or is there a way to reference the JSON of a webmap in Portal if essentially all the layers in my app derive from the webmap? But that wouldn't have info such as extent they way I needed. Darn! Thanks for any feedback.
... View more
09-17-2020
09:00 AM
|
0
|
7
|
3338
|
|
POST
|
Rebuilding from scratch a 3rd of 4th time, finally did the trick. Oh how I wish that error messages were a little more helpful when working with the JSAPI.
... View more
09-17-2020
08:47 AM
|
1
|
0
|
1642
|
|
POST
|
Still haven't had time to try this but I will report back after doing so eventually.
... View more
09-17-2020
08:46 AM
|
1
|
0
|
1340
|
|
POST
|
Never did get the selectFeatures() to work so I resorted to a work-around, simply iterating over the features which queryFeatures() would return and making them into Graphics one by one. Then adding them to map.graphics Seems these days that half the things i try to do don't work out the way that my interpretation of the documentation says it should. In the end, what matters though are result and work-arounds do the job.
... View more
09-17-2020
08:45 AM
|
1
|
0
|
2172
|
|
POST
|
Cool, thanks, Your one-liners are like fresh batteries in the caverns of ESRI documentation. Haha. Also. I just found that I may be complicating matters by using the result from a Search (with suggestions) to get my buffer center point and that seems to default to a WKID different from what's in my service. Not sure but I'm going to try to fix that it needed,.
... View more
09-10-2020
09:59 AM
|
0
|
1
|
2172
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-16-2025 07:32 AM | |
| 1 | 02-09-2024 05:18 PM | |
| 1 | 02-04-2025 09:27 AM | |
| 1 | 03-22-2019 10:55 AM | |
| 1 | 03-05-2020 08:46 AM |
| Online Status |
Offline
|
| Date Last Visited |
a month ago
|