AnsweredAssumed Answered

Map Units Please?

Question asked by Larry_Stout on Apr 11, 2014
Latest reply on Apr 11, 2014 by drc_
I am going to describe functionality I have built into my version of the Esri Flex Viewer to illustrate why I need to get the Map Units (or the toMeterFactor) from the JavaScript API so I can enable the same functionality in a JavaScript Viewer.

The programming languages (Flex and JavaScript) are different, but the reason I need the Map Units and the functionality I am implementing are the same.

1. When the user clicks on a feature, I show a popup with several tabs.  One of the tabs shows the measurements of the feature area and perimeter for polygons, length for polylines, and coordinates for points.  If the feature was a polygon or a polyline, the popup also shows the coordinates of the point clicked.  In both cases, the user can change the spatial reference of the coordinates or the units of the length and area units.  I call the geometry service to convert the coordinates to a different spatial reference.  If the spatial reference is Web Mercator or Geographic, I can calculate the area and length on the client.  If the spatial reference is projected, I can also calculate the area and length on the client, but I need the map units or the ratio of the units to meters to do that.
2. We use the same popup (not an Esri popup, but our own Flex popup) in the Identify and the Search Widget results.
3. We also need the map units to calculate area and length dynamically in the Draw Widget.
4. We have enhanced the Print Widget to show a graphic on the screen that represents the paper size selected for the print.  It lets the user see what will be printed rather than guess what will be printed.  In this widget, we have to do an approximate projection of the paper into the map coordinate system.  We do this on the client, because the user can drag the paper around the map.

You can see all of these widgets in our "last" Flex Viewer here:

I have started porting some of this functionality to a couple of different JavaScript Viewers, my version of the Dave Spriggs Configurable JavaScript Viewer that I got from GitHub (, and the Stem App JavaScript Viewer that is part of WebApp Builder (  These implementations are a little rough right now, so be gentle.  The Widget is called Print Plus in the JavaScript Viewers.