-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmap-vector.html
More file actions
127 lines (113 loc) · 6.01 KB
/
map-vector.html
File metadata and controls
127 lines (113 loc) · 6.01 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<title>Leaflet Examples</title>
<!-- Bootstrap core CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v1.1.1/maptiler-sdk.umd.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v1.1.1/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/leaflet-maptilersdk/v1.0.0/leaflet-maptilersdk.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-sm navbar-dark bg-dark" aria-label="Third navbar example">
<div class="container-fluid">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="me-2" viewBox="0 0 24 24"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
<strong>Leaflet Examples</strong>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarsExample03" aria-controls="navbarsExample03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExample03">
<ul class="navbar-nav me-auto mb-2 mb-sm-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="index.html">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown03" data-bs-toggle="dropdown" aria-expanded="false">Examples</a>
<ul class="dropdown-menu" aria-labelledby="dropdown03">
<li><a class="dropdown-item" href="map-simple.html">Simple Example</a></li>
<li><a class="dropdown-item" href="map-satellite.html">Satellite Layer</a></li>
<li><a class="dropdown-item" href="map-popup.html">Marker Popup</a></li>
<li><a class="dropdown-item" href="map-draggable.html">Draggable Marker</a></li>
<li><a class="dropdown-item" href="map-image.html">Overlay Image</a></li>
<li><a class="dropdown-item" href="map-geojson.html">GeoJSON Area</a></li>
<li><a class="dropdown-item" href="map-cluster.html">Clusters</a></li>
<li><a class="dropdown-item" href="map-fullscreen.html">Fullscreen</a></li>
<li><a class="dropdown-item" href="map-heatmap.html">Heatmap</a></li>
<li><a class="dropdown-item" href="map-vector.html">Vector Layer</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<main>
<section class="py-5 container">
<h1 class="fw-light">Vector Layer in Leaflet</h1>
<div class="row py-lg-5">
<style>
#map { height: 380px; }
</style>
<div id="map"></div>
</div>
<div class="row py-lg-5">
<div class="col-lg-12 col-md-8">
<p class="lead text-muted">View the source of this page to see how the map is created.The code to configure the MapTiler vector layer is also shown below:</p>
<pre>
const map = L.map('map').setView([54.17747885048963, -6.337641477584839], 16);
const tiles_url = "https://tileserver.openstreetmap.ie/styles/ga/style.json";
const mtLayer = L.maptilerLayer({
style: tiles_url,
language: 'ga',
maptilerLogo: false,
}).addTo(map);
</pre>
<p class="lead text-muted">Notice:</p>
<ul>
<li>The style property of the maptilerLayer uses a URL to a JSON file that includes the mbtiles/pdf and styles from the remote tileserver</li>
<li>The maptiler logo is dislayed even when set to false because Map Tiler <sup>1</sup></li>
<li>In the page source Leaflet CSS and JS is included as normal</li>
<li>In the page source Extra JS and CSS for MapTiler SDK</li>
<li>The language property can be changed to 'en' to display names of towns and streets in English rather than Irish</li>
<li>Before this will work on a new domain, the tileserver needs to be configured to accept requests from the domain</li>
</ul>
<p class="lead text-muted">
<sup>1</sup> MapTiler are a commercial company solely focused on making as much money as possible from the map community. My next task will be to try only freely-licensed alternatives.
</p>
<p>
</p>
</div>
</div>
</section>
</main>
<footer class="text-muted py-5">
<div class="container">
<p class="float-end mb-1">
<a href="#">Back to top</a>
</p>
<p class="mb-1"></p>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1/dist/js/bootstrap.min.js"></script>
<script>
const map = L.map('map').setView([0, 0], 1);
const myurl = "https://tileserver.openstreetmap.ie/styles/ga/style.json";
const mtLayer = L.maptilerLayer({
style: myurl,
language: 'ga',
center: [54.17747885048963, -6.337641477584839],
zoom: 16,
maptilerLogo: false,
}).addTo(map);
</script>
</body>
</html>