-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo-dgt.htm
103 lines (83 loc) · 3.49 KB
/
demo-dgt.htm
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
<html>
<head><title>OGC API - Tiles Styling</title>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//matomo.byteroad.net/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '2']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<div id="map" style="width:100vw;height:100vh;"></div>
<!-- load leaflet -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<!-- load VectorGrid extension -->
<script src="https://unpkg.com/[email protected]/dist/Leaflet.VectorGrid.bundled.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" />
<a class="github-fork-ribbon" href="https://github.com/emotional-cities/vtiles-example.git" data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
<script>
function getColor_solo(val){
return val == 'Não atribuída' ? "#DAF7A6":
val == 'Solo Rústico' ? "#FFC300":
val == 'Solo Urbano' ? "#FF5733":
val == 'Solo Urbano (urbanizável – transitório)' ? "#C70039":
// val == ' Solo Urbano Programado' ? "#900C3F":
"#581845";
}
var vectorTileStyling = {
'crus': function(properties) {
// 'crus_31_julho2024': function(properties) {
// console.log(properties)
val = properties["Classe_202"]
// console.log(val)
return ({
fill: true,
fillColor: "#B29071",
fillOpacity: 0.7,
weight: 1,
color: getColor_solo(val),
opacity: 1,
});
}
}
var mapVectorTileOptions = {
rendererFactory: L.canvas.tile,
interactive: true,
vectorTileLayerStyles: vectorTileStyling,
};
var pbfURL = 'https://ogcapi.dgterritorio.gov.pt/collections/crus/tiles/WebMercatorQuad/{z}/{x}/{y}?f=mvt';
// Martin url
//var pbfURL = 'http://localhost/tiles/crus_31_julho2024/{z}/{x}/{y}?f=mvt';
// pg_tileserv
//var pbfURL = 'http://localhost:7800/public.crus_31_julho2024/{z}/{x}/{y}.pbf';
let start = Date.now();
map = L.map('map').setView({ lng: -8.4292, lat: 40.2115 }, 6);
map.addLayer(
new L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ',
minZoom: 1,
maxZoom: 16
}));
var pbfLayer=L.vectorGrid.protobuf(pbfURL,mapVectorTileOptions).on('click',function(e) {
console.log(e.layer);
L.DomEvent.stop(e);
}).addTo(map);
let timeTaken = Date.now() - start;
console.log("Total time taken : " + timeTaken + " milliseconds"); //20 milliseconds - 0.29%
</script>
</body>
</html>