Last active
August 29, 2015 14:10
-
-
Save nixta/dbf65c36e465245fd744 to your computer and use it in GitHub Desktop.
Bookmarklets for the ArcGIS Online viewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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