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/leaflet@1.0.0-rc.3/dist/leaflet.css" />
    <script src="https://unpkg.com/leaflet@1.0.0-rc.3/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/leaflet@1.0.0-rc.3/dist/images/marker-icon.png',
                iconSize:   [32, 32],
                iconAnchor: [16, 32]
            })
        }).addTo(map);

        marker.bindTooltip("derp", {permanent: true});
    </script>
</body>
</html>
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.

  • 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 – Lucas Steffen Sep 24 '16 at 13:30
  • Also wow, the dist folder on the leaflet-branch is 3 years old. – Lucas Steffen Sep 24 '16 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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