Skip to content

Instantly share code, notes, and snippets.

@nekman
Last active December 28, 2015 18:48
Show Gist options
  • Save nekman/7545445 to your computer and use it in GitHub Desktop.
Save nekman/7545445 to your computer and use it in GitHub Desktop.
'use strict';
(function() {
var template = 'http://opendata-download-metfcst.smhi.se/api/category/pmp1g/version/1/geopoint/lat/{{lat}}/lon/{{lon}}/data.json';
function toUrl(coords) {
return template.replace(/{{lat}}/, coords.latitude)
.replace(/{{lon}}/, coords.longitude);
}
navigator.geolocation.getCurrentPosition(function(loc) {
var geoUrl = toUrl(loc.coords);
$.getJSON(geoUrl).then(function(data) {
console.log(data);
});
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment