// Japanese Knotweed pop-up content for location id/name // If the value in the "Loc_ID" field is empty, then the value "No value" will appear in the pop-up. // Otherwise, the value in the "Loc_ID" field will appear. return DefaultValue($feature.Loc_ID, "No value"); --------------------------------------------------------------------------------- // Display the length of the trail in miles using a math equation to convert feet to miles. // This can save you from maintaining multiple fields related to length or areal units. // length of trail in feet using the native "Shape_Length" field var length_feet = $feature["Shape_Length"]; // length of trail in miles // use a simple math equation var length_miles = length_feet / 5280; // round length in miles to 2 decimal places // this helps make the displayed values more presentable to the general public var rounded_length_miles = Round(length_miles, 2); // use "return" keyword to set value in pop-up return rounded_length_miles; --------------------------------------------------------------------------------- // Setting the display value for a Vehicle Crash based upon a numeric code. // crash data file contains numeric codes. an associated pdf file maps the codes to textual descriptions // Collision Type field var code = $feature.COLLISION_TYPE; // set text value based upon code value // first argument is the field or variable you want to run the decode operation on // last argument is a default value to return if no matches are found in dataset var decodedValue = Decode(code, 0, 'Non-collision', 1, 'Rear-end', 2, 'Head-on', 3, 'Backing', 4, 'Angle', 5, 'Sideswipe (same dir.)', 6, 'Sideswipe (Opposite dir.)', 7, 'Hit fixed object', 8, 'Hit pedestrian', 9, 'Other or Unknown', 'Not specified'); // return value for popup return decodedValue; --------------------------------------------------------------------------------- // Create a label expression for a Roads Centerline layer where the road name components are in multiple fields. // The component fields will be combined into a single value to display. // Additionally, we will make sure that the value is not empty. // If it is empty, we will display an empty string (''). // If it's not empty, we'll display the value in the field. // the road pre-directional (i.e, "North", "South") var road_prefix = IIf(IsEmpty($feature["LSt_PreDir"]), '', $feature["LSt_PreDir"]); // the road name (i.e., "Main", "Market") var road_name = IIf(IsEmpty($feature["LSt_Name"]), '', $feature["LSt_Name"]); // the road type (i.e., "Street", "Lane") var road_suffix = IIf(IsEmpty($feature["LSt_Type"]), '', $feature["LSt_Type"]); // the road post-directional (i.e, "West", "East") var road_postdir = IIf(IsEmpty($feature["LSt_PosDir"]), '', $feature["LSt_PosDir"]); // combined the seperate name components into a single variable // there will be a space (' ') between each component // Examples include "W Main Street", "Market Street", "Apple Lane South" var road_label = Concatenate([road_prefix, road_name, road_suffix, road_postdir], ' '); // it's good practice to use the "return" keyword return road_label; --------------------------------------------------------------------------------- // perform an intersect spatial analysis between a hiking trails layer and PA house districts layer // display the PA house district(s) that intersect the trail in the trail's popup // if no house district(s) intersect trail, display a default message in popup // pa house districts layer in web map var pa_house_districts = FeatureSetById($map, /* PA House Districts */ "legislativedistrictshouse_4815"); // result of intersect function // returns pa house district feature[s] that intersects hiking trail var intersect_analysis = Intersects($feature, pa_house_districts); // count of features from intersect analysis var count_result = Count(intersect_analysis); // if there are intersecting pa house district features process results if (count_result > 0) { // container variable for each set of results var result_text = ''; // loop through all results of intersect analysis // reference fields from pa house district layer for (var feature in intersect_analysis) { var first_name = feature.H_FIRSTNAME; var last_name = feature.H_LASTNAME; var district = feature.LEG_DISTRICT_NO; var party = feature.PARTY; // group text and append to result variable result_text += first_name + ' ' + last_name + ' ; District: ' + district + ' ; Party: ' + party + TextFormatting.NewLine; } // if no house districts intersect trail, display message } else { return 'No Pennsylvania State House district intersects this trail feature'; } return result_text;