Created
November 9, 2010 15:11
-
-
Save andreia/669201 to your computer and use it in GitHub Desktop.
Geolocation using W3C Geolocation API - http://dev.w3.org/geo/api/spec-source.html
This file contains 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
<html> | |
<head> | |
<title>Example: Geolocation using W3C Geolocation API</title> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> | |
<script type="text/javascript"> | |
function initialize(){ | |
var myOptions = { zoom: 8, mapTypeId: google.maps.MapTypeId.HYBRID }; | |
var map = new google.maps.Map(document.getElementById("map"), myOptions); | |
if(navigator.geolocation){ | |
navigator.geolocation.getCurrentPosition(function(position){ | |
var currentLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); | |
map.setCenter(currentLocation); | |
var marker = new google.maps.Marker({ position: currentLocation, map: map, title:"you are here" }); | |
}); | |
} | |
} | |
</script> | |
</head> | |
<body onload="initialize()"> | |
<div id="map" style="height: 100%;"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment