This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="wrapper"> | |
<!-- Page heading --> | |
<h1>Geolocation</h1> | |
<!-- Status --> | |
<p>Finding your location: <span id="status">checking...</span></p> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Google Maps JavaScript API --> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function success(position) { | |
} | |
function error(msg) { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(success, error); | |
} else { | |
error('not supported'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function success(position) { | |
} | |
function error(msg) { | |
} | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(success, error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// variable to store the coordinates | |
var location = position.coords.latitude + ',' + position.coords.longitude; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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" />'); |