Skip to content

Instantly share code, notes, and snippets.

@aubm
Last active May 17, 2016 09:44
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 aubm/2981addf238cecdbe9b5f58fbf989c38 to your computer and use it in GitHub Desktop.
Save aubm/2981addf238cecdbe9b5f58fbf989c38 to your computer and use it in GitHub Desktop.
Web cartography helpers
javascript:(function () {
var ul, br, validCoords = /^[+-]?\d+(\.\d+)?,[+-]?\d+(\.\d+)?$/;
do {
if (!(ul = window.prompt('Type in the value for UL (upper left) as lng, lat. Example: 58, 58'))) {
return;
}
if (!ul.replace(/ /g, '').match(validCoords)) {
console.log('Invalid format for UL, please type again');
ul = undefined;
}
} while(!ul);
do {
if (!(br = window.prompt('Type in the value for BR (bottom right) as lng, lat: Example: 45, 45'))) {
return;
}
if (!br.replace(/ /g, '').match(validCoords)) {
console.log('Invalid format for BR, please type again');
br = undefined;
}
} while(!br);
ul = ul.split(',');
br = br.split(',');
var bbox = '['+ul[0]+', '+br[1]+', '+br[0]+', '+ul[1]+']';
console.log('bbox: ' + bbox);
alert('Here is the bbox, it is also printed out in the console: ' + bbox);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment