To create web applications with the ArcGIS API for JavaScript, you do not necessarily need programming skills. Often it is enough to understand public code examples and adapt them. Today I want to focus on a tool that is very helpful when creating web applications: the Sandbox. With it, you can easily and clearly test codes in the browser while servers and data remain unchanged.<\/P>
<\/P>
Let's take a look at the code examples<\/A> on the pages of the ArcGIS API for JavaScript. The examples are thematically organized, for example by analysis, geocoding, or routing. When clicking on one of the examples, you almost always have the option Explore in the Sandbox. Selecting this option opens the Sandbox as a split viewer: on the left appears the code, on the right the application. If you change the code on the left, you see on the right in the application what effect the code changes have.<\/P><\/P>
On the website for this example there is a description of what happens in the application with the current code: When clicking on the map, it is calculated using a geoprocessing service provided by Esri which areas are visible from the clicked point with a visibility range of 5 miles. The map center is located in California when loading the document and the basemap is a street map.<\/P>
I now want to adapt the map to my needs: Let's assume today in the Alps there is visibility of 20 kilometers. I am interested in which areas I can see if I now climb Zugspitze. To determine the coordinates of Zugspitze and any other point on Earth, we can use this helpful
First, I want to move the map center from San Diego to Zugspitze. The center of the map is defined in the parameter center, which always contains geographic X and Y coordinates. I change the value center: [-122.436, 37.73] to center: [10.99393, 47.42118], i.e., the coordinates of Zugspitze. If I now click on the orange RUN button at top right, the changes in code are applied and the map center changes directly in the map window. To now display a topographic map instead of a street map as basemap, we change basemap: "streets" to basemap: "topo".<\/P>
Now I want to make changes to visibility distance that are passed to the
vsDistance.distance = 5;<\/P>
vsDistance.units = "esriMiles";<\/P>
Now I just have to change values at distance to 20 and units to "esriKilometers". Of course, the layout of the map can be further changed arbitrarily. For example, I can modify in tag <div id="info" class="esriSimpleSlider">the content of text field at bottom left on map so that users of application know exactly what to expect.<\/P>
As soon as I am finished and satisfied with changes to application, I can download code. The HTML file with JavaScript code shown on left side of Sandbox can now be made available as functional application on internet. Reminder: For this I did not have to write code from scratch and design application but only make a few changes in existing code. Also, I did not need any software for this—just a web browser.<\/P>
An overview of freely available geometry services from Esri that can be integrated into JavaScript applications is available
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.