ArcGIS USNG & Lat-Long Scroll Readout

USNG & Lat-Long readout detailed instructions

This USNG readout in ArcGIS Server Web app works only if your underlying map is in a geographic coordinate system and not in a projected coordinate system.

First download these javascript files. Note that display_mapcoords.js is modified from the one available in the Add Map coordinate Display walkthrough. The second javascript is provided as is from Larry Moore’s USNG Google Maps Mashup.

“Note: A significant bug, affecting MGRS-to-lat/lng calculations in the first grid zone north of the equator, was discovered in the USNG.js module in December 2008″ – Larry Moore. The corrected script is available below obtained from Larry’s Website -Subu

display_mapcoords.js
usng.js

Attention: Step 5 & 6 of ESRI’s Walkthrough

In step 5 of the walkthrough, Add the following code in addition to what is listed there.

var latlng=[];

function toUSNG(lat, lng, precision) {

var latlngout = document.getElementById(‘latlngout’);

latlngout.innerText = latlngout.textContent = LLtoUSNG(lat, lng, precision);

}

function showLL(lng, lat) {

// window.status = “Long: ” + lng + ” Lat: ” + lat ;

var lngout = document.getElementById(“Label_X”);

var latout = document.getElementById(“Label_Y”);

lngout.innerText = lngout.textContent = lng ;

latout.innerText = latout.textContent = lat ;

}

<script language=”javascript” type=”text/javascript” src=”javascript/usng.js”></script>

Do remember to create three label controls – one for longitude called Label_X, one for latitude called Label_Y and one for USNG called “latlongout”.

In step 6 of the walkthrough, Use the display_mapcoords.js provided at the top of the page instead of the one in the walkthrough.