Skip to content

Commit

Permalink
maplibre 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lstiz committed Feb 24, 2025
1 parent ac2191d commit a15268d
Show file tree
Hide file tree
Showing 12 changed files with 121,613 additions and 67,681 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# MapICGC GL JS


> 🌠 __Based on MapLibre GL JS version:__ 4.5.0
> 🌠 __Based on MapLibre GL JS version:__ 5.1.0
The MapICGC GL JS library builds upon the open-source library [**MapLibre GL JS**](https://github.com/maplibre/maplibre-gl-js), exposing its existing capabilities while introducing new features specific to the MapICGC ecosystem. This library is tailored to seamlessly integrate with the MapICGC Cloud service, offering a comprehensive set of data to enhance web mapping experiences, including vector tiles, satellite raster tiles, DEM with Terrain RGB, and customizable styles with an editor.

Expand Down
114,668 changes: 114,668 additions & 0 deletions dist/index-CFgK05pK.mjs

Large diffs are not rendered by default.

64,718 changes: 0 additions & 64,718 deletions dist/index-NFWyDjBL.mjs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { p as Ui } from "./index-NFWyDjBL.mjs";
import { p as Ui } from "./index-CFgK05pK.mjs";
var Zt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function No(i) {
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
Expand Down
3,525 changes: 2,317 additions & 1,208 deletions dist/mapicgc-gl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mapicgc-gl.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { C as p, a as s, M as r } from "./index-NFWyDjBL.mjs";
import { C as p, a as s, M as r } from "./index-CFgK05pK.mjs";
export {
p as CompareMaps,
s as Config,
Expand Down
3,525 changes: 2,317 additions & 1,208 deletions dist/mapicgc-gl.umd.js

Large diffs are not rendered by default.

2,701 changes: 2,165 additions & 536 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "mapicgc-gl-js",
"homepage": "https://openicgc.github.io/mapicgc-doc/",
"version": "0.0.96",
"version": "0.0.97",
"description": "mapicgc-gl-js library",
"author": "Institut Cartogràfic i Geològic de Catalunya",
"license": "BSD-3-Clause",
"type": "commonjs",

"keywords": [
"map",
"js",
Expand Down Expand Up @@ -38,7 +39,8 @@
"build": "vite build",
"preview": "vite preview",
"publish": "npm publish --access public",
"setConfig": "node nodeSetConfig.js"
"setConfig": "node nodeSetConfig.js",
"test": "vitest"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand All @@ -48,26 +50,27 @@
"dotenv": "^16.3.1",
"jest": "29.7.0",
"jsdoc": "^4.0.2",
"jsdom": "^25.0.1",
"npm-run-all": "^4.1.5",
"package-json-versionify": "^1.0.4",
"path": "^0.12.7",
"rollup-plugin-polyfill": "^4.2.0",
"ssh2-sftp-client": "^9.0.4",
"vite": "^5.2.10",
"vite-plugin-node-polyfills": "^0.21.0",
"vitest": "^2.1.8",
"xml2js": "^0.6.2"
},
"dependencies": {
"@deck.gl/core": "~8.9.35",
"@deck.gl/geo-layers": "~8.9.35",
"@deck.gl/mapbox": "~8.9.35",
"@deck.gl/core": "^9.1.3",
"@deck.gl/geo-layers": "^9.1.3",
"@deck.gl/mapbox": "^9.1.3",
"@loaders.gl/3d-tiles": "~3.4.14",
"@maplibre/maplibre-gl-compare": "^0.5.0",
"@maplibre/maplibre-gl-geocoder": "^1.5.0",
"@watergis/maplibre-gl-export": "^3.7.0",
"flatgeobuf": "^3.31.1",
"maplibre-gl": "^4.7.1",
"maplibre-gl": "^5.1.0",
"utm-latlng": "^1.0.8"

}
}
2 changes: 1 addition & 1 deletion src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3258,7 +3258,7 @@ setSky(options) {
try {

if (name == "orto3d") {

this.map.setMaxZoom(18.8);
this.map.easeTo({ pitch: 45 });
const ambientLight = new AmbientLight({
Expand Down
122 changes: 122 additions & 0 deletions test/vitest/Map.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@

// import Map from '../../src/map/Map.js';
import jest from "jest";
import maplibregl from "maplibre-gl";
import { vi } from 'vitest';
import { JSDOM } from 'jsdom';


import { beforeEach, describe, expect, test, vi } from 'vitest';


describe('setStyle method', () => {
let instance;
let mockElement;

beforeEach(() => {
// Create a DOM environment
const dom = new JSDOM(`<!DOCTYPE html><div class="maplibregl-compact-show"></div>`);
global.document = dom.window.document;
vi.mock('maplibre-gl', () => ({
default: {
Map: vi.fn().mockImplementation(() => ({
addControl: vi.fn(),
// Mock additional methods if necessary
})),
},
}));
// Mock map initialization
const map = new maplibregl.Map({
container: 'map',
center: [0, 0],
zoom: 10,
});

// Mock methods used in setStyle
map.setStyle = vi.fn();
map.getStyle = vi.fn(() => ({ name: 'mockStyle' }));
map.on = vi.fn((event, callback) => {
if (event === 'styledata') callback();
});

// Mock DOM manipulation
mockElement = { classList: { remove: vi.fn() } };
vi.spyOn(document, 'querySelector').mockImplementation((selector) => {
if (selector === '.maplibregl-compact-show') return mockElement;
return null;
});

// Mock _dealOrto3dStyle
const _dealOrto3dStyleMock = vi.fn();

// Mock the instance
instance = {
map,
_dealOrto3dStyle: _dealOrto3dStyleMock,
setStyle: function (style, options) {
try {
if (options !== undefined) {
this.map.setStyle(style, options);
} else {
this.map.setStyle(style);
}
this.map.on('styledata', () => {
const element = document.querySelector('.maplibregl-compact-show');
if (element) {
element.classList.remove('maplibregl-compact-show');
}
this._dealOrto3dStyle(this.map.getStyle().name);
});
} catch (error) {
console.error(`Error setting style: ${error.message}`);
}
},
};
});
test('should initialize a MapLibre map instance and call addControl', () => {

// Mock map initialization options
const options = {
container: 'map',
center: [0, 0],
zoom: 10,
};

// Instantiate the mocked map
const map = new maplibregl.Map(options);


// Verify that the Map constructor is called with the correct options
expect(maplibregl.Map).toHaveBeenCalledWith(options);

// Mock a control and call addControl
const controlMock = vi.fn();
map.addControl(controlMock, 'top-right');

// Verify that the addControl method is called with the correct arguments
expect(map.addControl).toHaveBeenCalledWith(controlMock, 'top-right');
});
test('should set map style and handle styledata event correctly', () => {
const style = 'mockStyle';
const styleOptions = { transition: true };

// Test the function with options
instance.setStyle(style, styleOptions);
expect(instance.map.setStyle).toHaveBeenCalledWith(style, styleOptions);

// Test the function without options
instance.setStyle(style);
expect(instance.map.setStyle).toHaveBeenCalledWith(style);

// Verify DOM manipulation
expect(document.querySelector).toHaveBeenCalledWith('.maplibregl-compact-show');
expect(mockElement.classList.remove).toHaveBeenCalledWith('maplibregl-compact-show');

// Verify _dealOrto3dStyle is called with the correct style name
expect(instance._dealOrto3dStyle).toHaveBeenCalledWith('mockStyle');
});


});


10 changes: 10 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ import babel from '@rollup/plugin-babel';
import { nodePolyfills } from 'vite-plugin-node-polyfills'

export default defineConfig({
test: {
globals: true,
environment: 'node',
},
resolve: {
extensions: ['.mjs', '.js', '.ts', '.json'], // Asegúrate de que Vitest pueda resolver módulos ESM.
},
define: {
'process.env': {}
},
build: {
commonjsOptions: {
include: [/node_modules/],
},
minify: true,
lib: {
entry: 'src/index.js',
Expand Down

0 comments on commit a15268d

Please sign in to comment.