Skip to content

Instantly share code, notes, and snippets.

@nixta
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nixta/dbf65c36e465245fd744 to your computer and use it in GitHub Desktop.
Save nixta/dbf65c36e465245fd744 to your computer and use it in GitHub Desktop.
Bookmarklets for the ArcGIS Online viewer
if (typeof arcgisonline !== 'undefined' && arcgisonline.map.main.map !== null) {
var m = arcgisonline.map.main.map,
c = m.extent.getCenter();
alert('Scale = 1 : ' + m.getScale() +
'\nZoom Level = ' + m.getZoom() +
'\nCenter = ' + c.x + ', ' + c.y +
'\nLat,Lon = ' + c.getLatitude() + ', ' + c.getLongitude());
} else {
alert('Use this bookmark while viewing a map at ArcGIS.com!');
}
var cookies = document.cookie.split('; '),
authIndex = -1;
for (var i = 0; i < cookies.length; i++) {
if (cookies[i].indexOf('esri_auth') === 0) {
authIndex = i;
break;
}
}
if (authIndex === -1) {
alert('Could not find esri_auth cookie!');
} else {
authIndex = JSON.parse(window.decodeURIComponent(cookies[authIndex].split('=')[1]));
if (authIndex.token !== undefined) {
alert('Token found:\n' + authIndex.token);
console.log(authIndex.token);
} else {
alert('No token found in esri_auth');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment