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

vue2-leaflet-freedraw

v1.0.4

Published

A Vue2Leaflet wrapper for Freedraw

Downloads

345

Readme

Vue2-Leaflet-Freedraw

This is a FreeDraw plugin for Vue2-Leaflet

Install

npm install --save leaflet vue2-leaflet vue2-leaflet-freedraw

or with yarn:

yarn add leaflet vue2-leaflet vue2-leaflet-freedraw

Demo

git clone https://github.com/Esurnir/vue2-leaflet-freedraw.git
cd vue2-leaflet-freedraw
yarn
yarn serve

The demo should compile and be visible from http://localhost:8080/ The source code of the demo is in the dev folder.

Usage

on <template> add

<l-map :zoom="10" :center="center">
  <l-tile-layer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png" />
  <l-control position="topleft">
    <button @click="flipActive">
      {{ isActive ? 'Deactivate' : 'Activate' }}
    </button>
  </l-control>
  <l-freedraw v-model="polygons" :mode="mode" />
</l-map>

on <script> add

import LFreeDraw from 'vue2-leaflet-freedraw';
import { NONE, ALL } from 'leaflet-freedraw';
...
export default {
  components: {
    ...
    LFreeDraw
  },
  data() {
    return {
      ...
      polygons: [],
      isActive: false,
    }
  },
  computed: {
    mode() {
      return this.isActive ? ALL: NONE;
    }
  },
  methods: {
    flipActive() {
      this.isActive = !this.isActive;
    }
  }
}

Access freedraw directly

If you need to access the freeDraw Object directly : you can do it with a ref on the markercluster vue element and using the mapObject property

...
<l-freedraw ref="freeDrawRef"> ... </l-freedraw>
...
    ...
    this.$refs.freeDrawRef.mapObject.clear()
    ...

Props

Options

Accept all options from FreeDraw

Mode

Accept a number corresponding to one of the valid modes of freeDraw:

/**
 * @constant NONE
 */
export const NONE = 0;

/**
 * @constant CREATE
 */
export const CREATE = 1;

/**
 * @constant EDIT
 */
export const EDIT = 2;

/**
 * @constant DELETE
 */
export const DELETE = 4;

/**
 * @constant APPEND
 */
export const APPEND = 8;

/**
 * @constant EDIT_APPEND
 */
export const EDIT_APPEND = 10;

/**
 * @constant ALL
 */
export const ALL = 15;

value

The v-model property : Accept a LatLng[][]

debounce

From my experience the rate events happened when drawing was a bit excessive, so I throttled the rythm of emitted event by default, setting this to :debounce="false" allow to bypass this settings (I don't remember why I coded it in the first place, there must have been a reason at one point). This might be removed later on if I find there's no use case for it.

Author

Jean-Baptiste Zeller

License

MIT