geojson.html
2.9 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
<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/geojson-vt.js"></script>
<script src="../src/encode.js"></script>
<script src="../src/decode.js"></script>
<script src="../src/vectorTileFeature.js"></script>
<script src="../src/vectorTileLayer.js"></script>
<script src="../src/vector-tile.js"></script>
<script src="../src/geojson_wrapper.js"></script>
<script src="../src/vector-tile-pb.js"></script>
<script src="../src/vt-pbf.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/MVTSlice.js"></script>
<script>
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);
$.getJSON("bou2_4p.json", function (data){
// build an initial index of tiles
var tileIndex = geojsonvt(data, {
maxZoom: 14, // max zoom to preserve detail on
tolerance: 3, // simplification tolerance (higher means simpler)
extent: 4096, // tile extent (both width and height)
buffer: 64, // tile buffer on each side
debug: 2, // logging level (0 to disable, 1 or 2)
indexMaxZoom: 5, // max zoom in the initial tile index
indexMaxPoints: 10000, // max number of points per tile in the index
solidChildren: false // whether to include solid tile children in the index
});
var z= 14 - 6 ;
// request a particular tile
var features = tileIndex.getTile(6 + z, 48 * (1<<z), 24 * (1<<z)).features;
var mvtSource = new L.TileLayer.MVTSlice(data, {
debug: false,
getIDForLayerFeature: function(feature) {
return feature.properties.gid;
}
});
//Add layer
map.addLayer(mvtSource);
});
//$.ajax({
// url:"http://spatialserver.spatialdev.com/services/vector-tiles/GAUL_FSP/5/18/16.pbf",
// type:"GET",
// success: function(data) {
//var aa = new Pbf(new Uint8Array(data));
//var geojson = decode(aa);
//var ss = JSON.stringify(geojson);
// }
//});
</script>
</body>
</html>