0.0.12 • Published 5 months ago

@undp-data/cgaz-admin-tool v0.0.12

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
5 months ago

@undp-data/cgaz-admin-tool

Install

pnpm i -D @undp-data/cgaz-admin-tool

Usage

import MaplibreCgazAdminControl from '@undp-data/cgaz-admin-tool';
import '@undp-data/cgaz-admin-tool/dist/maplibre-cgaz-admin-control.css';

const options = {
	url: 'https://undpngddlsgeohubdev01.blob.core.windows.net/admin/cgaz-geoboundaries.pmtiles',
	attribution: `Administrative boundaries courtesy of <a href= 'https://www.geoboundaries.org'>geoBoundaries</a>`,
	isHover: true,
	sourceId: 'cgaz',
	layerId: 'cgaz',
	sourceLayer: 'admin',
	featureId: 'id',
	maxZoom: 10,
	adminRange: [0, 2],
	adminName: 'admin{level}_name',
	fillColor: 'hsla(0, 0%, 0%, 0.25)',
	fillOutlineColor: 'hsla(0, 0%, 0%, 1)'
};

map.addControl(new MaplibreCgazAdminControl(options), 'top-left');

In order to use this plugin, please also setup PMTiles Javascript API as follows.

pnpm i -D pmtiles
import maplibregl from 'maplibre-gl';
import * as pmtiles from 'pmtiles';

let protocol = new pmtiles.Protocol();
maplibregl.addProtocol('pmtiles', protocol.tile);

Options

PropertyDescriptionDefault
urlURL for CGAZ PMTilesURL
attributionAttribution for CGAZAdministrative boundaries courtesy of geoBoundaries
isHoverIf true, hovering by feature ID will be enabled. Default is true.true
sourceIdSource ID for maplibre.cgaz
layerIdlayer ID for maplibre.cgaz
sourceLayersource-layer property value for maplibre.admin
featureIdFeatureState ID.id
maxZoomMax zoom level of CGAZ PMTiles.10
adminRangeRange of admin levels covered.0, 2 (level 0 to 2)
adminNamefield name of administrative boundaries. {level} is replaced with admin level."admin{level}_name".
fillColorfill-color property value for CGAZ polygon layer.'hsla(0, 0%, 0%, 0.25)'
fillOutlineColorfill-outline-color property value for CGAZ polygon layer.'hsla(0, 0%, 0%, 1)'

create-svelte

Everything you need to build a Svelte library, powered by create-svelte.

Read more about creating a library in the docs.

Creating a project

If you're seeing this, you've probably already done this step. Congrats!

# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app

Developing

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Everything inside src/lib is part of your library, everything inside src/routes can be used as a showcase or preview app.

Building

To build your library:

npm run package

To create a production version of your showcase app:

npm run build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

Publishing

Go into the package.json and give your package the desired name through the "name" option. Also consider adding a "license" field and point it to a LICENSE file which you can create from a template (one popular option is the MIT license).

To publish your library to npm:

npm publish
0.0.10

6 months ago

0.0.11

5 months ago

0.0.12

5 months ago

0.0.9

9 months ago

0.0.8

10 months ago

0.0.7

11 months ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago