basic.html
3.1 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
<html>
<head>
<title>Basic</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../libs/leaflet/dist/leaflet.css"/>
<style>
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="../libs/jquery/dist/jquery.min.js"></script>
<script src="../libs/leaflet/dist/leaflet.js"></script>
<script src="../node_modules/pbf/dist/pbf.js"></script>
<script src="../src/point-geometry.js"></script>
<script src="../src/vectorTileFeature.js"></script>
<script src="../src/vectorTileLayer.js"></script>
<script src="../src/vector-tile.js"></script>
<script src="../src/MVTUtil.js"></script>
<script src="../src/StaticLabel.js"></script>
<script src="../src/MVTFeature.js"></script>
<script src="../src/MVTLayer.js"></script>
<script src="../src/MVTSource.js"></script>
<script>
var debug = {};
var map = L.map('map').setView([0, 0], 1); // africa
L.tileLayer('http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
maxZoom: 18,
id: 'examples.map-i86knfo3'
}).addTo(map);
var mvtSource = new L.TileLayer.MVTSource({
//url: "http://spatialserver.spatialdev.com/services/vector-tiles/GAUL_FSP/{z}/{x}/{y}.pbf",
url: "http://172.26.60.12/osm08/{z}/{x}/{y}.pbf",
debug: false,
clickableLayers: ["GAUL0"],
getIDForLayerFeature: function(feature) {
return feature.properties.id;
},
/**
* The filter function gets called when iterating though each vector tile feature (vtf). You have access
* to every property associated with a given feature (the feature, and the layer). You can also filter
* based of the context (each tile that the feature is drawn onto).
*
* Returning false skips over the feature and it is not drawn.
*
* @param feature
* @returns {boolean}
*/
filter: function(feature, context) {
if (feature.layer.name === 'water') {
return true;
}
return true;
},
style: function (feature) {
var style = {};
var type = feature.type;
switch (type) {
case 1: //'Point'
style.color = 'rgba(49,79,79,1)';
style.radius = 5;
style.selected = {
color: 'rgba(255,255,0,0.5)',
radius: 6
};
break;
case 2: //'LineString'
style.color = 'rgba(161,217,155,0.8)';
style.size = 3;
style.selected = {
color: 'rgba(255,25,0,0.5)',
size: 4
};
break;
case 3: //'Polygon'
style.color = fillColor;
style.outline = {
color: strokeColor,
size: 1
};
style.selected = {
color: 'rgba(255,140,0,0.3)',
outline: {
color: 'rgba(255,140,0,1)',
size: 2
}
};
break;
}
return style;
}
});
debug.mvtSource = mvtSource;
//Globals that we can change later.
var fillColor = 'rgba(149,139,255,0.4)';
var strokeColor = 'rgb(20,20,20)';
//Add layer
map.addLayer(mvtSource);
</script>
</body>
</html>