JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q36548F
  • License MIT

Compass pro for react-map-gl based projects

Package Exports

  • map-gl-compass-pro
  • map-gl-compass-pro/dist/cjs/index.js
  • map-gl-compass-pro/dist/esm/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (map-gl-compass-pro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

map-gl-compass-pro npm npm downloads

New generation maps require new generation tools!

Screen

Example implementation

Usage

As for now map-gl-compass-pro works only with react & react-map-gl (react-map-gl is peer dependency). If community will express will of using it with raw mapbox / maplibre library I will add some wrapper around this component.

import MapGL from 'react-map-gl'
import maplibregl from 'maplibre-gl'
import CompassPro from 'map-gl-compass-pro'

function Map(){

  (...)

  return (
      <MapGL
        initialViewState={{
          longitude: 14.5580,
          latitude: 53.4441,
          zoom: 14
        }}
        mapLib={maplibregl}
        mapStyle="https://my-domain.com/mapStyle.json"
      >
        <CompassPro 
          mapId="myMap" // optional, default: current
          size="lg" // optional, one of 'sm' | 'md' | 'lg', default: 'md', 
          visualizePitch={true} // optional, default false
          onNeedleClick={handleNeedleClick} // optional, default map.resetNorth() & map.resetNortPitch() is called
          wrapperClass="ownClassName" // optional, default absolutely positioned in bottom left corner
        />
      (...)    
      </MapGL>
    );
}

Please make sure that Compass is child of MapGL, otherwise it won't work. Also read more about react-map-gl setup and mapId.