-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgeolocation.html
48 lines (41 loc) · 1.46 KB
/
geolocation.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Map:Geolocation</title>
<style>html,body{height:100%;}body{padding:0;margin:0;}h1{padding:0;margin:0;font-size:50%;}</style>
</head>
<body>
<!-- MAP[START] -->
<h1>Map:Geolocation</h1>
<div id="myMap" style='width:60%;height:70%;float:left;'></div>
<!-- MAP[END] -->
<script src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[ *** YOUR MY KEY *** ]' async defer></script>
<script src="../js/BmapQuery.js"></script>
<script>
//****************************************************************************************
// BingMaps&BmapQuery
//****************************************************************************************
//Init
function GetMap(){
//------------------------------------------------------------------------
//1. Instance
//------------------------------------------------------------------------
const map = new Bmap("#myMap");
//------------------------------------------------------------------------
//2. geolocation: Display Map
// map.geolocation(function(data:object){...});
//------------------------------------------------------------------------
map.geolocation(function(data) {
//location
const lat = data.coords.latitude;
const lon = data.coords.longitude;
//Map
map.startMap(lat, lon, "load", 10);
//pin
map.pin(lat,lon,"#ff0000");
});
}
</script>
</body>
</html>