From 01261390b18540ca8abddf4b16b78fc9c1397390 Mon Sep 17 00:00:00 2001 From: Jin Igarashi Date: Sun, 17 Oct 2021 14:46:13 +0100 Subject: [PATCH] migrated to maplibre-gl-js --- .github/workflows/build.yml | 2 +- .github/workflows/deploy-ghpages.yml | 4 +-- .github/workflows/release.yml | 4 +-- .gitignore | 2 +- README.md | 42 ++++++++++++------------- css/styles.css | 22 ++++++------- docs/index.html | 4 +-- docs/index.ts | 16 +++++----- docs/index2.html | 14 ++++----- lib/index.ts | 2 +- lib/legend-control.ts | 32 +++++++++---------- package-lock.json | 47 +++++++++++++++------------- package.json | 13 ++++---- webpack.cdn.config.js | 4 +-- webpack.config.js | 2 +- 15 files changed, 106 insertions(+), 104 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ac8407..e28b0a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ name: build on: push: - branches: [ master ] + branches: [ main ] paths: - "lib/**" diff --git a/.github/workflows/deploy-ghpages.yml b/.github/workflows/deploy-ghpages.yml index e05e505..3adb0c6 100644 --- a/.github/workflows/deploy-ghpages.yml +++ b/.github/workflows/deploy-ghpages.yml @@ -5,7 +5,7 @@ name: deploy gh-pages on: push: - branches: [ master ] + branches: [ main ] paths: - "lib/**" - "docs/**" @@ -32,5 +32,5 @@ jobs: npm run build git config --global user.name "watergis+githubci" git config --global user.email "watergis+githubci@users.noreply.github.com" - git remote set-url origin https://x-access-token:${NODE_AUTH_TOKEN}@github.com/watergis/mapbox-gl-legend.git + git remote set-url origin https://x-access-token:${NODE_AUTH_TOKEN}@github.com/watergis/maplibre-gl-legend.git npm run deploy \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cae657..8cc925b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,8 +22,8 @@ jobs: run: | npm run build mkdir ./release - cp ./dist/cdn/mapbox-gl-legend.js ./release/. - cp ./css/styles.css ./release/mapbox-gl-legend.css + cp ./dist/cdn/maplibre-gl-legend.js ./release/. + cp ./css/styles.css ./release/maplibre-gl-legend.css - name: Create Release id: create_release uses: actions/create-release@latest diff --git a/.gitignore b/.gitignore index ce90799..0dbbd3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ dist docs/bundle*.js -docs/mapbox-gl-legend.* +docs/maplibre-gl-legend.* # Logs logs diff --git a/README.md b/README.md index 25fecbe..887dec9 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ -# mapbox-gl-legend -![badge](https://github.com/watergis/mapbox-gl-legend/workflows/build/badge.svg) -![badge](https://github.com/watergis/mapbox-gl-legend/workflows/deploy%20gh-pages/badge.svg) -![](https://github.com/watergis/mapbox-gl-legend/workflows/Release%20Draft/badge.svg) -![](https://github.com/watergis/mapbox-gl-legend/workflows/Node.js%20Package/badge.svg) -![GitHub](https://img.shields.io/github/license/watergis/mapbox-gl-legend) +# maplibre-gl-legend +![badge](https://github.com/watergis/maplibre-gl-legend/workflows/build/badge.svg) +![badge](https://github.com/watergis/maplibre-gl-legend/workflows/deploy%20gh-pages/badge.svg) +![](https://github.com/watergis/maplibre-gl-legend/workflows/Release%20Draft/badge.svg) +![](https://github.com/watergis/maplibre-gl-legend/workflows/Node.js%20Package/badge.svg) +![GitHub](https://img.shields.io/github/license/watergis/maplibre-gl-legend) -This module adds legend control which is able to create legend panel from mapbox style to mapbox-gl. +This module adds legend control which is able to create legend panel from mapbox style to maplibre-gl. It was forked from [maplibre-gl-export](https://github.com/watergis/maplibre-gl-export). This module is using source code of [orangemug/legend-symbol](https://github.com/orangemug/legend-symbol). I just adopted this library to normal Mapbox GL Plugin. Thanks so much to develop this library! ## Installation: ```bash -npm i @watergis/mapbox-gl-legend --save +npm i @watergis/maplibre-gl-legend --save ``` ## Use CDN ```html - - - + + + + diff --git a/docs/index.ts b/docs/index.ts index 41d7e24..5b7ac8c 100644 --- a/docs/index.ts +++ b/docs/index.ts @@ -1,18 +1,16 @@ -import mapboxgl from 'mapbox-gl'; -import { MapboxLegendControl, LegendOptions } from '../lib/index'; +import maplibregl from 'maplibre-gl'; +import { MaplibreLegendControl, LegendOptions } from '../lib/index'; import '../css/styles.css'; (()=>{ - // mapboxgl.accessToken='your mapbox access token' - const map = new mapboxgl.Map({ + const map = new maplibregl.Map({ container: 'map', - // style: 'mapbox://styles/mapbox/streets-v11', style:'https://narwassco.github.io/mapbox-stylefiles/unvt/style.json', center: [35.87063, -1.08551], zoom: 12, hash:true, }); - map.addControl(new mapboxgl.NavigationControl(), 'top-right'); + map.addControl(new maplibregl.NavigationControl(), 'top-right'); map.on('load', function() { const targets = { @@ -46,7 +44,7 @@ import '../css/styles.css'; onlyRendered: true, reverseOrder: true } - map.addControl(new MapboxLegendControl(targets, options), 'top-right'); + map.addControl(new MaplibreLegendControl(targets, options), 'top-right'); // add legend control with checkbox, and it will be shown as default options = { @@ -55,7 +53,7 @@ import '../css/styles.css'; onlyRendered: true, reverseOrder: false } - map.addControl(new MapboxLegendControl(targets, options), 'bottom-right'); + map.addControl(new MaplibreLegendControl(targets, options), 'bottom-right'); // add legend control with all layers, and it reverse layer order options = { @@ -64,6 +62,6 @@ import '../css/styles.css'; onlyRendered: false, reverseOrder: true } - map.addControl(new MapboxLegendControl({}, options), 'bottom-left'); + map.addControl(new MaplibreLegendControl({}, options), 'bottom-left'); }); })() \ No newline at end of file diff --git a/docs/index2.html b/docs/index2.html index a9b7655..1f2c863 100644 --- a/docs/index2.html +++ b/docs/index2.html @@ -4,9 +4,9 @@ Example - + - +