question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lost the distance measures when drawing (except for circle)

See original GitHub issue

Chrome V58 Windows 10 Leaflet 1.0.3 Leaflet-draw 0.4.9

As shown below, with leaflet 1.0 and leaflet draw 0.2.4 I was getting text distance for lines, and area for rectangles.

Now I only get the area for circles, but the others do not show anything. Is this just me, and why does the below no longer work?

(I.e. I no longer see the 1425.65 km as shown below).

distance

function addDrawLayer() {
    var options = null
    var map = MAP.map
    var drawings = new L.FeatureGroup()
    MAP.drawLayer = drawings
    map.addLayer(drawings)

    options = {
        shapeOptions: {
            showArea: true,
            clickable: true
        },
        metric: true,
        edit: {
            featureGroup: drawings
        }
    }
    var drawControl = new L.Control.Draw(options)
    map.addControl(drawControl)
    map.on('draw:created', function (e) {
        var type = e.layerType
        var layer = e.layer
        if (type === 'marker') {
            layer.bindPopup('A popup!')
        }
        drawings.addLayer(layer)
    });
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
berticommented, Sep 28, 2017

For polylines, it looks like this is because L.Draw.Polyline never shows the length in the tooltip if the browser supports touch events, which Chrome for desktop seems to do. I understand why this was done, but I’m not sure about the best solution here.

For rectangles and polygons, it’s a matter of setting the right options:

const drawOptions = {
  draw: {
    rectangle: {
      showArea: true
    },
    polygon: {
      showLength: true,
      showArea: true,
      allowIntersection: false  // Otherwise, area would not be shown
    }
  }
};
0reactions
hbaltzcommented, Jan 23, 2018

The version 1.0.0 of leaflet.draw seems to correct this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Draw and Measure a Circle Without a Pattern
How to Draw and Measure a Circle Without a Pattern. Sewing Tool Box ... Circumference: the distance around the outer edge of a...
Read more >
CIRCLE
A circle is a 2D shape that has a closed curve consisting of all points at a FIXED distance from its center. A...
Read more >
How do you determine if you can draw a circle around a set of ...
Try this: use stereographic projection to project your points onto a sphere. Then you need to find a plane passing through the sphere...
Read more >
Circularity | GD&T Basics - GDandTBasics.com
If you think of a stack of coins, circularity would be a measurement around ... it is ± 0.08 and circularity is the...
Read more >
Circle Geometry - Australian Mathematical Sciences Institute
Measurement and Geometry : Module 26 Years : 9-10 ... A circle is the set of all points in the plane that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found