Skip to content

Commit

Permalink
Merge pull request #4 from watergis/update-npm-package
Browse files Browse the repository at this point in the history
updated npm packages and removed mapbox specified code
  • Loading branch information
JinIgarashi authored Aug 12, 2022
2 parents 2985703 + 614df68 commit 692da81
Show file tree
Hide file tree
Showing 11 changed files with 2,884 additions and 6,569 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x
- run: npm ci
- name: build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x
registry-url: https://registry.npmjs.org/
# Defaults to the user or organization that owns the workflow file
scope: '@watergis'
Expand All @@ -32,7 +32,7 @@ jobs:
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x
registry-url: https://npm.pkg.github.com/
# Defaults to the user or organization that owns the workflow file
scope: '@watergis'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x
- run: npm ci
env:
CI: true
Expand Down
1 change: 1 addition & 0 deletions docs/bundle.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! https://mths.be/punycode v1.3.2 by @mathias */
2 changes: 1 addition & 1 deletion docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../css/styles.css';
zoom: 12,
hash:true,
});
map.addControl(new maplibregl.NavigationControl(), 'top-right');
map.addControl(new maplibregl.NavigationControl({}), 'top-right');

map.on('load', function() {
const targets = {
Expand Down
2 changes: 1 addition & 1 deletion docs/index2.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
zoom: 12,
hash:true,
});
map.addControl(new maplibregl.NavigationControl(), 'top-right');
map.addControl(new maplibregl.NavigationControl({}), 'top-right');
map.on('load', function() {
const targets = {
'pipeline': 'Pipeline',
Expand Down
22 changes: 6 additions & 16 deletions lib/legend-control.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import maplibregl, { accessToken, baseApiUrl, IControl, Map as MaplibreMap } from "maplibre-gl";
import { ControlPosition, IControl, LayerSpecification, Map as MaplibreMap } from "maplibre-gl";
import LegendSymbol from '@watergis/legend-symbol';
import axios from 'axios';

Expand All @@ -8,7 +8,6 @@ export type LegendOptions = {
showCheckbox: boolean;
reverseOrder: boolean;
onlyRendered: boolean;
accesstoken?: string;
title?: string;
}

Expand Down Expand Up @@ -38,7 +37,6 @@ export default class MaplibreLegendControl implements IControl
showCheckbox: true,
reverseOrder: true,
onlyRendered: true,
accesstoken: undefined,
title: undefined,
};
private sprite = {
Expand All @@ -56,7 +54,7 @@ export default class MaplibreLegendControl implements IControl
this.onDocumentClick = this.onDocumentClick.bind(this);
}

public getDefaultPosition(): string
public getDefaultPosition(): ControlPosition
{
const defaultPosition = "top-right";
return defaultPosition;
Expand Down Expand Up @@ -84,7 +82,7 @@ export default class MaplibreLegendControl implements IControl
* @param layer mapboxgl.Layer object
* @returns HTMLElement | undefined return TD Element
*/
private createLayerCheckbox(layer: maplibregl.Layer): HTMLElement | undefined
private createLayerCheckbox(layer: LayerSpecification): HTMLElement | undefined
{
if (!this.options.showCheckbox) return;
const this_ = this;
Expand Down Expand Up @@ -130,7 +128,7 @@ export default class MaplibreLegendControl implements IControl
* @param layer mapboxgl.Layer object
* @returns HTMLElement | undefined return TR Element
*/
private getLayerLegend(layer: maplibregl.Layer): HTMLElement | undefined
private getLayerLegend(layer: LayerSpecification): HTMLElement | undefined
{
const map = this.map;
const zoom = map?.getZoom();
Expand Down Expand Up @@ -357,17 +355,9 @@ export default class MaplibreLegendControl implements IControl
if (map.loaded()) {
const style = map.getStyle();
let styleUrl = style.sprite;
let strToken = '';
if (styleUrl && styleUrl.includes('mapbox://')){
styleUrl = styleUrl
.replace(/mapbox:\/\//g, baseApiUrl)
.replace(/sprites/g,'/styles/v1');
styleUrl = `${styleUrl}/sprite`;
strToken = `?access_token=${this.options.accesstoken || accessToken}`;
}
const promise = Promise.all([
this.loadImage(`${styleUrl}@2x.png${strToken}`),
this.loadJson(`${styleUrl}.json${strToken}`),
this.loadImage(`${styleUrl}@2x.png`),
this.loadJson(`${styleUrl}.json`),
]);
await promise.then(([image, json]) => {this.setSprite(image, json)});
this.updateLegendControl();
Expand Down
Loading

0 comments on commit 692da81

Please sign in to comment.