map-gl-geolocation
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

MapGL Geolocation Plugin

A mapbox-gl-js plugin to enable custom geolocation providers.

The project should works with maplibre-gl-js too.

Screenshot

Note: This is a work in progress and we welcome contributions.

Usage

import { Map } from 'mapbox-gl';
import { addGeolocationTo, GeolocationControl } from 'map-gl-geolocation';

const map = new Map({
    accessToken,
    container,
    style: 'mapbox://styles/mapbox/streets-v10'
});

// Create the geoloc logic behind the map.geolocation property
addGeolocationTo(map);

// Set the position and the heading to a custom location
map.geolocation.position = ({ lat: 43.608749, lng: 3.883528, accuracy: 10 });
map.geolocation.heading = 280;

// Add the specific control
map.addControl(new GeolocationControl());

Options

Refer to example for usage.

Test the project / Contribute

npm install & npm run dev

Go to http://localhost:3000/example/

Package Sidebar

Install

npm i map-gl-geolocation

Weekly Downloads

7

Version

0.4.1

License

MIT

Unpacked Size

36.3 kB

Total Files

7

Last publish

Collaborators

  • map-gl-indoor