All Projects → jimutt → Svelte Pick A Place

jimutt / Svelte Pick A Place

Licence: mit
Javascript location picker built with Svelte

Projects that are alternatives of or similar to Svelte Pick A Place

o.map
Open Street Map app - KaiOS
Stars: ✭ 51 (+15.91%)
Mutual labels:  leaflet, location
Leaflet Gps
Simple leaflet control plugin for tracking gps position
Stars: ✭ 90 (+104.55%)
Mutual labels:  location, leaflet
kirby-locator
A simple map & geolocation field, built on top of open-source services and Mapbox. Kirby 3 only.
Stars: ✭ 83 (+88.64%)
Mutual labels:  leaflet, location
svelte-leaflet
Svelte component for leaflet.
Stars: ✭ 37 (-15.91%)
Mutual labels:  leaflet, svelte
Leaflet Locatecontrol
A leaflet control to geolocate the user.
Stars: ✭ 539 (+1125%)
Mutual labels:  location, leaflet
Leaflet
🍃 JavaScript library for mobile-friendly interactive maps
Stars: ✭ 32,591 (+73970.45%)
Mutual labels:  leaflet
Svelte Preprocess
A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
Stars: ✭ 970 (+2104.55%)
Mutual labels:  svelte
Pelias Android Sdk
Android sdk for pelias
Stars: ✭ 20 (-54.55%)
Mutual labels:  location
Smelte
UI framework with material components built with Svelte and Tailwind CSS
Stars: ✭ 871 (+1879.55%)
Mutual labels:  svelte
R Community Explorer
Data-Driven Exploration of the R Community
Stars: ✭ 43 (-2.27%)
Mutual labels:  leaflet
Cassetter
Cassetter is a MIDI controlled granular sampler
Stars: ✭ 37 (-15.91%)
Mutual labels:  svelte
Pizza Delivery
university project : Android pizza delivery app
Stars: ✭ 32 (-27.27%)
Mutual labels:  location
Leaflet Ais Tracksymbol
AIS Extension for leaflet-tracksymbol It can display AIS Contacts on the Map.
Stars: ✭ 27 (-38.64%)
Mutual labels:  leaflet
Omni
Distributed publishing platform and discussion network for scholars. Establishing an unenclosable scholarly commons.
Stars: ✭ 34 (-22.73%)
Mutual labels:  svelte
Leaflet.markercluster.freezable
Adds ability to freeze clusters at specified zoom
Stars: ✭ 21 (-52.27%)
Mutual labels:  leaflet
Jsx Lite
Write components once, run everywhere. Compiles to Vue, React, Solid, Angular, Svelte, and Liquid.
Stars: ✭ 1,015 (+2206.82%)
Mutual labels:  svelte
Pm2.5 Idw Map
PM2.5 IDW Map from PM2.5 open data portal
Stars: ✭ 14 (-68.18%)
Mutual labels:  leaflet
Why Svelte
Why Svelte is our choice for a large web project in 2020
Stars: ✭ 953 (+2065.91%)
Mutual labels:  svelte
Leaflet.extras2
Extra functionality for leaflet R package.
Stars: ✭ 37 (-15.91%)
Mutual labels:  leaflet
Sapper Template Firebase
Starter Rollup template for Sapper apps with Firebase functions based on https://github.com/nhristov/sapper-template-rollup.
Stars: ✭ 29 (-34.09%)
Mutual labels:  svelte

npm version

Svelte component for position and area selection with Leaflet.

The component presents a Leaflet map on which the user can click to select a position or an area (through drawing a polygon). update and save events are emitted with the selected geometry in GeoJSON format.

Codepen demo JS API: https://codepen.io/jimutt/pen/XLjaqV

Codepen demo Bootstrap 3 form + modal: https://codepen.io/jimutt/pen/ZgaYBP?editors=1010

Usage

The component comes with basic styling and is made to fill the parent container. You need to supply a Leaflet instance to the component's leaflet prop.

Example in Svelte app:

<script>
  import leaflet from 'leaflet';
  import PickAPlace from 'svelte-pick-a-place';
</script>

<PickAPlace leaflet={leaflet} on:update={() => console.log('Update!')} on:save={() =>
console.log('On save!')} />

Example usage with Javascript API in legacy app:

Include IIFE build and stylesheet from unpkg, use the "-legacy" suffixed JS file if you need IE11 support and don't mind the much larger file size:

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/pick-a-place.css" />
<script src="https://unpkg.com/[email protected]/dist/pick-a-place.min.js"></script>

<!-- Or use build with IE11 support: -->
<script src="https://unpkg.com/[email protected]/dist/pick-a-place-legacy.min.js"></script>

Add component:

let pickAPlace = new PickAPlace({
  target: document.getElementById('map'),
  props: {
    leaflet: window.L
  }
});

// Listen to events through component.$on('eventName', callback)
pickAPlace.$on('update', ({ detail }) => {
  console.log('New position: ', detail);
});

Properties

  • leaflet - Leaflet instance
  • lat - wgs84 latitude. Set to 45 by default.
  • lng - wgs84 longitude. Set to 0 by default.
  • zoom - Map zoom level. Set to 3 by default.
  • guideOverlay - Show text overlay with instructions and picked lat/lng. True by default.
  • buttons - Show cancel & save buttons. True by default.
  • selectionModes - Array with enabled selection modes. Default: ['point', 'polygon']
  • selection - Default/initial position/area selection, supports a GeoJSON feature with a geometry object of type Point or type Polygon.

Events

  • update - Emitted on new selected location. The detail property of the event object contains the selection. If selection mode is "point" a GeoJSON feature with Point geometry is returned. If selection mode is "polygon" the update event is emitted when she polygon is finished/closed, the detail property will contain a GeoJSON feature with Polygon geometry.
  • save - Emitted on save button click. The detail property of the event object contains the selection. If selection mode is "point" a GeoJSON feature with Point geometry is returned. If selection mode is "polygon" the detail property will contain a GeoJSON feature with Polygon geometry.
  • cancel - Emitted on cancel button click.

TODO

  • More tests, test coverage is extremely poor at the moment.
  • Well-written docs.

Credits

The component was originally created from the component project template by Yogev: https://github.com/YogliB/svelte-component-template

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].