Using the WGS 84 Coordinate System in ArcGIS JavaScript Maps

Web Mercator is the standard for online interactive maps. It has been the standard since Google Maps first used it in 2005.

In the ArcGIS Maps SDK for JavaScript, Web Mercator basemaps are built-in and can be referenced by name. The data for the built-in basemaps can be found in Basemap.js. Here’s a JavaScript demo showing that raw data:

And here are those basemaps in a Basemap Gallery:

But what if we want to use the EPSG 4326 spatial reference, using latitude/longitude. Basemaps in that spatial reference are not built-in to the SDK.

We’ll first need some basemaps in that spatial reference. Esri maintains an ArcGIS Online group that contains EPSG 4326 (WGS 84) vector tile basemaps. To create a Basemap instance in the SDK, all we need is the Web Map item ID. So we’ll query the group, get the IDs, build the Basemap instances, and pass the array of Basemaps to the Basemap Gallery:

Can you see the difference between the two spatial references? In EPSG 4326, the United States looks wider than when using Web Mercator. Here’s an easier way to compare - swapping between the two:

With great power comes great responsibility!

Now that you know how to do it, should you? Probably not. Web Mercator is standard for interactive web mapping applications for many reasons. It is not that great either, but it’s the best we have for the web.

Are you using EPSG 4326 (WGS 84) in your web apps? I’d love to hear about where you’ve found use for this pattern.

Get an email summary of my blog posts (four per year):

Join email newsletter

... or follow the blog here:

See Also