Code Monkey home page Code Monkey logo

preact-leaflet's Introduction

preact-leaflet

๐Ÿšง This library is current under construction. ๐Ÿšง

Currently Supporting the following Leaflet components:

Example

import { h } from 'preact';
import { SvgIcon } from './SvgIcon';
import {
  MapContainer,
  TileLayer,
  Marker,
} from 'preact-leaflet';
import 'leaflet/dist/leaflet.css';
import './styles.css';


export const App = () => {
  return (
    <MapContainer
      // ref={this.mapRef}
      center={[51.505, -0.09]}
      zoom={13}
      options={{
        // Options
        // preferCanvas: false,

        // Control Options
        // attributionControl: true,
        // zoomControl: true,

        // Interaction Options
        // closePopupOnClick: true,
        // zoomSnap: 1,
        // zoomDelta: 1,
        // trackResize: true,
        // boxZoom: true,
        // doubleClickZoom: true,
        // dragging: true,

        // Map State Options
        // crs:
        // center: [51.505, -0.09],
        // zoom: 13,
        // minZoom: // Number
        // maxZoom: // Number
        // layers: [],
        // maxBounds: null,
        // rendered:

        // Animation Options
        // zoomAnimation: true,
        // zoomAnimationThreshold: 4,
        // fadeAnimation: true,
        // markerZoomAnimation: true,
        // transform3DLimit:

        // Panning Inertia Options
        // inertia:
        // inertiaDeceleration:
        // inertiaMaxSpeed:
        // easeLinearity:
        // worldCopyJump:
        // maxBoundsViscosity:

        // Keyboard Navigation Options
        // keyboard:
        // keyboardPanDelta:

        // Mouse wheel options
        // scrollWheelZoom:
        // wheelDebounceTime:
        // wheelPxPerZoomLevel:

        // Touch interaction options
        // tapHold:
        // tapTolerance:
        // touchZoom:
        // bounceAtZoomLimits:
      }}
    >
      <TileLayer
        // to use mapbox
        url="https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
        // to use open street maps
        // url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        options={{
          // to use mapbox
          attribution: "Map data &copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors, Imagery ยฉ <a href='https://www.mapbox.com/'>Mapbox</a>",
          // to use open street maps
          // attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
          maxZoom: 18,
          id: 'mapbox/streets-v11',
          tileSize: 512,
          zoomOffset: -1,
          // required for mapbox
          accessToken: '',
          // crossOrigin: false,
        }}
      />
      <Marker
        position={[51.5, -0.09]}
        icon={SvgIcon}
        options={{
          title: 'this is my title',
          opacity: 0.5,
        }}
      />
    </MapContainer>
  );
}

API

This project is a thin wrapper around the native leafletjs library.

Options

  • Support for all Map options
  • Support for all Marker options
  • Support for all Tile Layer options

TODO: Handle Event listeners

  • Support for all Map events
  • Support for all Marker events
  • Support for all Tile Layer events

TODO:

  • Add ability to get a ref to Markers and TileLayer

Contributing

Yes. Do it. All about that.

How to contribute

  1. Fork the project
  2. Create a feature branch (git checkout -b f/amazingFeature)
  3. Commit your changes (git commit -m 'added awesome sauce')
  4. Push to the remote branch (git push origin f/amazingFeature)
  5. Open a pull request.

Contributors: 1

Acknowledgments

Inspiration for the library was initially taken from the now archived kontrollanten/preact-leaflet. It has since been completely re-written.

preact-leaflet's People

Contributors

christopherhbutler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.