Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Last active December 10, 2015 15:38
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save niraj-shah/4456173 to your computer and use it in GitHub Desktop.
function success(position) {
// variable to store the coordinates
var location = position.coords.latitude + ',' + position.coords.longitude;
// select the span with id status
var s = $('#status');
// update the status message
s.html('found you!');
// Google Maps image using location
$('#wrapper').append('<img src="http://maps.google.com/maps/api/staticmap?center='+ location +
'&zoom=17&markers=size:medium|color:red|'+ location +
'&path=color:0x0000FF80|weight:2|'+ location +
'&size=480x360&sensor=false" />');
}
function error(msg) {
// select the span with id status
var s = $('#status');
// set the error message
s.html(typeof msg == 'string' ? msg : "failed");
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment