Giter VIP home page Giter VIP logo

leaflet-geoman's Introduction

Geoman Logo

Leaflet-Geoman

Leaflet Plugin For Creating And Editing Geometry Layers
Draw, Edit, Drag, Cut, Rotate, Split, Scale, Measure, Snap and Pin Layers
Supports Markers, CircleMarkers, Polylines, Polygons, Circles, Rectangles, ImageOverlays, LayerGroups, GeoJSON, MultiLineStrings and MultiPolygons

npm version NPM Downloads

Demo

Documentation

Visit geoman.io/docs to get started.

Demo

Check out the full power of Leaflet-Geoman Pro on geoman.io/demo

Feature Requests

I'm adopting the Issue Management of lodash which means, feature requests get the "Feature Request" Label and then get closed.
You can upvote existing feature requests (or create new ones). Upvotes make me see how much a feature is requested and prioritize their implementation.
Please see the existing Feature Requests here and upvote if you want them to be implemented.

Developing

Clone the repository and then install all npm packages:

pnpm install

Compile and run dev watch version:

pnpm run start

Compile and run build version:

pnpm run prepare

Run cypress test:

pnpm run test

Open cypress window:

pnpm run cypress

Open eslint check:

pnpm run lint

Take a look into CONTRIBUTING

Credit

A big thanks goes to @Falke-Design, he invests a lot of time and takes good care of Leaflet-Geoman.

Thanks to @ryan-morris for the implementation of Typescript and support with Typescript questions.

As I never built a leaflet plugin before, I looked heavily into the code of leaflet.draw to find out how to do stuff. So don't be surprised to see some familiar code.

I also took a hard look at the great L.GeometryUtil for some of my helper functions.

The Rotate Mode are only working because of the great calculation code of L.Path.Transform

leaflet-geoman's People

Contributors

0scvr avatar beig avatar cksadra avatar codeofsumit avatar cosme-benito avatar dependabot[bot] avatar diadenchuk avatar drzhbe avatar elliots avatar falke-design avatar henrikmaa avatar kmpm avatar lclpedro avatar mesonyx avatar michaelsemchenko avatar michiel-2 avatar mscno avatar na3shkw avatar neatnick avatar nparley avatar otterlyolive avatar pedroalvesr avatar richorama avatar ryan-morris avatar sostheng avatar strfx avatar szimih avatar turtiesocks avatar vvlladd28 avatar xmojmr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet-geoman's Issues

Toolbar Button Names are inconsistent

var options = {
    drawPolygon: true,  // adds button to draw a polygon
    editPolygon: true,  // adds button to toggle global edit mode
    deleteLayer: true   // adds a button to delete layers
};

this is bad naming for these buttons. Change it.

L.PM.Draw isn't used as a constructor class

There are issues with multiple maps on a page as L.PM.Draw() is used like I'm a noob coder or something.
Fix it, future self πŸ‘Š

Add L.PM.Draw as a new object to a map. Then everything is πŸ‘Œ

Custom Styles on Creation

AFAIK it's currently not possible to pass custom styles for polygons, polylines & markers.
So as soon as I create an element, it gets the leaflet default style. Is it possible to define some custom styles, so that they get applied on creation?

Thanks!

Unable to Remove Last Point from Polygon

After drawing out a polygon, if you want to remove it... you can remove all points except the last one.

Also, it would be great to see some functionality for deleting an entire polygon with one action as opposed to a point by point removal approach.

Nevertheless, nice work so far!

pm.toggleEdit does not work after new layer contents is added

When new layer contents is added after the pm plugin was initialized, it does not handle pm:edit events for newly added elements.

Like this:

var geoJsonLayer = L.geoJson().addTo(map);
geoJsonLayer.addData(json);
geoJsonLayer.addEventListener('click', function() {
    geoJsonLayer.pm.toggleEdit();
});

Clicking on the geoJsonLayer does not enter the edit mode

Showing Measurement on Line and Polygon

Hello, first, I want to show this is a great plugin. I am able to show measurement on line and polyon by integrating this with leaflet plugin (Leaflet Measure Path by ProminentEdge) in the option.

map.pm.setPathOptions({
showMeasurements: true,
});

But, I do not know how to update those measurements when I edit a line or polygon. I am new to leaflet. Could you please help me?

Expose an additional event before and after a polygon gets deleted

Hi there.

There are several pm-custom events including created, edited and dragXYZ.
AFAIK there are no events which get triggered when a polygon gets deleted. On the one hand it would be nice to ask for confirmation (like a pm:deletestart event) and on the other hand I would like to send a request after the polygon was deleted (like a pm:deleteend event).

thanks :)

Errors during Polygon Edit while in Drawing mode

Enable drawing mode, enable edit mode of a polygon, drag a marker => errors.

This is because the yet-to-be-drawn polygon is already a layer on the map but has no (as in, less than 2) coordinates.

Draw at least two coordinates and the errors disappear.

This means the snap-calculation needs to handle (=ignore) layers with fewer than 2 coordinate points.

Map controls get multiplied

When calling the map.pm.addControls multiple times with the same truthy values, the related controls get multiplied:

image

Unit Test Coverage

The features grow - there will soon be too much cases to test manually so: automate it with unit tests, possibly e2e tests.

include default CSS for markers

When the following CSS from the Demo isn't included the markers obviously won't show up

.marker-icon, .marker-icon:focus {
    background-color: #ffffff;
    border: 1px solid #3388FF;
    border-radius: 50%;
    margin: -7px 0 0 -7px !important;
    width: 14px !important;
    height: 14px !important;
    outline: 0;
}

So.. create a /dist folder and put .css and .js in there

GeoJSON with points throws Uncaught TypeError: Cannot read property 'enabled' of undefined

If GeoJSON layer contains points then pm logs console error Uncaught TypeError: Cannot read property 'enabled' of undefined when it sees the L.Marker type of layer.

To reproduce use this: http://plnkr.co/edit/ZjLXPgIWpcAq2k9xIKoJ?p=preview

Expected behavior: map.fitBounds(geoJsonLayer.getBounds()) gets called
Actual behavior: map.fitBounds(geoJsonLayer.getBounds()) is not called because call to geoJsonLayer.addData(json) throws an exception

Create new Demo Page

The current gh-pages branch is a small copy/mix of the demo.js in the master branch and the readme file.
Create a new website that shows off the features of leaflet.pm

listen to when a new layer is created

Hi,

I'm currently trying to configure a function to save the draw data to a geojson file, however the markers are not integrate to the function with "map.on('pm:create', function(e) {//...});".
I noticed that it's possible with other objects like line and polygon.

Do you have a solution for this?
Thanks

Refactor Controls

if(this.toggled()) {
  L.PM.enableDraw({
      map: map
  });
} else {
  L.PM.disableDraw(map);
}

should be replaced with a toggleDraw function.

L.PM.Draw.Poly should return if drawing mode is active or not.
Double Check that L.PM.Draw isn't getting messed up with multiple instances/maps.

Icons missing

Not sure how bower can handle images (icons). Got to do something about it or make it a requirement that devs provide icon paths.

Custom style for drawn polygon

Make an optional style that can be passed to the draw class so that a polygon that is currently drawn doesn't have to be just red lines:
image

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.