-
Notifications
You must be signed in to change notification settings - Fork 0
/
gps.html
74 lines (60 loc) · 1.91 KB
/
gps.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>GPS</title>
<!--
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6/prototype.js"></script>
-->
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function(){
var main = document.getElementById('main');
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(pos) {
//main.innerHTML = pos.coords.latitude + "," + pos.coords.longitude;
var position = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
//document.getElementById('latitude').val("a" + pos.coords.latitude);
$('#latitude').val(pos.coords.latitude);
$('#longitude').val(pos.coords.longitude);
//マップのオプション
var options = {
zoom: 18,
center: position,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scaleControl: true
};
var map = new google.maps.Map(document.getElementById("main"), options);
//Markerの作成
var marker = new google.maps.Marker({
map: map,
position: position,
clickable: true,
draggable: false,
flat: false,
visible: true,
});
//InfoWindowの作成
var info = new google.maps.InfoWindow({
content: '<img src="sms.png"/>',
position: position,
});
info.open(map, marker);
});
} else {
main.innerHTML ="??";
}
});
</script>
</head>
<body>
<form action="#" method="POST">
latitude:<input type="text" name="latitude" id="latitude" value=""/>
longitude:<input type="text" name="longitude" id="longitude" value=""/>
<input type="submit" value="送信"/>
</form>
<div id="main" style="width:800px; height:600px">
</div>
</body>
</html>