-
Notifications
You must be signed in to change notification settings - Fork 158
/
openlayers-tiles.html
91 lines (76 loc) · 1.8 KB
/
openlayers-tiles.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OpenLayers Vector Tiles</title>
<!-- CSS/JS for OpenLayers map -->
<link rel="stylesheet" href="https://openlayers.org/en/v6.1.1/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v6.1.1/build/ol.js"></script>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
width: 100%;
font-family: sans-serif;
}
#meta {
background-color: rgba(255,255,255,0.75);
color: black;
z-index: 2;
position: absolute;
top: 10px;
left: 20px;
padding: 10px 20px;
margin: 0;
}
</style>
</head>
<body>
<div id="meta">
<h2>OpenLayers Tile Map</h2>
<ul>
<li><a href="https://openlayers.org/">OpenLayers</a></li>
</ul>
</div>
<div id="map"></div>
<script>
var vectorServer = "http://localhost:7800/";
var vectorSourceLayer = "public.ne_50m_admin_0_countries";
var vectorProps = "?properties=name,type,pop_est"
var vectorUrl = vectorServer + vectorSourceLayer + "/{z}/{x}/{y}.pbf" + vectorProps;
var vectorStyle = new ol.style.Style({
stroke: new ol.style.Stroke({
width: 2,
color: "#ff00ff99"
}),
fill: new ol.style.Fill({
color: "#ff00ff33"
})
});
var vectorLayer = new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
url: vectorUrl
}),
style: vectorStyle
});
var baseLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: "https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png"
})
});
var map = new ol.Map({
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
}),
layers: [baseLayer, vectorLayer]
});
</script>
</body>
</html>