-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRendering_Restrictions.js
55 lines (47 loc) · 1.53 KB
/
Rendering_Restrictions.js
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
const api_key = "YOUR_API_KEY";
var coordinate = L.latLng(49.012, 8.4044);
var map = L.map('map', {
fullscreenControl: true
}).setView(coordinate, 17);
var vectorStyleUrl = "https://vectormaps-resources.myptv.com/styles/latest/standard.json";
//Lazy load the plugin to support right-to-left languages such as Arabic and Hebrew.
maplibregl.setRTLTextPlugin(
'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js',
null,
true
);
var vectorLayer = L.maplibreGL({
attribution: '© ' + new Date().getFullYear() + ' PTV Logistics, HERE',
interactive:false,
maxZoom: 18,
style: vectorStyleUrl,
transformRequest: (url) => {
let transformedUrl = url;
let mapsPathIndex = url.indexOf('/maps/');
if (mapsPathIndex > 0) {
transformedUrl = 'https://api.myptv.com/' + url.substring(mapsPathIndex) + '?apiKey=' + api_key;
return {
url: `${transformedUrl}`
};
}
return null;
}
}).addTo(map);
map.createPane('clickableTiles');
map.getPane('clickableTiles').style.zIndex = 500;
var rasterTileUrl = "https://api.myptv.com/rastermaps/v1/data-tiles/{z}/{x}/{y}";
var restrictionsLayer = L.tileLayer.ptvDeveloper(
rasterTileUrl + '?layers={layers}&apiKey=' + api_key, {
layers: 'restrictions',
maxZoom: 18,
opacity: 0.5,
pane: 'clickableTiles'
}).addTo(map);
var layers = {
"Vector Base Map": vectorLayer,
"Restrictions": restrictionsLayer,
};
L.control.layers({}, layers, {
position: 'bottomleft',
autoZIndex: false
}).addTo(map);