2

Here's a simple demonstration: The file leaflet.draw-src.js was downloaded here: https://github.com/Leaflet/Leaflet.draw/tree/master/dist

If you remove the script tag with the leaflet.draw-src.js the tooltip work just fine, but when added the leaflet.draw it gives the error Cannot read property 'popupPane' of undefined.

ps: Not using leaflet-draw is not an option

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
    <!-- got it from here https://github.com/Leaflet/Leaflet.draw/tree/master/dist -->
    <script src="leaflet.draw-src.js"></script>
    <style type="text/css">
        html, body {
            height: 100%;
        }
        body {
            margin: 0;
            padding: 0;
        }
        #map-canvas {
            position: relative;
            height: 100%;
            width: 100%;
        }
    </style>
</head>
<body>
    <div id="map-canvas"></div>
    <script type="text/javascript">
        var map = L.map('map-canvas').setView([-18, -52], 4);

        L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: "Map data &copy; <a href='http://openstreetmap.org'>OpenStreetMap</a> contributors, <a href='http://creativecommons.org/licenses/by-sa/2.0/'>CC-BY-SA</a>.",
            maxZoom: 18
        }).addTo(map);

        var marker = new L.Marker(L.latLng(-18, -52), {
            icon: new L.icon({
                iconUrl:    'https://unpkg.com/[email protected]/dist/images/marker-icon.png',
                iconSize:   [32, 32],
                iconAnchor: [16, 32]
            })
        }).addTo(map);

        marker.bindTooltip("derp", {permanent: true});
    </script>
</body>
</html>

1 Answer 1

3

For Leaflet 1.0, you have to use Leaflet.draw leaflet-master branch, as mentioned on the repo home page:

Support for Leaflet 1.0 is in development at the leaflet-master branch.

Unfortunately, even with that version, the Tooltip issue is a known bug (Leaflet/Leaflet#4760) that is not resolved yet.

2
  • Two solutions: Add 'leaflet.draw-src.js' only when needed or rename in the leaflet.draw-src.js file from L.Tooltip to L.Draw.Tooltip Sep 24, 2016 at 13:30
  • Also wow, the dist folder on the leaflet-branch is 3 years old. Sep 24, 2016 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.