-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge mapbox-gl-export to this repository (#52)
- Loading branch information
1 parent
ad4aa86
commit a03a84b
Showing
55 changed files
with
3,240 additions
and
1,950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
"@watergis/mapbox-gl-export": major | ||
--- | ||
|
||
This release has breaking changes. | ||
|
||
- merged [mapbox-gl-export](https://github.com/watergis/mapbox-gl-export) repository to `maplibre-gl-export`. | ||
- added Spanish language and Japanese language from `maplibre-gl-export` | ||
- added `Filename` option from `maplibre-gl-export` to allow to change default file name from `map`. | ||
- added `AllowedSizes` option from `maplibre-gl-export` to allow to set available file sizes. | ||
- the URL of CDN script and css were changed. Use the below URLs for CDN. | ||
|
||
```html | ||
<link href="https://www.unpkg.com/@watergis/mapbox-gl-export@latest/dist/mapbox-gl-export.css" rel="stylesheet" /> | ||
<script src="https://www.unpkg.com/@watergis/mapbox-gl-export@latest/dist/maplibre-gl-export.umd.js"></script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@watergis/maplibre-gl-export": minor | ||
--- | ||
|
||
feat: upgrade maplibre dependencies to v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@watergis/maplibre-gl-export": patch | ||
--- | ||
|
||
feat: added `LETTER` page size (migrated it from `mapbox-gl-export`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
}, | ||
"homepage": "https://github.com/watergis/maplibre-gl-export#readme", | ||
"devDependencies": { | ||
"@changesets/cli": "^2.26.0", | ||
"lefthook": "^1.2.9" | ||
"@changesets/cli": "^2.27.1", | ||
"lefthook": "^1.6.5" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_MAPBOX_ACCESSTOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
/dist | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
# Ignore files for PNPM, NPM and YARN | ||
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], | ||
plugins: ['@typescript-eslint'], | ||
ignorePatterns: ['*.cjs'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 2020 | ||
}, | ||
env: { | ||
browser: true, | ||
es2017: true, | ||
node: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
/dist | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
# Ignore files for PNPM, NPM and YARN | ||
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock | ||
*.md | ||
.github/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"useTabs": true, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"printWidth": 100, | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Jin IGARASHI | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
# mapbox-gl-export | ||
|
||
![build](https://github.com/watergis/maplibre-gl-export/workflows/build/badge.svg) | ||
![GitHub](https://img.shields.io/github/license/watergis/maplibre-gl-export) | ||
|
||
This module adds control which can export PDF and images. | ||
|
||
This module is using source code of [mpetroff/print-maps](https://github.com/mpetroff/print-maps). I just adopted this library to normal Mapbox GL Plugin. Thanks so much to develop this library! | ||
|
||
## for Maplibre GL users | ||
|
||
Please consider to use [maplibre-gl-export](https://github.com/watergis/maplibre-gl-export) plugin for Maplibre GL. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm i @watergis/mapbox-gl-export --save | ||
``` | ||
|
||
## Use CDN | ||
|
||
```html | ||
<link href="https://www.unpkg.com/@watergis/mapbox-gl-export@latest/dist/mapbox-gl-export.css" rel="stylesheet" /> | ||
<script src='https://api.mapbox.com/mapbox-gl-js/v1.13.1/mapbox-gl.js'></script> | ||
<script src="https://www.unpkg.com/@watergis/mapbox-gl-export@latest/dist/maplibre-gl-export.umd.js"></script> | ||
<script> | ||
map.addControl(new MapboxExportControl({ | ||
PageSize: Size.A3, | ||
PageOrientation: PageOrientation.Portrait, | ||
Format: Format.PNG, | ||
DPI: DPI[96], | ||
Crosshair: true, | ||
PrintableArea: true, | ||
}), 'top-right'); | ||
</script> | ||
``` | ||
|
||
Furthermore, you may download specific version's scripts and css locally from [release](https://github.com/watergis/maplibre-gl-export/releases) page. | ||
|
||
## Demo | ||
|
||
Try [codesandbox](https://codesandbox.io/s/mapbox-gl-export-8x4lw?file=/src/index.ts). | ||
|
||
See [demo](https://watergis.github.io/mapbox-gl-export/#12/-1.08551/35.87063). | ||
|
||
![demo.gif](./demo.gif) | ||
|
||
## Usage | ||
|
||
```ts | ||
import { MapboxExportControl, Size, PageOrientation, Format, DPI} from "@watergis/mapbox-gl-export"; | ||
import '@watergis/mapbox-gl-export/dist/mapbox-gl-export.css'; | ||
import mapboxgl from 'mapbox-gl'; | ||
|
||
const map = new mapboxgl.Map(); | ||
// create control with default options | ||
map.addControl(new MapboxExportControl(), 'top-right'); | ||
// create control with specified options | ||
map.addControl(new MapboxExportControl({ | ||
PageSize: Size.A3, | ||
PageOrientation: PageOrientation.Portrait, | ||
Format: Format.PNG, | ||
DPI: DPI[96], | ||
Crosshair: true, | ||
PrintableArea: true | ||
}), 'top-right'); | ||
``` | ||
|
||
### if you want to use a basemap from Mapbox | ||
|
||
- for mapbox v1 user | ||
|
||
```ts | ||
mapboxgl.accessToken='your mapbox access token' | ||
``` | ||
|
||
- for mapbox v2 user | ||
There is an option of `accessToken` in `MapboxExportControl`. Please put your accessToken when you create a instance of plugin. | ||
|
||
```ts | ||
mapboxgl.accessToken='your mapbox access token' | ||
const map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/streets-v11', | ||
}); | ||
map.addControl(new MapboxExportControl({ | ||
accessToken: 'your mapbox access token' | ||
}), 'top-right'); | ||
``` | ||
|
||
### Options | ||
|
||
You can specify default option as follows. | ||
|
||
- PageSize | ||
- You can select from `A2` to `A6` or `B2` to `B6` | ||
- default page size is `A4` | ||
- PageOrientation | ||
- You can select `landscape` or `portrait` | ||
- default is `landscape` | ||
- Format | ||
- You can select it from `jpg`, `png`, `svg` and `pdf` | ||
- default is `PDF` | ||
- DPI | ||
- You can select it from `72`, `96`, `200`, `300` and `400`. | ||
- default is `300` | ||
- Crosshair | ||
- Display crosshair on the map. it helps to adjust the map center before printing. | ||
- accepts `true` and `false` value | ||
- default is `false` | ||
- PritableArea | ||
- Display printable area on the map it helps to adjust pritable area before printing. | ||
- accepts `true` and `false` value | ||
- default is `false` | ||
- Local | ||
- default `en` for english | ||
- `de` german | ||
- `fr` french | ||
- `fi` finnish | ||
- `sv` swedish | ||
- `es` spanish | ||
- `vi` Vietnam | ||
- `uk` Ukranian | ||
- `zhHans` Chinese Simplified | ||
- `zhHant` Chinese Traditional | ||
- `ja` Japanese | ||
- AllowedSizes | ||
- list of allowed page sizes for export | ||
- available values `'LETTER'`, `'A2'`, `'A3'`, `'A4'`, `'A5'`, `'A6'`, `'B2'`, `'B3'`, `'B4'`, `'B5'`, `'B6'` | ||
- default: all sizes `['LETTER','A2','A3','A4','A5','A6','B2','B3','B4','B5','B6']` | ||
- Filename | ||
- file name template, file part | ||
- default `map` for i.e `map.pdf` | ||
|
||
## Attribution | ||
|
||
When you use exported map, please includes attribution as follows. | ||
|
||
If you can include HTML, use this code snippet that includes links to Mapbox & OpenStreetMap: | ||
|
||
```html | ||
© NARWASSCO, Ltd. © <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> © <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>Powered by the United Nations Vector Tile Toolkit | ||
``` | ||
|
||
For print output or if you can’t include links, use this text-only attribution: | ||
|
||
``` | ||
© NARWASSCO, Ltd. ©Mapbox ©OpenStreetMap contributors, Powered by the United Nations Vector Tile Toolkit | ||
``` | ||
|
||
`© NARWASSCO, Ltd.` is default example of map data by `Narok Water and Sewerage Services Co., Ltd.`, Kenya. If you don't use current map, you don't need to use this attribution. | ||
|
||
Also, default example is using base map by United Nation Vector Tile Toolkit. That is why `Powered by the United Nations Vector Tile Toolkit` is included in above. | ||
|
||
## Development | ||
|
||
```bash | ||
pnpm lint | ||
pnpm format | ||
pnpm dev | ||
``` | ||
|
||
open [http://localhost:5173](http://localhost:5173). | ||
|
||
If there are any changes on source code, it will be reflected automatically. | ||
|
||
## Build package | ||
|
||
``` | ||
pnpm build | ||
``` | ||
|
||
The modules will be generated under `dist` folder. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Example</title> | ||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" | ||
/> | ||
<link href="https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.css" rel="stylesheet" /> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#map { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
width: 100%; | ||
z-index: 10; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<a | ||
class="github-fork-ribbon left-top" | ||
href="https://github.com/watergis/maplibre-gl-export" | ||
data-ribbon="Fork me on GitHub" | ||
title="Fork me on GitHub" | ||
>Fork me on GitHub</a | ||
> | ||
<div id="map"></div> | ||
<script src="https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.js"></script> | ||
<script type="module" src="./index.ts"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.