Three Ways Esri’s JavaScript API Saves You Time

Anyone who’s ever worked on a project during crunch time understands the feeling of wishing for more time. After all, time is the only resource you can’t get back once it’s been spent. Fortunately for GeoDevs working on the web, Esri’s JavaScript API can save you lots of time.

What is an API?

An API, or Application Programming Interface, is how an application can access a server. It provides a way to send and receive information and functionality between your application and a server in an easy-to-use format, usually JSON.

APIs help your software get the information you need more easily. (Image Source)

For example, say you built an application that got a all the tags for all of a user’s items in ArcGIS Online, and sorted those tags by most popular. You could sign into ArcGIS Online, view that user’s content, and manually make a list of all the items and their tags. However, this would be limited to what that user had shared with you, and your list would become out of date as soon as they edited any tags, added a new item, or deleted an old one.

Instead, you could use Esri’s JavaScript API and send it some information on the user in question. The API can check all of their items as they stand at the moment the request is processed. Then, it can return information on all of those items, including their tags. After that, all you have to do is tally them up. There’s no need to worry about sharing permissions or if the list is out of date!

Esri’s JavaScript API

Esri’s JavaScript API comes in two different versions – the 3.x API and the 4.x API. Both of these APIs are currently supported and in active development. They allow developers to build web applications with a number of features that make working with maps much simpler. The 4.x API allows developers to write applications that work with both 2D and 3D maps. The 3.x API only works for 2D mapping, but it has been around longer and has more features than the 4.x API. However, new functionality is being added to the 4.x API with each version, and it will eventually replace the 3.x API.

Saving Time with Esri’s JavaScript API

Security

Your data is important. As such, you want to make sure you can control who can access and edit that data. Therefore, authentication is an obvious first choice when looking at the benefits of working with this API. Using the OAuth and IdentityManager classes, information on the signed in user is included with almost every request automatically. This means there is almost no work needed in order to ensure that users can only access item and information they’re supposed. You can also control these settings using the 3.x version of the API. For more information, see our guide on OAuth 2.0 and ArcGIS.

Multi-Dimensional Applications

One of the big things about the 4.x JavaScript API is that it allows developers to use both 2-dimensional and 3-dimensional mapping at the same time. This is done using views and scenes, respectively. For a quick proof-of-concept, check out the example below.

While the example above just shows a 2D and 3D map displayed at the same time, the ability to use both together can be used in a variety of ways. For example, you could allow a user to navigate to a certain location on a globe using a 3D map, and update a 2D map to display the same location, or vice versa. This can allow users of an application to see data that may have been recorded only in 2D or 3D format along with data that is stored in another format. You could also create a 3D mapping application, but allow users to toggle to a 2D application if their network, browser, or device cannot handle processing a 3D mapping application. This would mean you can make a more versatile application rather than having to repeat your work and maintain two different versions of the same application.

Configuring Symbology

Maps are important because they can help people visualize data spatially. That’s why what goes on your maps, and how it’s represented is so important. While there are a lot of options for adjusting symbology in your webmaps, sometimes you find yourself in a situation where you need to generate custom symbols on the fly – that’s where Esri’s new DictionaryRenderer class comes in. Since this class is very new (it just came out in the 4.13 version of the ArcGIS API for JavaScript), it has some limitations. However, it is still in Beta and should be developed and expanded on in future versions of the API. It’s definitely something to keep an eye on.

The Dictionary Renderer will allow you to symbolize the features on your map using multiple attributes together. You can define and combine symbols, giving you an impressive degree of flexibility and control when displaying your data. Check out a cool example of how the class can be used to display different features at California gas stations to get some ideas on how you might use it.

Bonus Reads

Courtney Kirkham

Application Developer

Courtney is an enthusiastic and motivated GEODev with a focus on web development. She works as a member of our Professional Services team building custom Web Appbuilder Widgets and stand-alone applications. When not working, Courtney relaxes by gardening, practicing shotokan karate, and playing board games.