|
POST
|
Hi That is not correct. You can work with map services, but to have full functionality you will need to add each layer separately. Take a look at the sample service of the USA: USA (MapServer) It is a Map Service with 4 layer: If you add the service to AGOL using the URL "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer " it will be added as a group layer and functionality will be limited to only the attributes of the current feature. When you add then individually adding "/0" for the Cities and "/3" for the Counties, you can use Arcade normally to extract the county name for the city like this: return First(Intersects($feature, FeatureSetByName($map,"USA - Counties"))).name; Which will appear in the pop-up:
... View more
08-11-2020
07:28 PM
|
2
|
0
|
2233
|
|
POST
|
Hi af2r_carto1 , The error message is kind of weird and may not represent what the error is really about. In case the layers are part of the same feature service you could use $datastore in stead of $map, but I think something else is going on. Would it be possible to share the map and data? You can create a group, share the map and data with that group and invite me to that group using my AGOL username "xbakker.spx".
... View more
08-11-2020
07:11 PM
|
0
|
2
|
2659
|
|
POST
|
Hi Matt Creaney , When I look at the Asset "RG-2-622" I get the result that I was expecting: Asset OID:1681
Asset name:RG-2-622
DateOfCommission:07/13/2020
# bays count:2
# bay.bay_number:1
## itps count:1
## itp asset_name:RG-2-622
## assets count:1
### asset OID:1681
#### vehicles count:4
##### vehicle:RV2 - Brennen
##### visited:07/20/2020
##### duration:1:47:22
##### vehicle:RV9 - Macca
##### visited:07/20/2020
##### duration:1:26:34
##### vehicle:RV2 - Brennen
##### visited:07/22/2020
##### duration:1:40:36
##### vehicle:RV2 - Brennen
##### visited:07/30/2020
##### duration:0:16:16
# bay.bay_number:2
## itps count:1
## itp asset_name:RG-2-622
## assets count:1
### asset OID:1681
#### vehicles count:4
##### vehicle:RV2 - Brennen
##### visited:07/20/2020
##### duration:1:47:22
##### vehicle:RV9 - Macca
##### visited:07/20/2020
##### duration:1:26:34
##### vehicle:RV2 - Brennen
##### visited:07/22/2020
##### duration:1:40:36
##### vehicle:RV2 - Brennen
##### visited:07/30/2020
##### duration:0:16:16 What you see here is that the ObjectID of the asset is 1681. When I look for the bays, I get 2 bays as result. But when I go through the related product commission ITP and get the asset, it gets back to asset RG-2-622 with ObjectID 1681. This still confirms my feeling that it would not be necessary to go through the bays and product commission ITP to get to the Asset, since it seems the be the same one the expression started. Do you have an example where this is not the case?
... View more
08-11-2020
06:42 PM
|
0
|
1
|
674
|
|
POST
|
Hi WhittingtonL_cohealthinst , Not sure where you are getting this error. It seems to be working just fine: // read out the location ID
var geoid = $feature["geoid_1"];
// create a query with that ID
var sql = "geoid_1 = @geoid";
// filter the data using the query
var fs = OrderBy(Filter($layer, sql), "State_Year ASC");
// get the count, and only process if you have results
var nodatayears = [];
var result = "Insurance rate through the years:";
var cnt = Count(fs);
if (cnt > 0) {
// loop through results
for (var f in fs) {
var finalval = f["Value_Final"];
if (finalval == -1) {
// result += TextFormatting.NewLine + " - Data Not Available (" + f["State_Year"] + ")";
nodatayears[Count(nodatayears)] = f["State_Year"];
} else {
result += TextFormatting.NewLine + " - " + Round(f["Value_Final"], 1) + "% (" + f["State_Year"] + ")";
} }
}
if (Count(nodatayears) > 0) {
result += TextFormatting.NewLine + " - Data Not Available for years: " + Concatenate(nodatayears, ", ");
}
return result; ... results in:
... View more
08-11-2020
04:09 PM
|
0
|
7
|
1789
|
|
POST
|
Hi Matt Creaney , I have no access to the WebApp. Based on your last comment I did a little test, taking the production database feature (the asset) and get the related bays and for each bay get the related Product Commission ITP and for each Product Commission ITP get back to the assets (in this case I used a query based on the asset name) and did a buffer around each asset to get the vehicles within the buffer: // An Asset (production database feature) has 1 or more Bays
// and a Bay has 1 or more Product Commission ITPs,
// so you have to get to the ITP via the Bay record.
var result = "";
var Buffer_Distance = 100;
var dateFormat = "MM/DD/Y";
var DateOfCommission = Text($feature.CreationDate, dateFormat);
result = "Asset OID:" + $feature.OBJECTID;
result += TextFormatting.NewLine + "Asset name:" + $feature["asset_name"];
result += TextFormatting.NewLine + "DateOfCommission:" + DateOfCommission;
var bays = FeatureSetByRelationshipName($feature, "Bay");
result += TextFormatting.NewLine + " # bays count:" + Count(bays);
for (var bay in bays) {
result += TextFormatting.NewLine + " # bay.bay_number:" + bay.bay_number;
var itps = FeatureSetByRelationshipName(bay, "Product_Commission_ITP");
result += TextFormatting.NewLine + " ## itps count:" + Count(itps);
for (var itp in itps) {
var assetname = itp.asset_name;
result += TextFormatting.NewLine + " ## itp asset_name:" + assetname;
var sql = "asset_name = @assetname";
var assets = Filter($layer, sql);
result += TextFormatting.NewLine + " ## assets count:" + Count(assets);
for (var asset in assets) {
result += TextFormatting.NewLine + " ### asset OID:" + asset.OBJECTID;
var assetbuffer = Buffer(asset, Buffer_Distance, 'meters');
var vehicles = Intersects(FeatureSetById($map, "Vehicle_Locations_8121"), assetbuffer);
result += TextFormatting.NewLine + " #### vehicles count:" + Count(vehicles);
for (var vehicle in vehicles) {
result += TextFormatting.NewLine + " ##### vehicle:" + vehicle.vehicle;
var visited = Text(vehicle["date_visited"], dateFormat);
var duration = vehicle["visit_duration"];
result += TextFormatting.NewLine + " ##### visited:" + visited;
result += TextFormatting.NewLine + " ##### duration:" + duration;
}
}
}
}
return result; However, no matter where I look it will only find a single asset: Asset OID:2450
Asset name:RO5310
DateOfCommission:07/20/2020
# bays count:1
# bay.bay_number:1
## itps count:1
## itp asset_name:RO5310
## assets count:1
### asset OID:2450
#### vehicles count:4
##### vehicle:RV20 - Matt B
##### visited:07/20/2020
##### duration:2:08:35
##### vehicle:RV1 - Locky
##### visited:07/23/2020
##### duration:0:26:01
##### vehicle:RV10 - Nibs
##### visited:07/27/2020
##### duration:0:12:44
##### vehicle:RV9 - Macca
##### visited:07/30/2020
##### duration:3:54:38 Can you point out a location where you have either multiple bays or multiple product commission ITP's?
... View more
08-11-2020
03:32 PM
|
0
|
3
|
2242
|
|
POST
|
Hi Robert Liveanu , Don't worry, I'm happy to help. If you run into any problems, you can reach out to me.
... View more
08-11-2020
02:25 PM
|
0
|
0
|
9643
|
|
POST
|
Hi Lindsey Whittington , There are always options to avoid the null error you are facing. If you can share the webmap with the layer I can have a look. Are you planning to have all these layers in a single map (I strongly recommend you not to do that)? Maybe more importantly, for what audience are you preparing this and what are the expected workflows? If you have different requirements for different groups of people, it would be better to configure focused based apps for each group and not load too many layers into your map. You can also create a single pop-up combining information from multiple layers. It all depends on what will work best for the end user (and as long as it is possible to configure and performance is acceptable).
... View more
08-11-2020
01:18 PM
|
0
|
9
|
1789
|
|
POST
|
Hi Robert Liveanu , For your specific case I would recommend you to use "GroupBy". This will also allow you to show the count of the trees or other statistics if available (average height, diameter, etc). There is a blog post by Paul Barker that explains the use of GroupBy: What’s New in Arcade 1.8 I recommend you to read it and if you have any questions, just post them here (or start another thread, which would probably be better, to keep the threads clean)
... View more
08-11-2020
01:11 PM
|
1
|
2
|
9643
|
|
POST
|
Hi WhittingtonL_cohealthinst , Ok, I guess it is not related to the female layer, since it seems to be working with the same expression (just changed the text "Male" into "Female"):
... View more
08-11-2020
12:11 PM
|
0
|
11
|
1789
|
|
POST
|
Hi WhittingtonL_cohealthinst , Are you trying to do something similar on the female layer? If so, I can have a look. To answer your question. Apparently, somewhere along the road it has a variable containing the value null which is casted to string. I will have a look (assuming it is related to the female layer).
... View more
08-11-2020
12:04 PM
|
0
|
12
|
1789
|
|
POST
|
Hi [email protected] , It makes sense that it might be data-related. Please post back if you find a reason.
... View more
08-11-2020
12:02 PM
|
0
|
1
|
3224
|
|
POST
|
Hi Lindsey Whittington , Sure, you can put in a condition that checks for the -1 value: // read out the location ID
var geoid = $feature["geoid_1"];
// create a query with that ID
var sql = "geoid_1 = @geoid";
// filter the data using the query
var fs = OrderBy(Filter($layer, sql), "State_Year ASC");
// get the count, and only process if you have results
var result = "Male % through the years:";
var cnt = Count(fs);
if (cnt > 0) {
// loop through results
for (var f in fs) {
var finalval = f["Value_Final"];
if (finalval == -1) {
result += TextFormatting.NewLine + " - Data Not Available (" + f["State_Year"] + ")";
} else {
result += TextFormatting.NewLine + " - " + Round(f["Value_Final"], 1) + "% (" + f["State_Year"] + ")";
} }
}
return result; Which will show up like this: Maybe that is not what you want and you can do it differently by switching off including any results that have no data available (see line 16 which has been commented out): // read out the location ID
var geoid = $feature["geoid_1"];
// create a query with that ID
var sql = "geoid_1 = @geoid";
// filter the data using the query
var fs = OrderBy(Filter($layer, sql), "State_Year ASC");
// get the count, and only process if you have results
var result = "Male % through the years:";
var cnt = Count(fs);
if (cnt > 0) {
// loop through results
for (var f in fs) {
var finalval = f["Value_Final"];
if (finalval == -1) {
// result += TextFormatting.NewLine + " - Data Not Available (" + f["State_Year"] + ")";
} else {
result += TextFormatting.NewLine + " - " + Round(f["Value_Final"], 1) + "% (" + f["State_Year"] + ")";
} }
}
return result; This will look like this which is not very helpful either: So you can handle those cases differently like this (in case you have census tract with part data and part no data. In this case you will collect all the years without data and add that list to the result: // read out the location ID
var geoid = $feature["geoid_1"];
// create a query with that ID
var sql = "geoid_1 = @geoid";
// filter the data using the query
var fs = OrderBy(Filter($layer, sql), "State_Year ASC");
// get the count, and only process if you have results
var nodatayears = [];
var result = "Male % through the years:";
var cnt = Count(fs);
if (cnt > 0) {
// loop through results
for (var f in fs) {
var finalval = f["Value_Final"];
if (finalval == -1) {
// result += TextFormatting.NewLine + " - Data Not Available (" + f["State_Year"] + ")";
nodatayears[Count(nodatayears)] = f["State_Year"];
} else {
result += TextFormatting.NewLine + " - " + Round(f["Value_Final"], 1) + "% (" + f["State_Year"] + ")";
} }
}
if (Count(nodatayears) > 0) {
result += TextFormatting.NewLine + " - Data Not Available for years: " + Concatenate(nodatayears, ", ");
}
return result; Which will look like this:
... View more
08-11-2020
11:18 AM
|
1
|
16
|
2727
|
|
POST
|
Hi Lindsey Whittington , Just to know if I am on the right track have a look at the green text in the image below: What I do, is using the geoid_1 field to identify the location and then filter the layer using this geoid_1 and loop through the results to show the final values through the years. Are you looking for something like this or do you want to extract statistics of the data? The expression I used was: // read out the location ID
var geoid = $feature["geoid_1"];
// create a query with that ID
var sql = "geoid_1 = @geoid";
// filter the data using the query
var fs = OrderBy(Filter($layer, sql), "State_Year ASC");
// get the count, and only process if you have results
var result = "Male % through the years:";
var cnt = Count(fs);
if (cnt > 0) {
// loop through results
for (var f in fs) {
result += TextFormatting.NewLine + " - " + Round(f["Value_Final"], 1) + "% (" + f["State_Year"] + ")";
}
}
return result;
... View more
08-11-2020
10:52 AM
|
1
|
18
|
2727
|
|
POST
|
Hi Lindsey Whittington , Thanks for clarifying! I do have a couple of additional questions/observations: What type of geometry does your data have (are you working with points, lines or polygons)? Do features with the same location have an ID that can be used to identify them? When creating a label you will only have access to your current feature. A pop-up can contain statistical information on all the features. It would help to have access to the data. If you can share the data, please create a group, share the data with that group and invite me using my AGOL user name "xbakker.spx".
... View more
08-11-2020
09:40 AM
|
0
|
20
|
2727
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|