1
1
< meta name ="viewport " content ="width=620 " />
2
2
< title > geolocation</ title >
3
- < script type ="text/javascript " src ="http ://maps.google.com/maps/api/js?sensor=false "> </ script >
3
+ < script type ="text/javascript " src ="https ://maps.google.com/maps/api/js?sensor=false "> </ script >
4
4
< article >
5
5
< p > Finding your location: < span id ="status "> checking...</ span > </ p >
6
6
</ article >
7
7
< script >
8
8
function success ( position ) {
9
9
var s = document . querySelector ( '#status' ) ;
10
-
10
+
11
11
if ( s . className == 'success' ) {
12
- // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back
12
+ // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back
13
13
return ;
14
14
}
15
-
15
+
16
16
s . innerHTML = "found you!" ;
17
17
s . className = 'success' ;
18
-
18
+
19
19
var mapcanvas = document . createElement ( 'div' ) ;
20
20
mapcanvas . id = 'mapcanvas' ;
21
21
mapcanvas . style . height = '400px' ;
22
22
mapcanvas . style . width = '560px' ;
23
-
23
+
24
24
document . querySelector ( 'article' ) . appendChild ( mapcanvas ) ;
25
-
25
+
26
26
var latlng = new google . maps . LatLng ( position . coords . latitude , position . coords . longitude ) ;
27
27
var myOptions = {
28
28
zoom : 15 ,
32
32
mapTypeId : google . maps . MapTypeId . ROADMAP
33
33
} ;
34
34
var map = new google . maps . Map ( document . getElementById ( "mapcanvas" ) , myOptions ) ;
35
-
35
+
36
36
var marker = new google . maps . Marker ( {
37
- position : latlng ,
38
- map : map ,
37
+ position : latlng ,
38
+ map : map ,
39
39
title :"You are here! (at least within a " + position . coords . accuracy + " meter radius)"
40
40
} ) ;
41
41
}
44
44
var s = document . querySelector ( '#status' ) ;
45
45
s . innerHTML = typeof msg == 'string' ? msg : "failed" ;
46
46
s . className = 'fail' ;
47
-
47
+
48
48
// console.log(arguments);
49
49
}
50
50
54
54
error ( 'not supported' ) ;
55
55
}
56
56
57
- </ script >
57
+ </ script >
0 commit comments