mapicgc-gl-js 0.0.76 → 0.0.78

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/src/map/Map.js CHANGED
@@ -22,7 +22,7 @@ import Config from "../constants/ConfigICGC.js";
22
22
  import Legends from "../constants/Legends.js";
23
23
  import mapicgcConfig from "../mapicgc-config.json";
24
24
 
25
- const ORDER_LAYER_TOP = "top";
25
+ const ORDER_LAYER_TOP = "top"; // default
26
26
  const ORDER_LAYER_LINE = "lines";
27
27
  const ORDER_LAYER_SYMBOL = "labels";
28
28
  let Styles, Terrains, Layers, defaultOptions;
@@ -93,6 +93,7 @@ export default class Map {
93
93
  /**
94
94
  * Add geocoder.
95
95
  * @function addGeocoderICGC
96
+ * @param {string} [position='top-right'] - Position to add the control on the map.
96
97
  * @returns {Object} - The current position of the search result.
97
98
  */
98
99
  addGeocoderICGC(position) {
@@ -1340,6 +1341,12 @@ export default class Map {
1340
1341
  */
1341
1342
  addLogo(options) {
1342
1343
  try {
1344
+ let mapId = document.getElementById("map");
1345
+ let logosDiv;
1346
+ logosDiv = document.createElement("div");
1347
+ logosDiv.id = "logos";
1348
+ mapId.appendChild(logosDiv);
1349
+
1343
1350
  const img = document.createElement("img");
1344
1351
  img.src = options.url;
1345
1352
  img.style.height = options.height;
@@ -1405,6 +1412,13 @@ export default class Map {
1405
1412
  const handleClick = (base) => {
1406
1413
  map.setStyle(base.url);
1407
1414
  };
1415
+ let mapId = document.getElementById("map");
1416
+ let menuGroup;
1417
+ menuGroup = document.createElement("div");
1418
+ menuGroup.id = "basemap-group";
1419
+ menuGroup.classList.add = "basemap-group";
1420
+ mapId.appendChild(menuGroup);
1421
+
1408
1422
  const basemapGroup = document.getElementById("basemap-group");
1409
1423
  baseLayers.forEach((base) => {
1410
1424
  const div = document.createElement("div");
@@ -1451,7 +1465,7 @@ export default class Map {
1451
1465
  text = text + `<h4>${pr}</h4>`;
1452
1466
  });
1453
1467
  description = text;
1454
- map.addPopup(coordinates, description, popupStyle);
1468
+ this.addPopup(coordinates, description, popupStyle);
1455
1469
  }
1456
1470
  } else {
1457
1471
  let text = "";
@@ -1460,7 +1474,7 @@ export default class Map {
1460
1474
  "<b>" + key + "</b>:" + features[0].properties[key] + "<br>";
1461
1475
  }
1462
1476
  description = text;
1463
- map.addPopup(coordinates, description, popupStyle);
1477
+ this.addPopup(coordinates, description, popupStyle);
1464
1478
  }
1465
1479
  }
1466
1480
  });
@@ -1512,20 +1526,7 @@ export default class Map {
1512
1526
  console.error(`Error adding export control: ${error.message}`);
1513
1527
  }
1514
1528
  }
1515
- /**
1516
- * Adds a popup to the map.
1517
- * @function addPopup
1518
- * @param {array} coordinates - Coordinates of the popup .
1519
- * @param {string} text - Text content for the popup.
1520
- */
1521
- addPopup(coordinates, text) {
1522
- try {
1523
- new maplibregl.Popup()
1524
- .setLngLat(coordinates)
1525
- .setHTML(text)
1526
- .addTo(this.map);
1527
- } catch (error) {}
1528
- }
1529
+
1529
1530
  /**
1530
1531
  * Adds a marker to the map.
1531
1532
  * @function addMarker
@@ -1681,6 +1682,10 @@ export default class Map {
1681
1682
  addLayerTree(options) {
1682
1683
  try {
1683
1684
  let places = options.features;
1685
+ let mapId = document.getElementById("map");
1686
+ let menuGroup = document.createElement("nav");
1687
+ menuGroup.id = "filter-group";
1688
+ mapId.appendChild(menuGroup);
1684
1689
  const filterGroup = document.getElementById("filter-group");
1685
1690
  this.map.addSource(`${options.id}`, {
1686
1691
  type: options.type,
@@ -2081,6 +2086,16 @@ export default class Map {
2081
2086
  }
2082
2087
 
2083
2088
  //Internal methods
2089
+ /**
2090
+ * Finds the type of image based on the provided URL and specified vectors.
2091
+ * @function _findImageType
2092
+ * @param {string} url - The URL of the image to find the type for.
2093
+ * @param {Object} var1 - The first vector object containing key-value pairs.
2094
+ * @param {Object} var2 - The second vector object containing key-value pairs.
2095
+ * @param {Object} var3 - The third vector object containing key-value pairs.
2096
+ * @param {Object} var4 - The fourth vector object containing key-value pairs.
2097
+ * @returns {string|null} - The type of image if found, otherwise null.
2098
+ */
2084
2099
  _findImageType(url, var1, var2, var3, var4) {
2085
2100
  const vectors = [var1, var2, var3, var4];
2086
2101
  for (const vector of vectors) {
@@ -2092,6 +2107,12 @@ export default class Map {
2092
2107
  }
2093
2108
  return null;
2094
2109
  }
2110
+ /**
2111
+ * Gets the key by URL from the FGBAdmin layers.
2112
+ * @function _getKeyByUrlFGB
2113
+ * @param {string} url - The URL to find the key for in the FGBAdmin layers.
2114
+ * @returns {string|null} - The key if found, otherwise null.
2115
+ */
2095
2116
  _getKeyByUrlFGB(url) {
2096
2117
  for (const key in Layers.FGBAdmin) {
2097
2118
  if (Layers.FGBAdmin.hasOwnProperty(key) && Layers.FGBAdmin[key] === url) {
@@ -2100,6 +2121,12 @@ export default class Map {
2100
2121
  }
2101
2122
  return null;
2102
2123
  }
2124
+ /**
2125
+ * Gets the legend by name from the default vector layers.
2126
+ * @function _getLegendByName
2127
+ * @param {string} name - The name of the vector layer to get the legend for.
2128
+ * @returns {string|null} - The legend if found, otherwise null.
2129
+ */
2103
2130
  _getLegendByName(name) {
2104
2131
  for (const layerKey in defaultOptions.vectorLayers) {
2105
2132
  const layer = defaultOptions.vectorLayers[layerKey];
@@ -2109,6 +2136,12 @@ export default class Map {
2109
2136
  }
2110
2137
  return null;
2111
2138
  }
2139
+ /**
2140
+ * Gets the key by URL from the Vector layers.
2141
+ * @function _getKeyByUrlVector
2142
+ * @param {string} url - The URL to find the key for in the Vector layers.
2143
+ * @returns {string|null} - The key if found, otherwise null.
2144
+ */
2112
2145
  _getKeyByUrlVector(url) {
2113
2146
  for (const key in Layers.Vector) {
2114
2147
  if (Layers.Vector.hasOwnProperty(key) && Layers.Vector[key] === url) {
@@ -2117,6 +2150,12 @@ export default class Map {
2117
2150
  }
2118
2151
  return null;
2119
2152
  }
2153
+ /**
2154
+ * Raises text 3D style on the map.
2155
+ * @function _raiseText3DStyle
2156
+ * @async
2157
+ * @returns {Promise<void>} - A promise that resolves after updating the text 3D style on the map.
2158
+ */
2120
2159
  async _raiseText3DStyle() {
2121
2160
  try {
2122
2161
  const image = await this.map.loadImage(
@@ -2153,11 +2192,12 @@ export default class Map {
2153
2192
  return null;
2154
2193
  }
2155
2194
  }
2195
+
2156
2196
  /**
2157
- * Internal method to handle map styles.
2197
+ * Deals with map styles based on the name.
2158
2198
  * @function _dealStyleMaps
2159
- * @param {string} name - Name of the map style.
2160
- * @returns {string} - URL of the map style.
2199
+ * @param {string} name - The name of the map style.
2200
+ * @returns {Object|string|null} - The map style object if found, or the input name if not found, or null if an error occurs.
2161
2201
  */
2162
2202
  _dealStyleMaps(name) {
2163
2203
  try {
@@ -2179,6 +2219,12 @@ export default class Map {
2179
2219
  return null;
2180
2220
  }
2181
2221
  }
2222
+ /**
2223
+ * Deals with the 3D ortho style based on the name.
2224
+ * @function _dealOrto3dStyle
2225
+ * @param {string} name - The name of the orto3D style.
2226
+ * @returns {void|null} - Returns null if an error occurs.
2227
+ */
2182
2228
  _dealOrto3dStyle(name) {
2183
2229
  try {
2184
2230
  if (name == "orto3d") {
@@ -2221,6 +2267,12 @@ export default class Map {
2221
2267
  return null;
2222
2268
  }
2223
2269
  }
2270
+ /**
2271
+ * Deals with the order of the layer.
2272
+ * @function _dealOrderLayer
2273
+ * @param {string} order - The order of the layer.
2274
+ * @returns {string} - The id of the first symbol layer if the order is 'symbol', the id of the first line layer if the order is 'line', otherwise an empty string.
2275
+ */
2224
2276
  _dealOrderLayer(order) {
2225
2277
  if (order === ORDER_LAYER_SYMBOL) {
2226
2278
  return this._firstSymbolLayer();
@@ -2230,6 +2282,11 @@ export default class Map {
2230
2282
  return "";
2231
2283
  }
2232
2284
  }
2285
+ /**
2286
+ * Retrieves the id of the first symbol layer.
2287
+ * @function _firstSymbolLayer
2288
+ * @returns {string|undefined} - The id of the first symbol layer if found, otherwise undefined.
2289
+ */
2233
2290
  _firstSymbolLayer() {
2234
2291
  try {
2235
2292
  const layers = this.map.getStyle().layers;
@@ -2250,6 +2307,11 @@ export default class Map {
2250
2307
  console.error(`Error getting first symbol layer: ${error.message}`);
2251
2308
  }
2252
2309
  }
2310
+ /**
2311
+ * Retrieves the id of the first line layer.
2312
+ * @function _firstLineLayer
2313
+ * @returns {string|undefined} - The id of the first line layer if found, otherwise undefined.
2314
+ */
2253
2315
  _firstLineLayer() {
2254
2316
  try {
2255
2317
  const layers = this.map.getStyle().layers;
@@ -2265,6 +2327,11 @@ export default class Map {
2265
2327
  console.error(`Error getting first symbol layer: ${error.message}`);
2266
2328
  }
2267
2329
  }
2330
+ /**
2331
+ * Creates a Mapbox layer for displaying cities in 3D.
2332
+ * @function _createCitiesMapboxLayer
2333
+ * @returns {MapboxLayer|null} - The Mapbox layer for displaying cities in 3D if created successfully, otherwise null.
2334
+ */
2268
2335
  _createCitiesMapboxLayer() {
2269
2336
  try {
2270
2337
  const citiesMapboxLayer = new MapboxLayer({
@@ -27,7 +27,7 @@
27
27
 
28
28
 
29
29
  <div id="map"></div>
30
- <nav id="menu-group" class="filter-group"></nav>
30
+
31
31
 
32
32
  <script>
33
33
  async function initMap() {
@@ -24,7 +24,7 @@
24
24
 
25
25
  <body>
26
26
  <div id="map" class="map"></div>
27
- <nav id="filter-group" class="filter-group"></nav>
27
+ <!-- <nav id="filter-group" class="filter-group"></nav> -->
28
28
  <script>
29
29
  async function initMap() {
30
30
  const data = await mapicgcgl.Config.getConfigICGC();;
@@ -28,7 +28,7 @@
28
28
  </head>
29
29
  <body>
30
30
  <div id="map" class="map"></div>
31
- <div id="logos"></div>
31
+ <!-- <div id="logos"></div> -->
32
32
  <script>
33
33
  async function initMap() {
34
34
  const data = await mapicgcgl.Config.getConfigICGC();;
@@ -44,7 +44,7 @@
44
44
 
45
45
  <body>
46
46
  <div id="map" class="map"></div>
47
- <nav id="menu-group" class="filter-group"></nav>
47
+
48
48
  <script>
49
49
  async function initMap() {
50
50
  const data = await mapicgcgl.Config.getConfigICGC();;
@@ -24,8 +24,7 @@
24
24
 
25
25
  <body>
26
26
  <div id="map" class="map"></div>
27
- <nav id="menu-group" class="filter-group"></nav>
28
- <div id="basemap-group" class="basemap-group"></div>
27
+
29
28
  <script>
30
29
  async function initMap() {
31
30
  const data = await mapicgcgl.Config.getConfigICGC();;