-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (35 loc) · 1.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Geo Location</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript" src="cordova.js"></script>
<script src="http://maps.google.com/maps/api/js" type="text/javascript"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', getLocation);
function getLocation(){
navigator.geolocation.getCurrentPosition(onSuccess, onError, { timeout: 30000 });
}
function onSuccess(position) {
var lat=position.coords.latitude;
var lang=position.coords.longitude;
//Google Maps
var myLatlng = new google.maps.LatLng(lat,lang);
var mapOptions = {zoom: 4,center: myLatlng}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker = new google.maps.Marker({position: myLatlng,map: map});
}
function onError(error) {
alert('code: ' + error.code + '\n' +'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>