Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/watergis/mapbox-gl-area-switcher
This module adds area switcher control which is able to change locations of area quickly to mapbox-gl
https://github.com/watergis/mapbox-gl-area-switcher
demo mapbox-gl
Last synced: 2 months ago
JSON representation
This module adds area switcher control which is able to change locations of area quickly to mapbox-gl
- Host: GitHub
- URL: https://github.com/watergis/mapbox-gl-area-switcher
- Owner: watergis
- License: mit
- Created: 2020-07-25T14:17:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-22T14:37:35.000Z (over 1 year ago)
- Last Synced: 2024-10-30T05:43:08.714Z (3 months ago)
- Topics: demo, mapbox-gl
- Language: TypeScript
- Homepage: https://watergis.github.io/mapbox-gl-area-switcher/#12/-1.08551/35.87063
- Size: 98.6 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# mapbox-gl-area-switcher
![](https://github.com/watergis/mapbox-gl-area-switcher/workflows/Node.js%20Package/badge.svg)
![GitHub](https://img.shields.io/github/license/watergis/mapbox-gl-area-switcher)This module adds area switcher control which is able to change locations of area to mapbox-gl
## Installation:
```bash
npm i @watergis/mapbox-gl-area-switcher --save
```## Demo:
Try [codesandbox](https://codesandbox.io/s/mapbox-gl-area-switcher-mqd8f?file=/src/index.ts).
See [demo](https://watergis.github.io/mapbox-gl-area-switcher/#12/-1.08551/35.87063).
## Test:
```
npm run build
npm start
```open [http://localhost:8080](http://localhost:8080).
## Usage:
```ts
import MapboxAreaSwitcherControl from "@watergis/mapbox-gl-area-switcher";
import { Map as MapboxMap } from "mapbox-gl";import "@watergis/mapbox-gl-area-switcher/css/styles.css";
const map = new MapboxMap();
map.addControl(new MapboxAreaSwitcherControl([
{title: 'Narok',latlng: [35.87063, -1.08551],zoom: 14,},
{title: "Ololulung'a",latlng: [35.65072, -1.0085],zoom: 13},
{title: "Kilgoris",latlng: [34.87533, -1.00278],zoom: 14},
{title: "Suswa",latlng: [36.33078, -1.05307],zoom: 13}
]), 'top-right');
```Specify your areas which you want to change the location quickly by the control.
If number of areas is more than 5, the control will become select box in order to avoid the control become too long. The default limit number of areas can be changed in the second parameter. You may change as below.
```ts
map.addControl(new MapboxAreaSwitcherControl([
{title: 'Narok',latlng: [35.87063, -1.08551],zoom: 14,},
{title: "Ololulung'a",latlng: [35.65072, -1.0085],zoom: 13},
{title: "Kilgoris",latlng: [34.87533, -1.00278],zoom: 14},
{title: "Suswa",latlng: [36.33078, -1.05307],zoom: 13}
], 3), 'top-right');
```