Reflections on Lesson 6
Each lesson adds to our coding capabilities. Lesson 6 covers search and query capabilities and introduces us to promises. Likewise, with each lesson, the coding becomes more complex.
For this lesson, we were given a choice of scenarios. I selected the Historic Wildfire Perimeter Service. The assignment calls for users to be prompted to enter a year from 2000 to 2018. The app was designed with the following major components:
- Using the JavaScript prompt() method, the user is prompted to enter a year from 2000 to 2018 or all (or any alpha character) for all years. If a year outside the range, the user is prompted again. The data entered is assigned to a variable named “data.”
- The "data" variable is evaluated through several conditional arguments. If the data is within the range, a variable is created: whereClause = "FIREYEAR = '" + data + "'". If the user selected all data, the variable is: whereClause = "FIREYEAR >= 2000". The whereClause variable is used in a definitionExpression when the feature layer is being created.
- Once the user makes a valid selection, the JavaScript alert() method is used in connection with the .queryFeatureCount method to obtain a count of the selected features.
- The ClassBreaksRenderer is used with PolygonSymbol3D and ExrtudeSymbol3DLayer. Class breaks were developed by exploring the data in ArcGIS online. A five class “natural breaks” classification was used. Colors for the five classes are based on Color Brewer. The 5-class Yellow Orange Red sequential color scheme was deployed.
- Symbol extrusion provides perspective on the fire size.
- A number of widgets are added to the map: home, basemap gallery, legend, and search.
- Custom styling was undertaken for the popup, legend and title. This was handled in the main.css file, overriding the default values in the Esri stylesheet.
Lesson 6 provided an excellent introduction to searches and queries and how JavaScript can be used to create user prompts. Overall, the JavaScript prompt() method is not ideal for user interaction. As the lesson summary notes, “more sophisticated apps” will be explored in Lesson 7.