Skip to content

Instantly share code, notes, and snippets.

@bwiggs
Created July 29, 2016 02:00
Show Gist options
  • Save bwiggs/516bddbb0803141273e92b780febef93 to your computer and use it in GitHub Desktop.
Save bwiggs/516bddbb0803141273e92b780febef93 to your computer and use it in GitHub Desktop.
$(document).ready(function () {
var $loginBtn = $('#login');
var $signInView = $('.sign-in-view');
var $imageResultsView = $('.image-results-view');
// initialize the SDK with our API key
_500px.init({
sdk_key: '8626d07001b7482e7707a6248a3b28bcaf22fd23'
});
_500px.getAuthorizationStatus(function (status) {
if (status == 'authorized') {
load()
}
});
$loginBtn.on('click', function() {
_500px.login(function (status) {
if(status == 'authorized') {
load();
} else {
// not authorized
}
});
});
function load() {
$signInView.hide();
$imageResultsView.show();
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var radius = 50;
var geo = position.coords.latitude +
',' +
position.coords.longitude +
',' +
radius +
'mi';
console.log(geo);
_500px.api('/photos/search', {geo: geo}, function(response) {
console.log(response);
});
});
} else {
console.warn('browser doesnt support geolocation');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment