|
POST
|
The error is caused by a missing "+" after the first double quotes in line 10 (and line 12 and 14).
... View more
06-24-2024
01:40 PM
|
0
|
0
|
3965
|
|
POST
|
You don't need curly braces for one line if/else statements (although they are good for avoiding confusion). This expression works properly var words = ['n', '1st', 'ave']
var upperWords = ['N','W']
var lowerWords = ['1st', '2nd']
var label = ''
for (var word in words)
{
var isUpper = IndexOf(upperWords, words[word]) > -1
var isLower = IndexOf(lowerWords, words[word]) > -1
if (isUpper)
label += words[word] + ' '
else if (isLower)
label += lower(words[word]) + ' '
else
label += proper(words[word]) + ' '
}
return label returning "N 1st Ave "
... View more
06-24-2024
01:38 PM
|
0
|
2
|
3965
|
|
POST
|
When posting code, don't use an image. Use the "Insert/Edit code sample" button. This makes it easier for us to read and copy it to check syntax.
... View more
06-24-2024
01:16 PM
|
0
|
0
|
3971
|
|
POST
|
There's definitely something odd happening with notifications. I just got an email saying one of my answers was accepted, but there's no notification showing. When I click on the notification icon, it shows this not even showing past notifications.
... View more
06-24-2024
08:28 AM
|
0
|
1
|
3033
|
|
POST
|
This has a few problem. SQL is picky about quotes, so you'll have to encase the entire thing in double quotes and use single quotes for each item. You have to use a single = sign. And you have to use "or" not "||" var filtered_pop = Filter($datapoint.sum_SUM_Population,
"Name = 'Shelby County' or Name = 'Tipton County' or ..." However, by using "in", you can make this much easier to read and much shorter. var filtered_pop = Filter($datapoint.sum_SUM_Population,
"Name in ('Shelby County', 'Tipton County', ...)"
... View more
06-24-2024
07:51 AM
|
1
|
1
|
1566
|
|
POST
|
Playground doesn't use a profile where you can use $layer. If you click on "Profile variables", it only shows "$feature". You'll have to test out your code in a web map where you have access to more profile variables.
... View more
06-21-2024
08:56 AM
|
1
|
1
|
1841
|
|
POST
|
I'm definitely not reading things closely enough! Just the injury field is Yes/No, so replace line 23 with attrs['fatal'] = f.number_dead;
... View more
06-20-2024
12:49 PM
|
1
|
1
|
2053
|
|
POST
|
That expression will work properly. Make sure that there is no expression or field in the "Choose attributes" section before saving your expression. Otherwise you'll get the "There was an error" message
... View more
06-20-2024
12:15 PM
|
0
|
0
|
1163
|
|
POST
|
Since you know which floor the feature is on, why run all the intersections? Just run it once according to the floor. // Check the value of the room level field: values are "base" "lowr" "uppr" "pent" "mezz"
var roomlevel = $feature.Room_Level
var floor = Decode(roomlevel,
"base", "BORG_Basement_Level",
"lowr", "BORG_LowerLevel",
"uppr", "BORG_UpperLevel",
"pent", "BORG_Penthouse",
"mezz", "BORG_Mezzanine")
var fs = FeatureSetByName($map, floor)
// Intersect the current location with the the level and
// get the first intersecting room
var location = First(Intersects($feature, fs));
iif(IsEmpty(location), null, location['room_id'])
... View more
06-20-2024
12:02 PM
|
1
|
0
|
1368
|
|
POST
|
I couldn't figure out a way to do that in the GroupBy statement alone, so give this a try where it creates new count fields for the two fields. I simplified it a bit so it wasn't writing all the attributes to the new FeatureSet, so see how it works. // sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');
// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;
// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating', 'collision_date'], true);
var fieldList = [];
Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
Push(fieldList, {"alias":"Fatal Total","editable":true,"length":4,"name":"fatal","nullable":true,"type":"esriFieldTypeInteger"})
Push(fieldList, {"alias":"Injury Total","editable":true,"length":4,"name":"injured","nullable":true,"type":"esriFieldTypeInteger"})
var temp_dict = {
fields: fieldList,
geometryType: '',
features: []
}
for (var f in crashFs) {
var attrs = {}
attrs['fatal'] = iif(f.number_dead == 'Yes', 1, 0);
attrs['injured'] = iif(f.gis_incapacitating == 'Yes', 1, 0);
attrs['collision_year'] = Year(f['collision_date'])
Push(
temp_dict['features'],
{attributes: attrs}
)
}
var newFS = FeatureSet(temp_dict);
var summaryFS = GroupBy(newFS, 'collision_year',
[
{name: 'Total Deaths', expression: 'fatal', statistic: 'SUM' },
{name: 'Total Injuries', expression: 'injured', statistic: 'SUM' } ]);
return summaryFS;
... View more
06-20-2024
11:31 AM
|
1
|
3
|
7178
|
|
POST
|
Two more changes. Line 8 should be var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating', 'collision_date'], true); and line 25 should attrs['collision_year'] = Year(f['collision_date'])
... View more
06-20-2024
08:41 AM
|
0
|
5
|
3704
|
|
POST
|
A few fixes I missed // sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');
// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;
// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);
function Memorize(fs) {
var fieldList = Schema(fs)['fields'];
Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
var temp_dict = {
fields: fieldList,
geometryType: '',
features: []
}
for (var f in fs) {
var attrs = {}
for (var attr in f) {
attrs[attr] = f[attr]
}
attrs['collision_year'] = Year(f['date'])
Push(
temp_dict['features'],
{attributes: attrs}
)
}
return FeatureSet(temp_dict);
}
var newFS = Memorize(crashFs)
var summaryFS = GroupBy(newFS, 'collision_year',
[
{name: 'Total Deaths', expression: 'number_dead', statistic: 'SUM' },
{name: 'Total Injuries', expression: 'gis_incapacitating', statistic: 'SUM' } ]);
return summaryFS;
... View more
06-20-2024
08:30 AM
|
0
|
7
|
3709
|
|
POST
|
Try this **Updated GroupBy expression // sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');
// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;
// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);
function Memorize(fs) {
var fieldList = Schema(fs)['fields'];
Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
var temp_dict = {
fields: fieldList,
geometryType: '',
features: []
}
for (var f in fs) {
var attrs = {}
for (var attr in f) {
attrs[attr] = f[attr]
}
attrs['collision_year'] = Year(f['date'])
Push(
temp_dict['features'],
{attributes: attrs}
)
}
return FeatureSet(theDict);
var newFS = Memorize(fs)
var summaryFS = GroupBy(newFS, 'collision_year',
[
{name: 'Total Deaths', expression: 'number_dead', statistic: 'SUM' },
{name: 'Total Injuries', expression: 'gis_incapacitating', statistic: 'SUM' } ]);
return summaryFS;
... View more
06-20-2024
07:39 AM
|
0
|
9
|
3725
|
|
POST
|
When posting code, use the "Insert/Edit code sample" button. It makes your code easier to read and provide line numbers in your code. Remember that I was using a different data set to show you how it would work, since I couldn't test it with your data and you were getting an execution error. Do you still get that error when using this? var summaryFS = GroupBy(newFS, 'collision_year',
[
{name: 'number_dead', expression: 'TotalDeaths', statistic: 'SUM' },
{name: 'gis_incapacitating', expression: 'TotalInjuries', statistic: 'SUM' }
]);
... View more
06-20-2024
06:43 AM
|
0
|
11
|
3729
|
|
POST
|
**Edit: updated for a better response. This is one way to do it var planzone = First(...
var rda = First(...
var output = `ADDITIONAL DETAILS<br><br>
Zoning: ${iif(!IsEmpty(planzone), planzone.Zoning, 'No')}<br><br>
RDA Boundary: ${iif(!IsEmpty(rda), rda.ENTITY, 'No')}`
return {
type: 'text',
text: output
} If you'd like a separate response if the feature falls outside both areas, you can use this instead var planzone = First(...
var rda = First(...
var output;
if (IsEmpty(rda) && IsEmpty (planzone)) {
output = "Feature is outside the Zoning and RDA areas"
} else {
output = `ADDITIONAL DETAILS<br><br>`
output += `Zoning: ${iif(!IsEmpty(planzone), planzone.Zoning, 'No')}<br><br>`
output += `RDA Boundary: ${iif(!IsEmpty(rda), rda.ENTITY, 'No')}`
}
return {
type: 'text',
text: output
} Note: pardon any typos. Using the Insert/edit code sample tool makes it easier to provide a good sample
... View more
06-17-2024
12:28 PM
|
1
|
1
|
2316
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|