-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchange-bearing-map.html
185 lines (170 loc) · 5.91 KB
/
change-bearing-map.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Change the Bearing of a Map — Maps for HTML reference examples</title>
<link rel="stylesheet" href="examples.css">
<script src="api-keys.js"></script>
</head>
<body>
<h1>Examples for
<a href="../#use-case-change-bearing-map">Use Case: Change the Bearing of a Map</a>
</h1>
<p>
Those mapping APIs that allow the map view to be rotated,
in the sense of the projected view being rotated around the centre point
so that the bearing of the top of the map is not North,
usually allow this to be specified either when the map view is created and initialised
or later via an exposed property or method.
</p>
<p>
In the API examples the latter technique is used,
to demonstrate that the map view can be dynamically updated in this respect.
</p>
<details>
<summary>Jump to section…</summary>
<ul class="toc">
<li>Iframe embeds: <ul>
<li><a href="#google-maps-embed">Google Maps embed</a></li>
<li><a href="#openstreetmap">OpenStreetMap embed</a></li>
<li><a href="#bing-maps-embed">Bing Maps embed</a></li>
<li><a href="#mapbox-embed">Mapbox Studio embed</a></li>
</ul></li>
<li>Client-side frameworks: <ul>
<li><a href="#leaflet-js">Leaflet.js API</a></li>
<li><a href="#openlayers">OpenLayers API</a></li>
<li><a href="#google-maps-api">Google Maps Platform API</a></li>
<li><a href="#bing-maps-api">Bing Maps Control API</a></li>
<li><a href="#mapkit-js">MapKit JS (Apple Maps) API</a></li>
<li><a href="#mapbox-api">Mapbox GL JS API</a></li>
<li><a href="#tomtom">TomTom Maps SDK for Web with vector maps</a></li>
<li><a href="#d3-geo">D3 Geographies APIs</a></li>
</ul></li>
</ul>
</details>
<section id="google-maps-embed">
<h2>Google Maps embed</h2>
<p>Not applicable</p>
</section>
<section id="openstreetmap">
<h2>OpenStreetMap embed</h2>
<p>Not applicable</p>
</section>
<section id="bing-maps-embed">
<h2>Bing Maps embed</h2>
<p>Not applicable</p>
</section>
<section id="mapbox-embed">
<h2>MapBox Studio embed</h2>
<div>
<iframe width="600" height="450"
title="MapBox Studio"
src="https://api.mapbox.com/styles/v1/nchan0154/cjx9sxbqt08611cp94xvmkwu1.html?fresh=true&access_token=pk.eyJ1IjoibmNoYW4wMTU0IiwiYSI6ImNqeDlzd3BrNjAxcjAzeXFuMjdodGowbnMifQ.wmDpzNGfADuQOSn1dABh7A#2/0/0/45">
</iframe>
</div>
</section>
<section id="leaflet-js">
<h2>Leaflet.js (with OpenStreetMap tiles)</h2>
<p>Not applicable: Leaflet.js does not support any bearing other than North.</p>
</section>
<section id="openlayers">
<h2>OpenLayers with OpenStreetMap tiles</h2>
<div id="ol-osm-use-case-change-bearing-map" style="width: 600px; height: 450px;"></div>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css" type="text/css">
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<code class="script-example">
<script>
{
let map = new ol.Map({
view: new ol.View({
center: ol.proj.fromLonLat([6.055737, 46.233226]),
zoom: 3
}),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'ol-osm-use-case-change-bearing-map'
});
map.getView().setRotation(-45 * (Math.PI / 180));
}
</script>
</code>
</section>
<section id="google-maps-api">
<h2>Google Maps API</h2>
<p>Not applicable</p>
</section>
<section id="bing-maps-api">
<h2>Bing Maps Control API</h2>
<p>Not applicable</p>
</section>
<section id="mapkit-js">
<h2>MapKit JS (Apple Maps) API</h2>
<div id="mapkit-js-map" style="width: 600px; height: 450px;"></div>
<script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>
<code class="script-example">
<script>
{
let mapkitKey = m4h.keys.mapkit.maps4html;
if (self.location.hostname === 'localhost') {
if (self.location.protocol === 'https:') {
mapkitKey = m4h.keys.mapkit.httpslocalhost8000;
} else {
mapkitKey = m4h.keys.mapkit.localhost8000;
}
}
mapkit.init({
authorizationCallback: function(done) {
done(mapkitKey);
},
language: "en"
});
const center = new mapkit.Coordinate(0, 0),
span = new mapkit.CoordinateSpan(360, 180),
region = new mapkit.CoordinateRegion(center, span);
const map = new mapkit.Map(document.getElementById('mapkit-js-map'), {
region: region
});
map.rotation = -45;
}
</script>
</code>
</section>
<section id="mapbox-api">
<h2>Mapbox GL JS API</h2>
<div id="mapbox-api-map" style="width: 600px; height: 450px;"></div>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.0.0/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.0.0/mapbox-gl.js'></script>
<code class="script-example">
<script>
{
mapboxgl.accessToken = m4h.keys.mapboxGL;
let map = new mapboxgl.Map({
container: 'mapbox-api-map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [6.055737, 46.233226],
zoom: 3
});
map.setBearing(45);
}
</script>
</code>
</section>
<section id="tomtom">
<h2>TomTom Maps SDK for Web with vector maps</h2>
<p>Not applicable.</p>
</section>
<section id="d3-geo">
<h2>D3 Geographies APIs</h2>
***TODO<!--
Replace with code including link/external scripts. Custom script has <code class="script-example"> parent element.
or <p>Not applicable</p>
-->***
</section>
</body>
</html>