npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mapcomponents/react-maplibre

v1.0.9

Published

[![npm version](https://badge.fury.io/js/@mapcomponents%2Freact-maplibre.svg)](https://badge.fury.io/js/@mapcomponents%2Freact-maplibre) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![downloads]

Downloads

788

Readme

MapComponents MapLibre

npm version License: MIT downloads downloads

Tests

@mapcomponents/react-maplibre is a react component library for declarative GIS application development.

Links

  • Documentation: https://mapcomponents.github.io/react-map-components-maplibre/
  • Catalogue: https://www.mapcomponents.org/

Getting started

Use our Codesandbox template to quickly try out this library without any setup required. https://codesandbox.io/s/base-template-n0vp9

How to use @mapcomponents/react-maplibre in ...

... a new project

The easiest way to start a new project using this framework is to bootstrap a react application using our vite-template.

Requirements:

  1. node.js >=16
  2. yarn

Run the following commands in the terminal:

npx degit mapcomponents/template {your-app-name}
cd {your-app-name}
yarn
yarn dev

This will start a development server that serves the mapcomponents app on port 5174 of your local machine as well as a browser tab with live reload enabled. This reloads the affected parts of the application if changes are detected to the corresponding files in the filesystem. Open the project folder in the IDE of your choice and start building your map client.

... an existing react project

In this case, navigate to your project folder in a terminal and execute the following steps:

  1. Add @mapcomponents/react-maplibre as a dependency to your project using yarn add @mapcomponents/react-maplibre.
  2. Add the MapComponentsProvider (named export of this module) to your applications react-DOM where it makes sense. Only children of this component will be able to render a map canvas or interact with a maplibre-gl instance. Place it in the index.js entrypoint if your application is a dedicated map app and all components have a high probability to interact with the maplibre-gl instance. Place it somewhere higher in the JSX tree if the map constitutes only a small portion of your app and components outside of the MapComponentsProvider have no need to interact with the map instance.
  3. Add a MapLibreMap component to the react-DOM wherever the map canvas is supposed to be placed.

Adding data to the map

The easiest way to add data to the map is using GeoJSON data and the MlGeoJsonLayer component. The MlGeoJsonLayer component is designed to require only the geojson property to be set, while it provides properties to fully customize it to your needs.

Insert the following code in your app below index.tsx to add a GeoJSON layer to your map.

import MlGeoJsonLayer from '@mapcomponents/react-maplibre';

const geojson_data = {
	"type": "Feature",
	"properties": {},
	"geometry": {
		"coordinates": [
			[
				[0.7415817264899545, 56.91203727013931],
				[0.7743616447289128, 55.2757658775181],
				[4.609612078732766, 55.23840364745948],
				[4.642391996971725, 56.91203727013931],
				[0.7415817264899545, 56.91203727013931]
			]
		],
		"type": "Polygon"
	}
}

And add the following within the JSX.

<MlGeoJsonLayer geojson={geojson_data} />

Please take a look at our storybooks and the code examples provided in the {ComponentName}.stories.tsx files next to the Components in the ./src/components/ folder.

more links

  • @mapcomponents/react-maplibre storybook: https://mapcomponents.github.io/react-map-components-maplibre
  • @mapcomponents/react-maplibre-lab storybook: https://mapcomponents.github.io/react-map-components-maplibre-lab