Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support options for disabling shape types and editing #4

Open
xfischer opened this issue Aug 12, 2019 · 1 comment
Open

Support options for disabling shape types and editing #4

xfischer opened this issue Aug 12, 2019 · 1 comment

Comments

@xfischer
Copy link

Hi, thanks for this plugin, it is really useful.

I'd like to enable only rectangle shapes and disable other shape types. How is it possible ?

@kevinunger
Copy link

kevinunger commented Jan 28, 2020

You could use the native leaflet draw ( npm i leaflet-draw -S ). You could use the vue2-leaflet wrapper and just use the leaflet-draw. Maybe someone with more knowledge could integrate the native way to handle the draw-options into this plugin.


    <l-map id="map" ref="map">
      <l-tile-layer :url=url></l-tile-layer>
    </l-map>

.
.
.

import LDraw from 'leaflet-draw';

mounted() {
      this.$nextTick(() => {
      const map = this.$refs.map.mapObject;
      const drawControl = new window.L.Control.Draw({
        position: 'topright',
        draw: {
          polyline: {
            allowIntersection: false,
            showArea: true
          },
          polygon: false,   // disable or enable with true/false
          rectangle: false,
          circle: false,
          marker: false
        }
      });
      map.addControl(drawControl);
      const editableLayers = new window.L.FeatureGroup().addTo(map);
      map.on(window.L.Draw.Event.CREATED, (e) => {
        // const type = e.layerType;
        const layer = e.layer;
        // Do whatever else you need to. (save to db, add to map etc)
        editableLayers.addLayer(layer);
      });
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants