index.html
1.72 KB
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
<!doctype html>
<!-- Copyright (c) 2015 Google Inc. All rights reserved. -->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Google Map demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../google-map.html">
<link rel="import" href="../google-map-marker.html">
<link rel="import" href="../google-map-directions.html">
<style>
body {
margin: 0;
height: 100vh;
}
#controlsToggle {
position: absolute;
left: 10%;
bottom: 10%;
}
</style>
</head>
<body fullbleed>
<!-- Note: places library needs to be loaded because we're using google-map-directions
which also loads the maps lib with the places library. -->
<google-map latitude="37.779" longitude="-122.3892" min-zoom="9" max-zoom="11"
language="en" libraries="places">
<google-map-marker latitude="37.779" longitude="-122.3892"
title="Go Giants!" draggable="true">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/San_Francisco_Giants_Cap_Insignia.svg/200px-San_Francisco_Giants_Cap_Insignia.svg.png" />
</google-map-marker>
</google-map>
<google-map-directions start-address="Oakland" end-address="Mountain View"
language="en"></google-map-directions>
<button id="controlsToggle" onclick="toggleControls()">Toggle controls</button>
<script>
var gmap = document.querySelector('google-map');
gmap.addEventListener('api-load', function(e) {
document.querySelector('google-map-directions').map = this.map;
});
function toggleControls() {
gmap.disableDefaultUi = !gmap.disableDefaultUi;
}
</script>
</body>
</html>