mapicgc-gl-js 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/array-utils-flat-DeB-J5jn.mjs +1523 -0
- package/dist/assets/maplibre-gl-worker-HMCkgiD4.js +10 -0
- package/dist/buffer-transform-CH0poqqn.mjs +941 -0
- package/dist/expression-CtaQKvTZ.mjs +3444 -0
- package/dist/get-attribute-from-layouts-DqvACIaG.mjs +936 -0
- package/dist/{html2canvas-DhrjCa5K-6_3CwS_m.mjs → html2canvas-Cgp0Hyhk-HIw4n-A9.mjs} +105 -109
- package/dist/{index.es-D_FsJY9H-CO3QIBGM.mjs → index.es-lgdlL0gw-Bl7I-U5B.mjs} +176 -176
- package/dist/mapicgc-gl-js.css +1 -1
- package/dist/mapicgc-gl.css +199 -0
- package/dist/mapicgc-gl.js +5079 -856
- package/dist/mapicgc-gl.mjs +85573 -61841
- package/dist/purify.es-DNpVkA56-DxzGf9c8.mjs +769 -0
- package/dist/{chunk-efA98nb6-Dfm7IivL.mjs → rolldown-runtime-3b4jIN3o-CmciV3xi.mjs} +2 -2
- package/dist/{typeof-CTd55yxz-BxqQpTq1.mjs → typeof-C3azmBUr-9LkZMuan.mjs} +1 -1
- package/dist/webgl-Cep-x0-T.mjs +784 -0
- package/package.json +20 -15
- package/public/mapicgc-gl.css +199 -0
- package/src/controls/ApiTerritorialControl.js +222 -0
- package/src/index.js +18 -1
- package/src/map/Map.js +245 -144
- package/src/mapicgc-config.json +1303 -8
- package/src/plugins/CompareMaps.js +2 -1
- package/src/territorial/ApiTerritorialControl.js +1 -0
- package/src/territorial/mostraPanellInfo.js +250 -0
- package/src/territorial/searchApiTerritorialICGC.js +250 -0
- package/test/exemples/addApiTerritorialICGC.html +113 -0
- package/test/exemples/addBasemap.html +4 -4
- package/test/exemples/addCompare.html +7 -6
- package/test/exemples/addControl.html +12 -6
- package/test/exemples/addFeatureQuery.html +5 -4
- package/test/exemples/addGeocoderICGC.html +5 -4
- package/test/exemples/addICGCTerrain.html +5 -4
- package/test/exemples/addICGCTerrainCustomStyle.html +5 -4
- package/test/exemples/addImageLayerICGC.html +5 -4
- package/test/exemples/addLayerGeojson.html +5 -4
- package/test/exemples/addLayerTree.html +5 -4
- package/test/exemples/addLogo.html +5 -3
- package/test/exemples/addMapStyle.html +5 -4
- package/test/exemples/addMarker.html +5 -4
- package/test/exemples/addMouseCoordinateControl.html +5 -4
- package/test/exemples/addReliefStyle.html +6 -5
- package/test/exemples/addVectorLayerICGC.html +5 -4
- package/test/exemples/advancedExemple.html +5 -4
- package/test/exemples/fetchData.html +6 -5
- package/test/exemples/fetchDataAndMenu.html +5 -4
- package/test/exemples/styleOrto3D.html +8 -4
- package/test/vitest/ApiTerritorialControl.test.js +76 -0
- package/vite.config.mjs +16 -5
- package/dist/purify.es-DVGU85zV-CJOZ7ABI.mjs +0 -549
- package/dist/webgl-device-B1jTrfKA.mjs +0 -6880
- package/dist/webgl-device-D8jkwRzb.mjs +0 -2
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>test mapicgc-gl-js</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
|
|
7
|
+
<!-- v6 de maplibre-gl és ESM-only: ja no hi ha bundle UMD, per tant
|
|
8
|
+
el vostre dist tampoc en pot generar un que funcioni sol amb
|
|
9
|
+
<script src>. Cal carregar-lo com a mòdul. -->
|
|
8
10
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
11
|
|
|
10
12
|
<style>
|
|
@@ -28,10 +30,15 @@
|
|
|
28
30
|
|
|
29
31
|
<div id="map" class="map"></div>
|
|
30
32
|
|
|
31
|
-
<script>
|
|
33
|
+
<script type="module">
|
|
34
|
+
// Import ES module del vostre propi build (ex.: dist/mapicgc-gl.mjs,
|
|
35
|
+
// segons com l'anomeneu al vite.config). Ja no cal carregar
|
|
36
|
+
// maplibre-gl per separat: la llibreria en reexporta el namespace.
|
|
37
|
+
import { Map, Config, maplibregl } from "../../dist/mapicgc-gl.mjs";
|
|
38
|
+
|
|
32
39
|
async function initMap() {
|
|
33
|
-
const data = await
|
|
34
|
-
const map = new
|
|
40
|
+
const data = await Config.getConfigICGC();
|
|
41
|
+
const map = new Map({
|
|
35
42
|
container: "map",
|
|
36
43
|
style: data.Styles.TOPO,
|
|
37
44
|
center: [2.1464, 41.306],
|
|
@@ -41,7 +48,6 @@
|
|
|
41
48
|
pitch: 0,
|
|
42
49
|
});
|
|
43
50
|
map.on("load", () => {
|
|
44
|
-
// console.log('map', map)
|
|
45
51
|
// mapicgc-gl-js library:
|
|
46
52
|
map.addGeolocateControl(
|
|
47
53
|
{
|
|
@@ -56,7 +62,7 @@
|
|
|
56
62
|
map.addExportControl();
|
|
57
63
|
map.addMouseCoordControl();
|
|
58
64
|
map.addFullscreenControl({}, 'top-right')
|
|
59
|
-
//
|
|
65
|
+
// control natiu de maplibre-gl (v6), via el namespace reexportat:
|
|
60
66
|
map.addControl(new maplibregl.NavigationControl(), "bottom-right");
|
|
61
67
|
});
|
|
62
68
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>test mapicgc-gl-js</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
|
|
10
9
|
<style>
|
|
@@ -29,10 +28,12 @@
|
|
|
29
28
|
<div id="map"></div>
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
<script>
|
|
31
|
+
<script type="module">
|
|
32
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
33
|
+
|
|
33
34
|
async function initMap() {
|
|
34
|
-
const data = await
|
|
35
|
-
const map = new
|
|
35
|
+
const data = await Config.getConfigICGC();
|
|
36
|
+
const map = new Map({
|
|
36
37
|
container: "map",
|
|
37
38
|
style: data.Styles.TOPO,
|
|
38
39
|
center: [2.1464, 41.306],
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addGeocoderICGC.html</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -22,10 +21,12 @@
|
|
|
22
21
|
</head>
|
|
23
22
|
<body>
|
|
24
23
|
<div id="map" class="map"></div>
|
|
25
|
-
<script>
|
|
24
|
+
<script type="module">
|
|
25
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
26
|
+
|
|
26
27
|
async function initMap() {
|
|
27
|
-
const data = await
|
|
28
|
-
const map = new
|
|
28
|
+
const data = await Config.getConfigICGC();
|
|
29
|
+
const map = new Map({
|
|
29
30
|
container: "map",
|
|
30
31
|
style: data.Styles.TOPO,
|
|
31
32
|
center: [1.8436, 41.5923],
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addICGCTerrain.html</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -22,10 +21,12 @@
|
|
|
22
21
|
</head>
|
|
23
22
|
<body>
|
|
24
23
|
<div id="map" class="map"></div>
|
|
25
|
-
<script>
|
|
24
|
+
<script type="module">
|
|
25
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
26
|
+
|
|
26
27
|
async function initMap() {
|
|
27
|
-
const data = await
|
|
28
|
-
const map = new
|
|
28
|
+
const data = await Config.getConfigICGC();
|
|
29
|
+
const map = new Map({
|
|
29
30
|
container: "map",
|
|
30
31
|
style: data.Styles.ORTO,
|
|
31
32
|
center: [0.959, 42.201],
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addICGCTerrain.html</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -22,10 +21,12 @@
|
|
|
22
21
|
</head>
|
|
23
22
|
<body>
|
|
24
23
|
<div id="map" class="map"></div>
|
|
25
|
-
<script>
|
|
24
|
+
<script type="module">
|
|
25
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
26
|
+
|
|
26
27
|
async function initMap() {
|
|
27
|
-
const data = await
|
|
28
|
-
const map = new
|
|
28
|
+
const data = await Config.getConfigICGC();
|
|
29
|
+
const map = new Map({
|
|
29
30
|
container: "map",
|
|
30
31
|
style: "icgc_orto_histo.json",
|
|
31
32
|
center: [0.959, 42.201],
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>test mapicgc-gl-js</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -24,10 +23,12 @@
|
|
|
24
23
|
|
|
25
24
|
<body>
|
|
26
25
|
<div id="map" class="map"></div>
|
|
27
|
-
<script>
|
|
26
|
+
<script type="module">
|
|
27
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
28
|
+
|
|
28
29
|
async function initMap() {
|
|
29
|
-
const data = await
|
|
30
|
-
const map = new
|
|
30
|
+
const data = await Config.getConfigICGC();
|
|
31
|
+
const map = new Map({
|
|
31
32
|
container: "map",
|
|
32
33
|
style: data.Styles.TOPO,
|
|
33
34
|
center: [2.1464, 41.306],
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addLayerGeojson.html</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -24,10 +23,12 @@
|
|
|
24
23
|
|
|
25
24
|
<body>
|
|
26
25
|
<div id="map" class="map"></div>
|
|
27
|
-
<script>
|
|
26
|
+
<script type="module">
|
|
27
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
28
|
+
|
|
28
29
|
async function initMap() {
|
|
29
|
-
const data = await
|
|
30
|
-
const map = new
|
|
30
|
+
const data = await Config.getConfigICGC();
|
|
31
|
+
const map = new Map({
|
|
31
32
|
container: "map",
|
|
32
33
|
style: data.Styles.TOPO,
|
|
33
34
|
center: [1.001, 41.759],
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addLayerTree</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -25,10 +24,12 @@
|
|
|
25
24
|
<body>
|
|
26
25
|
<div id="map" class="map"></div>
|
|
27
26
|
<!-- <nav id="filter-group" class="filter-group"></nav> -->
|
|
28
|
-
<script>
|
|
27
|
+
<script type="module">
|
|
28
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
29
|
+
|
|
29
30
|
async function initMap() {
|
|
30
|
-
const data = await
|
|
31
|
-
const map = new
|
|
31
|
+
const data = await Config.getConfigICGC();
|
|
32
|
+
const map = new Map({
|
|
32
33
|
container: "map",
|
|
33
34
|
style: data.Styles.TOPO,
|
|
34
35
|
center: [2.1464, 41.306],
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addLogo</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -52,6 +51,9 @@
|
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
initMap();
|
|
55
|
-
|
|
54
|
+
<script type="module">
|
|
55
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
56
|
+
|
|
56
57
|
</body>
|
|
57
|
-
|
|
58
|
+
const data = await Config.getConfigICGC();
|
|
59
|
+
const map = new Map({
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addMapStyle</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -24,11 +23,13 @@
|
|
|
24
23
|
|
|
25
24
|
<body>
|
|
26
25
|
<div id="map" class="map"></div>
|
|
27
|
-
<script>
|
|
26
|
+
<script type="module">
|
|
27
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
28
|
+
|
|
28
29
|
async function initMap() {
|
|
29
|
-
const data = await
|
|
30
|
+
const data = await Config.getConfigICGC();
|
|
30
31
|
|
|
31
|
-
const map = new
|
|
32
|
+
const map = new Map({
|
|
32
33
|
container: 'map',
|
|
33
34
|
style: data.Styles.ORTO,
|
|
34
35
|
center: [1.1464, 41.706],
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addMarker</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -24,10 +23,12 @@
|
|
|
24
23
|
</head>
|
|
25
24
|
<body>
|
|
26
25
|
<div id="map" class="map"></div>
|
|
27
|
-
<script>
|
|
26
|
+
<script type="module">
|
|
27
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
28
|
+
|
|
28
29
|
async function initMap() {
|
|
29
|
-
const data = await
|
|
30
|
-
const map = new
|
|
30
|
+
const data = await Config.getConfigICGC();
|
|
31
|
+
const map = new Map({
|
|
31
32
|
container: "map",
|
|
32
33
|
style: data.Styles.TOPO,
|
|
33
34
|
center: [2.1464, 41.306],
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addMouseCoordinateControl</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -21,10 +20,12 @@
|
|
|
21
20
|
</head>
|
|
22
21
|
<body>
|
|
23
22
|
<div id="map" class="map"></div>
|
|
24
|
-
<script>
|
|
23
|
+
<script type="module">
|
|
24
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
25
|
+
|
|
25
26
|
async function initMap() {
|
|
26
|
-
const data = await
|
|
27
|
-
const map = new
|
|
27
|
+
const data = await Config.getConfigICGC();
|
|
28
|
+
const map = new Map({
|
|
28
29
|
container: "map",
|
|
29
30
|
style: data.Styles.TOPO,
|
|
30
31
|
center: [2.1464, 41.306],
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addICGCTerrain.html</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -25,11 +24,13 @@
|
|
|
25
24
|
|
|
26
25
|
<body>
|
|
27
26
|
<div id="map" class="map"></div>
|
|
28
|
-
<script>
|
|
27
|
+
<script type="module">
|
|
28
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
29
|
+
|
|
29
30
|
async function initMap() {
|
|
30
|
-
const data = await
|
|
31
|
+
const data = await Config.getConfigICGC();
|
|
31
32
|
|
|
32
|
-
// const map = new
|
|
33
|
+
// const map = new Map({
|
|
33
34
|
// container: "map",
|
|
34
35
|
// style: "RELIEF", // Simple string
|
|
35
36
|
// center: [1.68, 42.46],
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
|
|
44
45
|
//opció personalitzada:
|
|
45
46
|
|
|
46
|
-
const map = new
|
|
47
|
+
const map = new Map({
|
|
47
48
|
container: "map",
|
|
48
49
|
style: {
|
|
49
50
|
source: {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addVectorLayerICGC</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -25,10 +24,12 @@
|
|
|
25
24
|
|
|
26
25
|
<body>
|
|
27
26
|
<div id="map"></div>
|
|
28
|
-
<script>
|
|
27
|
+
<script type="module">
|
|
28
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
29
|
+
|
|
29
30
|
async function initMap() {
|
|
30
|
-
const data = await
|
|
31
|
-
const map = new
|
|
31
|
+
const data = await Config.getConfigICGC();
|
|
32
|
+
const map = new Map({
|
|
32
33
|
container: "map",
|
|
33
34
|
style: data.Styles.TOPO,
|
|
34
35
|
center: [2.1464, 41.306],
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>advancedExemple</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -45,10 +44,12 @@
|
|
|
45
44
|
<body>
|
|
46
45
|
<div id="map" class="map"></div>
|
|
47
46
|
|
|
48
|
-
<script>
|
|
47
|
+
<script type="module">
|
|
48
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
49
|
+
|
|
49
50
|
async function initMap() {
|
|
50
|
-
const data = await
|
|
51
|
-
const map = new
|
|
51
|
+
const data = await Config.getConfigICGC();
|
|
52
|
+
const map = new Map({
|
|
52
53
|
container: "map",
|
|
53
54
|
style: data.Styles.ORTO,
|
|
54
55
|
center: [1.808, 41.618],
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>fetchData</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
8
|
<style>
|
|
10
9
|
body {
|
|
@@ -25,10 +24,12 @@
|
|
|
25
24
|
<body>
|
|
26
25
|
<div id="map" class="map"></div>
|
|
27
26
|
|
|
28
|
-
<script>
|
|
27
|
+
<script type="module">
|
|
28
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
29
|
+
|
|
29
30
|
async function initMap() {
|
|
30
|
-
const data = await
|
|
31
|
-
const map = new
|
|
31
|
+
const data = await Config.getConfigICGC();
|
|
32
|
+
const map = new Map({
|
|
32
33
|
container: "map",
|
|
33
34
|
style: data.Styles.LIGHT,
|
|
34
35
|
center: [1.808, 41.618],
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
};
|
|
62
63
|
map.on("load", () => {
|
|
63
64
|
map.fetchData(
|
|
64
|
-
|
|
65
|
+
'https://api.icgc.cat/territorial/collections/agrupacions-censals/items?f=geojson',
|
|
65
66
|
"Comarques", paintOptionsfgb);
|
|
66
67
|
map.fetchData(
|
|
67
68
|
"https://analisi.transparenciacatalunya.cat/resource/pzaa-n72w.geojson",
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>test mapicgc-gl-js</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
6
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
7
|
<style>
|
|
9
8
|
body {
|
|
@@ -36,10 +35,12 @@
|
|
|
36
35
|
</head>
|
|
37
36
|
<body>
|
|
38
37
|
<div id="map" class="map"></div>
|
|
39
|
-
<script>
|
|
38
|
+
<script type="module">
|
|
39
|
+
import { Map, Config } from "../../dist/mapicgc-gl.mjs";
|
|
40
|
+
|
|
40
41
|
async function initMap() {
|
|
41
|
-
const data = await
|
|
42
|
-
const map = new
|
|
42
|
+
const data = await Config.getConfigICGC();
|
|
43
|
+
const map = new Map({
|
|
43
44
|
container: "map",
|
|
44
45
|
style: data.Styles.TOPO,
|
|
45
46
|
center: [1.808, 41.618],
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>styleOrto3D</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -52,10 +52,14 @@
|
|
|
52
52
|
<label for='DARK'>DARK</label>
|
|
53
53
|
</div>
|
|
54
54
|
<div id="map" class="map"></div>
|
|
55
|
-
|
|
55
|
+
<script type="module">
|
|
56
|
+
// Import ES module del vostre propi build (ex.: dist/mapicgc-gl.mjs,
|
|
57
|
+
// segons com l'anomeneu al vite.config). Ja no cal carregar
|
|
58
|
+
// maplibre-gl per separat: la llibreria en reexporta el namespace.
|
|
59
|
+
import { Map, Config} from "../../dist/mapicgc-gl.mjs";
|
|
56
60
|
async function initMap() {
|
|
57
|
-
const data = await
|
|
58
|
-
const map = new
|
|
61
|
+
const data = await Config.getConfigICGC();;
|
|
62
|
+
const map = new Map({
|
|
59
63
|
container: 'map',
|
|
60
64
|
style: data.Styles.ORTO3D,
|
|
61
65
|
center: [2.3090, 41.9800],
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
describe('searchApiTerritorialICGC', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
vi.resetModules();
|
|
6
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
7
|
+
ok: true,
|
|
8
|
+
json: async () => ({ features: [] }),
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('adds skipgeometry=true when skipGeometry is enabled', async () => {
|
|
13
|
+
const { searchApiTerritorialICGC } = await import('../../src/territorial/searchApiTerritorialICGC.js');
|
|
14
|
+
|
|
15
|
+
await searchApiTerritorialICGC(1.5, 41.8, {
|
|
16
|
+
collections: 'municipis',
|
|
17
|
+
skipGeometry: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
21
|
+
expect.stringContaining('skipgeometry=true'),
|
|
22
|
+
expect.objectContaining({
|
|
23
|
+
headers: {
|
|
24
|
+
Accept: 'application/geo+json',
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('keeps geometry in direct helper calls by default', async () => {
|
|
31
|
+
const { searchApiTerritorialICGC } = await import('../../src/territorial/searchApiTerritorialICGC.js');
|
|
32
|
+
|
|
33
|
+
await searchApiTerritorialICGC(1.5, 41.8, {
|
|
34
|
+
collections: 'municipis',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
38
|
+
expect.not.stringContaining('skipgeometry=true'),
|
|
39
|
+
expect.any(Object)
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('ApiTerritorialControl', () => {
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
vi.resetModules();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('uses skipGeometry=true by default for map click lookups', async () => {
|
|
50
|
+
const searchApiTerritorialICGC = vi.fn().mockResolvedValue({});
|
|
51
|
+
|
|
52
|
+
vi.doMock('../../src/territorial/searchApiTerritorialICGC.js', () => ({
|
|
53
|
+
searchApiTerritorialICGC,
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
const { default: ApiTerritorialControl } = await import('../../src/controls/ApiTerritorialControl.js');
|
|
57
|
+
const control = new ApiTerritorialControl();
|
|
58
|
+
|
|
59
|
+
control._map = {};
|
|
60
|
+
|
|
61
|
+
await control._handleMapClick({
|
|
62
|
+
lngLat: {
|
|
63
|
+
lng: 1.5,
|
|
64
|
+
lat: 41.8,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(searchApiTerritorialICGC).toHaveBeenCalledWith(
|
|
69
|
+
1.5,
|
|
70
|
+
41.8,
|
|
71
|
+
expect.objectContaining({
|
|
72
|
+
skipGeometry: true,
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
});
|
package/vite.config.mjs
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import babel from '@rollup/plugin-babel';
|
|
3
|
-
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
3
|
+
//import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
4
4
|
|
|
5
5
|
export default defineConfig({
|
|
6
|
+
// Sense això, Vite emet les URLs dels assets (com el worker de
|
|
7
|
+
// maplibre-gl via `?worker&url`) com a rutes absolutes des de l'arrel
|
|
8
|
+
// del lloc (`/assets/...`). Com que mapicgc-gl-js és una llibreria que
|
|
9
|
+
// es pot servir des de qualsevol subcarpeta (no necessàriament l'arrel
|
|
10
|
+
// del domini), calen rutes relatives a la ubicació real del bundle.
|
|
11
|
+
base: './',
|
|
6
12
|
test: {
|
|
7
13
|
globals: true,
|
|
8
14
|
environment: 'node',
|
|
9
15
|
},
|
|
10
16
|
resolve: {
|
|
11
17
|
extensions: ['.mjs', '.js', '.ts', '.json'], // Asegúrate de que Vitest pueda resolver módulos ESM.
|
|
18
|
+
// maplibre-gl v6 es ESM-only. Si @watergis/maplibre-gl-export,
|
|
19
|
+
// @maplibre/maplibre-gl-geocoder o @maplibre/maplibre-gl-compare aún
|
|
20
|
+
// hacen un require('maplibre-gl') de estilo CJS internamente, el plugin
|
|
21
|
+
// commonjs puede acabar creando una segunda "copia" del módulo (con su
|
|
22
|
+
// propia clase Map) distinta de la que usa Map.js. dedupe fuerza a Vite/
|
|
23
|
+
// Rollup a resolver siempre la MISMA instancia física del paquete.
|
|
24
|
+
dedupe: ['maplibre-gl'],
|
|
12
25
|
},
|
|
13
26
|
define: {
|
|
14
27
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
@@ -31,12 +44,10 @@ export default defineConfig({
|
|
|
31
44
|
},
|
|
32
45
|
rollupOptions: {
|
|
33
46
|
plugins: [
|
|
34
|
-
|
|
35
|
-
protocolImports: true,
|
|
36
|
-
}),
|
|
47
|
+
|
|
37
48
|
babel({ babelHelpers: 'bundled' }),
|
|
38
49
|
],
|
|
39
50
|
|
|
40
51
|
},
|
|
41
52
|
},
|
|
42
|
-
});
|
|
53
|
+
});
|