|
POST
|
Hmmm... I can't reproduce this, they look the same to me: Map Viewer Classic: Web App Builder: But, notice that the first "linebreak" line in my popups is only half length (the last one, too)? If you look at your code, that makes sense: At the end of each iteration, you add a new line and linebreak, at the start you add linebreak. So for each iteration except the first, the dashed line on top will be 2 * linebreak. Looking at your popups, I don't see that behavior, so unless I'm missing something, this doesn't seem to be the code your popups use. Anyway, try a slightly different approach: var linebreak = "-------------------------"
var popupLines = [linebreak] // we're using an array to store the lines of the popup
for (var f in relatedrecords) {
// If SITEADDID is not empty, push it into the array
if (!IsEmpty(f.SITEADDID)){
Push(popupLines, "APN: " + f.SITEADDID)
}
// If FULLADDR is not empty, push it into the array
if (!IsEmpty(f.FULLADDR)){
Push(popupLines, f.FULLADDR)
}
// get the dashed line in
Push(popupLines, linebreak)
}
// Concatenate the array with NewLine and return
return Concatenate(popupLines, TextFormatting.NewLine)
... View more
08-10-2022
11:18 PM
|
1
|
2
|
3200
|
|
POST
|
I packed it all in one expression, you will probably have to extract this into multiple expressions. // load your survey
var survey_dict = {geometryType: "", fields: [{name: "DateCollected", type: "esriFieldTypeDate"}], features: [{attributes: {DateCollected: Number(Date(2022,7,1))}},{attributes: {DateCollected: Number(Date(2022,7,1))}},{attributes: {DateCollected: Number(Date(2022,7,2))}},{attributes: {DateCollected: Number(Date(2022,7,3))}},{attributes: {DateCollected: Number(Date(2022,7,3))}},{attributes: {DateCollected: Number(Date(2022,7,4))}},{attributes: {DateCollected: Number(Date(2022,7,4))}},{attributes: {DateCollected: Number(Date(2022,7,4))}},{attributes: {DateCollected: Number(Date(2022,7,6))}},{attributes: {DateCollected: Number(Date(2022,7,6))}},{attributes: {DateCollected: Number(Date(2022,7,8))}},{attributes: {DateCollected: Number(Date(2022,7,8))}},{attributes: {DateCollected: Number(Date(2022,7,10))}},{attributes: {DateCollected: Number(Date(2022,7,11))}},{attributes: {DateCollected: Number(Date(2022,7,11))}},]}
var survey = FeatureSet(Text(survey_dict))
//return survey
//var survey = FeatureSetByName(...)
// optionally, filter the survey
//survey = Filter(survey, "SurveyID IN (1, 2, 3)")
// abort if nothing was found
if(Count(survey) == 0) { return null }
// get first and last date
var first_date = First(OrderBy(survey, "DateCollected")).DateCollected
var last_date = First(OrderBy(survey, "DateCollected DESC")).DateCollected
// get the range in days
var range_days = DateDiff(last_date, first_date, "days") + 1
// get crazy binning the survey resonses into weekdays,
// counting the workdays, and days without response
var weekday_bins = [0, 0, 0, 0, 0, 0, 0]
var workdays = 0
var days_without_response = 0
var current_date = first_date
for(var i = 0; i < range_days; i++) {
var iso_day = IsoWeekday(current_date)
var responses = Filter(survey, "DateCollected = @current_date")
weekday_bins[iso_day-1] += Count(responses)
workdays += (iso_day < 6)
days_without_response += (Count(responses) == 0)
current_date = DateAdd(current_date, 1, "days")
}
var return_lines = [
`The survey was running from ${Text(first_date, "Y-MM-DD")} to ${Text(last_date, "Y-MM-DD")} (${range_days} days, ${workdays} work days).`,
`In this time, ${Count(survey)} responses were submitted. There were ${days_without_response} days without response.`,
`Mo: ${weekday_bins[0]}`,
`Tu: ${weekday_bins[1]}`,
`We: ${weekday_bins[2]}`,
`Th: ${weekday_bins[3]}`,
`Fr: ${weekday_bins[4]}`,
`Sa: ${weekday_bins[5]}`,
`Su: ${weekday_bins[6]}`,
]
return Concatenate(return_lines, TextFormatting.NewLine) The survey was running from 2022-08-01 to 2022-08-11 (11 days, 9 work days).
In this time, 15 responses were submitted. There were 3 days without response.
Mo: 4
Tu: 1
We: 3
Th: 5
Fr: 0
Sa: 2
Su: 0
... View more
08-10-2022
01:17 AM
|
2
|
11
|
4449
|
|
POST
|
Glad you found the error. Some IDEs only tell you the line where something went wrong, not the exact position. So while it can be satisfying to write one-liners (I'm very guilty of that in Python) they make it hard to find the problem (plus, they are hard to read, and line-wrap doesn't make it better...). if(Find('STATE OF IOWA, I', $feature.STATE_ROUT) > -1) {
return Split($feature.STATE_ROUT, ' ', 5, true)[4]
}
if(Find('STATE OF IOWA, I', $feature.STATE_RO_1)> -1) {
return Split($feature.STATE_RO_1, ' ', 5, true)[4]
}
return 'DefaultValue' You're right, the expression shouldn't work for interstates, either. I have not the faintest clue why it would have worked, but: Did it actually work (did you see the correct labels)? Does it still work? Have you revalidated the expression (pressed on the checkmark button)?
... View more
08-09-2022
06:00 AM
|
0
|
2
|
2524
|
|
POST
|
For each of the attributes, run the Calculate Field tool on your polygon fc. Switch to Arcade, copy and edit the code below. // load your points
var point_fc = FeatureSetByName($datastore, "NameOfYourPointFC")
// get the point contained by the polygon
var contained_point = First(Contains($feature, point_fc))
// return null if there is no point
if(contained_point == null) return null
// else return the point's attribute
return contained_point.FieldName
... View more
08-09-2022
05:33 AM
|
0
|
0
|
2357
|
|
POST
|
current_setting = arcpy.env.addOutputsToMap
arcpy.env.addOutputsToMap = False
# your code
arcpy.env.addOutputsToMap = current_setting
... View more
08-08-2022
03:18 AM
|
3
|
0
|
1877
|
|
POST
|
Something like this could do what you want (not tested): // Calculation Attribute Rule
// field: e (Text)
// triggers: Insert, Update, Delete
// write "INSERT" or "DELETE" into e
if $editcontext.editType != "UPDATE" {
return $editcontext.editType
}
// define the fields you want to check
var checked_fields = ["a", "b", "c", "d"]
// build an array of fields where the value changed
var changed_fields = []
var old_attributes = Dictionary(Text($originalfeature)).attributes
var new_attributes = Dictionary(Text($feature)).attributes
for(var f in checked_fields) {
var field = checked_fields[f]
if(old_attributes[field] != new_attributes[field]) {
Push(changed_fields, field)
}
}
// compare geometry
if(!Equals(Geometry($originalfeature), Geometry($feature))) {
Push(changed_fields, "geometry")
}
// concatenate the field names into a string and write that into e
return Concatenate(changed_fields, ", ")
... View more
08-08-2022
03:12 AM
|
0
|
0
|
1091
|
|
POST
|
You're using Text() on a feature, which returns a json string containing info about the geometry and attributes of the feature. What you want to do is extracting the fields of the feature, not the whole feature. You're not adding to your popupText sring. Instead you reassign a new value to it each time, which is why you only see one line as a result. There's no need to call Text() here. Your fields are all strings, the number format won't do anything. What you could do is using DefaultValue() to insert some meaningful text if there's a null value in a field. var popupLines = [
"Age: " + DefaultValue(cou.age, "not reported"),
"Gender: " + DefaultValue(cou.gender, "not reported"),
"Race: " + DefaultValue(cou.race, "not reported"),
]
return Concatenate (popupLines, TextFormatting.NewLine)
// or comma sepated:
// return Concatenate(popupLines, ", ")
... View more
08-08-2022
02:57 AM
|
0
|
0
|
1819
|
|
POST
|
Is your data in the right coordinate system? From AreaGeodetic: Support is limited to geometries with a Web Mercator (wkid 3857) or a WGS 84 (wkid 4326) spatial reference. Does it work if you use Area instead?
... View more
08-05-2022
12:53 AM
|
0
|
0
|
2303
|
|
POST
|
I mean, 1000 seems like a good number, most users won't get there. But for active users it's only a matter of time. I guess it only makes sense that you hit that limit first 🙂 I've uploaded 350 images in my 1.5 years as active user, so I still have some way to go, but it ramps up quickly. Do I have to go into my old posts and delete the images from them? I hope not. Few things are worse than finding a question with the same rare problem you have and an answer "See screenshot" followed by a broken image... Maybe I need to chill out with the screenshots Noooo. "A picture says more than a thousand words". In many situations it's far easier to show a screenshot than to describe it in words. Hopefully this limit can be set per user. Another thousand should probably be enough for the next year or so 🙂
... View more
08-05-2022
12:32 AM
|
0
|
0
|
4372
|
|
POST
|
I tested it on a table without ObjectID field... I edited the code in my original comment, so that it skips copying ObjectID and GlobalID fields (line 20).
... View more
08-04-2022
01:11 AM
|
1
|
1
|
3306
|
|
POST
|
Not out of the box, but it's possible with a little Python. This is only for x and y, because I have no clue about vertical reference. def xy_to_point_enhanced(in_table, x_field, y_field, epsg_field, out_fc, out_epsg):
"""Converts tabular coordinates into a point feature class, analogous to XY Table To Point. coordinates can be from different coordinate systems.
in_table: str, path to the input table or table name in map
x_field, y_field, epsg_field: str, names of the coordinate fields and the field that contains the epsg code
out_fc: str, path of the output point feature class
out_epsg: epsg code of the output feature class
"""
from pathlib import Path
import arcpy
out_ws = str(Path(out_fc).parent)
out_name = str(Path(out_fc).name)
out_sr = arcpy.SpatialReference(out_epsg)
in_fields = arcpy.ListFields(in_table)
# create output feature class
arcpy.management.CreateFeatureclass(out_ws, out_name, "POINT", spatial_reference=out_sr)
for f in in_fields:
if f.type not in ["OID", "GlobalID"]:
arcpy.management.AddField(out_fc, f.name, f.type)
# fill output feature class
field_names = [f.name for f in in_fields]
with arcpy.da.InsertCursor(out_fc, field_names + ["SHAPE@"]) as icur:
with arcpy.da.SearchCursor(in_table, field_names) as scur:
for row in scur:
row_dict = dict(zip(field_names, row))
# create a point geometry from the input coordinates
in_sr = arcpy.SpatialReference(row_dict[epsg_field])
in_point = arcpy.PointGeometry(arcpy.Point(row_dict[x_field], row_dict[y_field]), in_sr)
# project the point geometry to the output coordinate system
out_point = in_point.projectAs(out_sr)
# insert the row values and the new geometry into the feature class
icur.insertRow(list(row) + [out_point])
# and then you can call it like this
xy_to_point_enhanced("TestTable", "X", "Y", "EPSG", "memory/TestPoints", 25832)
... View more
08-03-2022
02:02 AM
|
1
|
4
|
3353
|
|
POST
|
In lines 17 and 21, you're using rStores instead of nrStores, that might be it...
... View more
08-02-2022
10:31 PM
|
0
|
0
|
1014
|
|
POST
|
This might be because the Arcade Geometry Functions are dependant on view scale: note that geometries fetched from feature services, especially polylines and polygons, are generalized according to the view's scale resolution. Be aware that using a feature's geometry (i.e. $feature) as input to any geometry function will yield results only as precise as the view scale. Therefore, results returned from geometry operations in the visualization and labeling profiles may be different at each scale level.
... View more
08-01-2022
11:18 PM
|
0
|
0
|
1368
|
|
POST
|
Could this be because it is a pdf? Yes. The popup image section is basically a GUI wrapper for the HTML <img src="{expression/expr0}"> img tags can only show images, not pdf. To show pdf, you can try using the embed tag (don't know if this is blocked or not): <embed src="{expression/expr0}"></embed> or you can try iframe: <iframe src="{expression/expr0}"></iframe> If these don't work, you're probably stuck with just showing the link: <a href="{expression/expr0}">Click this link!</a>
... View more
08-01-2022
11:01 PM
|
0
|
0
|
3459
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-30-2023 09:57 AM | |
| 1 | 05-18-2023 12:51 AM | |
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|