generated from huanglii/vite-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 🎸 polygon-morpher * docs: ✏️ update
- Loading branch information
Showing
16 changed files
with
547 additions
and
56 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 |
---|---|---|
@@ -1 +1,69 @@ | ||
# vite-lib-template | ||
# @naivemap/mapbox-gl-polygon-morpher | ||
|
||
Morph smoothly between Polygons or MultiPolygons. | ||
|
||
[API Reference](./docs/index.md) | ||
|
||
## Install | ||
|
||
```bash | ||
npm i mapbox-gl @naivemap/mapbox-gl-polygon-morpher | ||
``` | ||
|
||
## Quick start | ||
|
||
```js | ||
import PolygonMorpher from '@naivemap/mapbox-gl-polygon-morpher' | ||
|
||
const map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/streets-v12', | ||
center: [-74.5, 40], | ||
zoom: 9 | ||
}) | ||
|
||
map.on('load', () => { | ||
map.addSource('geojson-source', { | ||
type: 'geojson', | ||
data: { | ||
type: 'FeatureCollection', | ||
features: [] | ||
} | ||
}) | ||
map.addLayer( | ||
{ | ||
id: 'poly-layer', | ||
type: 'fill', | ||
source: 'geojson-source', | ||
paint: { | ||
'fill-color': 'rgba(152, 224, 173, 0.5)' | ||
} | ||
}, | ||
'aeroway-line' | ||
) | ||
const geojsonSource = map.getSource('geojson-source') as mapboxgl.GeoJSONSource | ||
const polygonMorpher = new PolygonMorpher(geojsonSource) | ||
|
||
polygonMorpher.morph(feature) | ||
}) | ||
``` | ||
|
||
## UMD | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link href="https://api.mapbox.com/mapbox-gl-js/v2.11.0/mapbox-gl.css" rel="stylesheet" /> | ||
<script src="https://api.mapbox.com/mapbox-gl-js/v2.11.0/mapbox-gl.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@naivemap/mapbox-gl-polygon-morpher"></script> | ||
</head> | ||
<body> | ||
<div id="map" style="position: absolute; top: 0; right: 0; bottom: 0; left: 0"></div> | ||
<script> | ||
const polygonMorpher = new PolygonMorpher(geojsonSource) | ||
</script> | ||
</body> | ||
</html> | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@naivemap/mapbox-gl-polygon-morpher](./mapbox-gl-polygon-morpher.md) | ||
|
||
## mapbox-gl-polygon-morpher package | ||
|
||
Morph smoothly between Polygons or MultiPolygons. | ||
|
||
## Classes | ||
|
||
| Class | Description | | ||
| --- | --- | | ||
| [PolygonMorpher](./mapbox-gl-polygon-morpher.polygonmorpher.md) | Morph smoothly between Polygons or MultiPolygons. | | ||
|
||
## Interfaces | ||
|
||
| Interface | Description | | ||
| --- | --- | | ||
| [MorphOption](./mapbox-gl-polygon-morpher.morphoption.md) | The option of the morpher. | | ||
|
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@naivemap/mapbox-gl-polygon-morpher](./mapbox-gl-polygon-morpher.md) > [MorphOption](./mapbox-gl-polygon-morpher.morphoption.md) > [maxDuration](./mapbox-gl-polygon-morpher.morphoption.maxduration.md) | ||
|
||
## MorphOption.maxDuration property | ||
|
||
Maximum duration of morphing | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
maxDuration?: number; | ||
``` |
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,20 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@naivemap/mapbox-gl-polygon-morpher](./mapbox-gl-polygon-morpher.md) > [MorphOption](./mapbox-gl-polygon-morpher.morphoption.md) | ||
|
||
## MorphOption interface | ||
|
||
The option of the morpher. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export interface MorphOption | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Modifiers | Type | Description | | ||
| --- | --- | --- | --- | | ||
| [maxDuration?](./mapbox-gl-polygon-morpher.morphoption.maxduration.md) | | number | _(Optional)_ Maximum duration of morphing | | ||
|
21 changes: 21 additions & 0 deletions
21
docs/mapbox-gl-polygon-morpher.polygonmorpher._constructor_.md
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 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@naivemap/mapbox-gl-polygon-morpher](./mapbox-gl-polygon-morpher.md) > [PolygonMorpher](./mapbox-gl-polygon-morpher.polygonmorpher.md) > [(constructor)](./mapbox-gl-polygon-morpher.polygonmorpher._constructor_.md) | ||
|
||
## PolygonMorpher.(constructor) | ||
|
||
Constructs a new instance of the PolygonMorpher class | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
constructor(source: mapboxgl.GeoJSONSource, option?: MorphOption); | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| source | mapboxgl.GeoJSONSource | The GeoJSONSource to be updated. | | ||
| option | [MorphOption](./mapbox-gl-polygon-morpher.morphoption.md) | _(Optional)_ The option of the morpher. | | ||
|
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,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@naivemap/mapbox-gl-polygon-morpher](./mapbox-gl-polygon-morpher.md) > [PolygonMorpher](./mapbox-gl-polygon-morpher.polygonmorpher.md) | ||
|
||
## PolygonMorpher class | ||
|
||
Morph smoothly between Polygons or MultiPolygons. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export default class PolygonMorpher | ||
``` | ||
|
||
## Constructors | ||
|
||
| Constructor | Modifiers | Description | | ||
| --- | --- | --- | | ||
| [(constructor)(source, option)](./mapbox-gl-polygon-morpher.polygonmorpher._constructor_.md) | | Constructs a new instance of the PolygonMorpher class | | ||
|
||
## Methods | ||
|
||
| Method | Modifiers | Description | | ||
| --- | --- | --- | | ||
| [morph(feature)](./mapbox-gl-polygon-morpher.polygonmorpher.morph.md) | | Morph to the given feature | | ||
|
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 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@naivemap/mapbox-gl-polygon-morpher](./mapbox-gl-polygon-morpher.md) > [PolygonMorpher](./mapbox-gl-polygon-morpher.polygonmorpher.md) > [morph](./mapbox-gl-polygon-morpher.polygonmorpher.morph.md) | ||
|
||
## PolygonMorpher.morph() method | ||
|
||
Morph to the given feature | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
morph(feature: GeoJSON.Feature<GeoJSON.Polygon | GeoJSON.MultiPolygon>): Promise<void>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| feature | GeoJSON.Feature<GeoJSON.Polygon \| GeoJSON.MultiPolygon> | Feature | | ||
|
||
**Returns:** | ||
|
||
Promise<void> | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
{ | ||
"name": "vite-lib-template", | ||
"name": "@naivemap/mapbox-gl-polygon-morpher", | ||
"version": "0.1.0", | ||
"description": "vite lib", | ||
"repository": "https://github.com/naivemap/vite-lib-template", | ||
"keywords": [], | ||
"author": "huangli", | ||
"description": "Morph smoothly between Polygons or MultiPolygons", | ||
"repository": "https://github.com/naivemap/mapbox-gl-polygon-morpher", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/naivemap/mapbox-gl-polygon-morpher/issues" | ||
}, | ||
"keywords": [ | ||
"mapbox-gl", | ||
"animate", | ||
"morph", | ||
"flubber" | ||
], | ||
"author": "huanglii <[email protected]>", | ||
"license": "MIT", | ||
"main": "./dist/index.umd.js", | ||
"module": "./dist/index.js", | ||
|
@@ -52,6 +63,7 @@ | |
"@microsoft/api-documenter": "^7.19.25", | ||
"@microsoft/api-extractor": "^7.33.6", | ||
"@types/jest": "^29.2.4", | ||
"@types/mapbox-gl": "^2.7.10", | ||
"@types/node": "^18.11.9", | ||
"@typescript-eslint/eslint-plugin": "^5.45.0", | ||
"@typescript-eslint/parser": "^5.45.0", | ||
|
@@ -64,10 +76,17 @@ | |
"husky": "^8.0.2", | ||
"jest": "^29.3.1", | ||
"lint-staged": "^13.0.4", | ||
"mapbox-gl": "^2.13.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.8.0", | ||
"ts-jest": "^29.0.3", | ||
"typescript": "^4.9.3", | ||
"vite": "^3.2.4" | ||
}, | ||
"dependencies": { | ||
"@turf/area": "^6.5.0", | ||
"@turf/intersect": "^6.5.0", | ||
"flubber": "^0.4.2", | ||
"geojson-tools": "^0.2.2" | ||
} | ||
} |
Oops, something went wrong.