-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo-basic.html
92 lines (73 loc) · 2.55 KB
/
demo-basic.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<html>
<head>
<title>HERE Generic map</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<link rel="stylesheet" type="text/css" href="../dist/css/heremap.css" />
</head>
<body>
<div id="map"></div>
<script src="../dist/libhere.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../dist/heremap.min.js" type="text/javascript" charset="utf-8"></script>
<!-- convenient way to define APP_ID and APP_CODE and bnot expose it to the whole world... -->
<script src="credentials.js" type="text/javascript" charset="utf-8"></script>
<!-- our business logic -->
<script>
var hm = window.heremap;
function initMap() {
//configure APP_ID and APP_CODE
hm.config({
app_id: APP_ID,
app_code: APP_CODE,
});
hm.getAvailableMapStyle().then(style => {
console.log("Style ", style);
});
// show map fragment
// to see console message, open debugger window
hm.map(
"map", {
zoom: 6,
scheme:"satellite.day",
viewChange: (zoom, coord) => {
console.log("viewchange", zoom, coord)
},
click: (coord, button, key) => {
console.log("click", coord, button, key)
},
keydown: (key) => {
console.log("key down", key)
}
}
);
};
async function drawSomeStuff() {
// add a simple marker on Paris
hm.marker({
coord: [48.85, 2.3]
});
// show a route from lille to Bordeaux
const lille = await hm.geocode("lille, France");
const bordeaux = await hm.geocode("bordeaux, France");
hm.marker({
coord: lille.coord,
svg: "@svg/marker.svg",
color: "green",
size: "21x27"
});
hm.marker({
coord: bordeaux.coord,
svg: "@svg/marker.svg",
color: "red",
ratio: 2
});
const route = await hm.route(lille.coord, bordeaux.coord);
hm.polyline({
coords: route.coords
});
}
initMap();
drawSomeStuff();
</script>
</body>
</html>