Giter Club home page Giter Club logo

leaflet.editablehandlers's Introduction

EditableHandlers

This is a project which will include different tools to edit/play with geometries in Leaflet. Currenlty I added support for:

  • Circle editor (L.CircleEditor)
  • Measuring tool (L.MeasuringTool)
  • Label for the polygon sides (L.PolySideLabel)

Circle edition (L.CircleEditor)

That is, the user can move the circle as well as increase the radius of the circle by just using the drag areas.

CircleEditor extends from L.Circle and adds the handlers in order to move and increase the area. To use it, it is the same way as initializing a Circle, with the difference that you will just call CircleEditor instead.

Code example:

    var radius = 500; /*radius in meters*/
    var eCircle = new L.CircleEditor(locationLatLng, radius, circleOptions);
    map.addLayer(eCircle);

The circle editor has one additional feature. The dragger icon can be set (with css) to grow when the mouse is over it, this makes the dragging action of the center or its radius easier for the user. Just set the option called 'extendedIconClass' to any of the styles currenlty set in the css file:

  • .extend-icon
  • .extend-icon-medium
  • .extend-icon-xl

Measuring tool (L.MeasuringTool)

With this class you get the option measure the distance of a path. The new change makes it possible to measure the distance between multiple points. There is an option to show distance between points, 'displayPartialDistance' which is set to false by default, and to show the total distance, 'displayTotalDistance' which is true by default. The class allows you style the line as well as the tooltip which shows the distance info. Also it allows you to set the icons for the start and stop points in the map. You will be able to grab the icons and move them at will. The distance is updated.

Code example:

    measuringTool = new L.MeasuringTool(map);
    measuringTool.enable();
	
    //use the method disable to terminate the measuring.
    measuringTool.disable();

Label for the polygon sides (L.PolySideLabel)

This class will show the distance between each of the vertices of the polygon/polyline when the mouse is on top of it. It works great for most browsers, except for IE7/8 where on hover, it shows the info for all the polygones at the same time (and not only the one you are hovering over).

Notes

  • There is a limit of sides (option bodersLimit = 8) which you can change. This limit sets the max amount of sides for a polygon to show the length info. If is greater, then nothing is shown.
  • If the sides are too small (option minSideLength 40 meters), then instead of the distance, you will get characters and a leyend on the side indicating the sides for each character.
  • There is a limit for the visible area (option minAreaToShow). If the visible drawn area is smaller than this, the info wil not be shown.

Code example:

    var polygon = new L.Polygon(...);
    ....
    map.addLayer(polygon);
    var labelPolygon = new L.PolySideLabel(polygon, options);

leaflet.editablehandlers's People

Contributors

aratcliffe avatar dgarciach avatar keyjote avatar mattiasb avatar tonyc avatar xnzac 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet.editablehandlers's Issues

TypeError in Leaflet 0.6.2 after distance layer added with MeasuringTool

I modified the packaged example, measuring-tool.html, to use Leaflet 0.6.2 instead of the packaged version. This results in a TypeError when completing a distance measurement, after the PopUp appears.

Uncaught TypeError: Object [object Object] has no method 'fire' leaflet-src.js:3809
L.Popup.L.Class.extend.onAdd leaflet-src.js:3809
L.Map.L.Class.extend._layerAdd leaflet-src.js:2246
L.Map.L.Class.extend.addLayer leaflet-src.js:1714
L.MeasuringTool.L.Class.extend._onMapClick L.MeasuringTool.js:94
L.Mixin.Events.fireEvent leaflet-src.js:473
L.Map.L.Class.extend._fireMouseEvent leaflet-src.js:2215
L.Map.L.Class.extend._onMouseClick leaflet-src.js:2194
handler

This is a nice library, and I'd like to use it with 0.6.2 (or later)!

L.CircleEditor '_leaflet_id' undefined error with leaflet master branch (0.8-dev)

Hi there

We've recently had to upgrade to the latest Leaflet master branch due to better Mapbox support, among other reasons. Leaflet master seems to have had many internal changes and has caused L.CircleEditor to throw an error:

Uncaught TypeError: Cannot read property '_leaflet_id' of undefined 
L.Util.stamp leaflet-0-8-dev.js:81
L.Evented.L.Class.extend._on leaflet-0-8-dev.js:399

Here's a jsfiddle on it: http://jsfiddle.net/dinglixiang/sXh5k/24/

It's pointing to the latest build of Leaflet master branch at our server.

Could you kindly take a look and advise on what the issue might be? Much thanks.

Custom Distance for the Measuring Tool

Hey,

I realise this plugin has not been updated in a while, but I hope I can ask a question.

I am using Leaflet for a game map and wondering if there is there any way of defining a custom distance?

The map I am using is 2km x 2km.

Hope to hear from anybody!

Thank you.

Disable editing?

Is there a way to turn off the editing? I would like to have editing turned on and off by another control.

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.