Skip to content

Instantly share code, notes, and snippets.

@SecureCloud-biz
Forked from niraj-shah/interactive_map.js
Created July 13, 2014 00:19
Show Gist options
  • Save SecureCloud-biz/06d7f961aa859a4092ce to your computer and use it in GitHub Desktop.
Save SecureCloud-biz/06d7f961aa859a4092ce 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;
// setup the map using user location
var mapOptions = {
center: new google.maps.LatLng( position.coords.latitude, position.coords.longitude ),
zoom: 16,
zoomControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// add map to the html
map = new google.maps.Map( document.getElementById("map-canvas"), mapOptions );
// setup the marker
var markers = new google.maps.Marker( {
position:mapOptions.center
});
// add market to the map
markers.setMap(map);
// select the span with id status
var s = $('#status');
// update the status message
s.html('found you!');
}
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