0
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
<!-- MarkerCluster CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css" />
<!-- AwesomeMarkers CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
    
<link href="{% static 'css/main.css' %}" rel="stylesheet">
   
<!-- Sidebar - Treview CSS -->
<link src="{% static 'bootstrap-treeview/css/bootstrap-treeview.css' %}">
<link href="{% static 'leaflet-sidebar-v2/css/leaflet-sidebar.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/spinner.css' %}">
<!--Leaflet-measure CSS-->
<link rel="stylesheet" href="{% static 'leaflet-measure/css/measure.css' %}">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<!-- Leaflet -->
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<!-- MarkerCluster JS -->
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
<!-- Sidebar - Treview JS -->
<script src="{% static '.../leaflet-sidebar.js' %}"></script>
<script src="{% static '.../bootstrap-treeview.js' %}"></script>
<script src="{% static '.../jquery.zoom.js' %}"></script>
<!-- MomentJS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.min.js"></script>
<!-- Measure -->
<script src="https://cdn.jsdelivr.net/npm/leaflet-measure@3.1.0/dist/leaflet-measure.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
const openStreetMap = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', 
    {
        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
        maxZoom: 18,
        boxZoom: true,
        trackResize: true
    }
);

var map = L.map('mapDiv', { center: centerCity, zoom: 15, layers: [openStreetMap] });

var baseMaps = {
    "Map": openStreetMap
};

L.control.measure({position: 'bottomright', primaryLengthUnit: 'meters', primaryAreaUnit: 'sqmeters', captureZIndex: 10000}).addTo(map);

The measure works fine, I can see all the measures perfectly, but the polyline don't show up.

Exemple

Because of this issue I did other tests and observate that my app don't show polyline, circle, rectangle too.

  • Tests
var oneLayer = new L.geoJson();
map.addLayer(oneLayer);

var redCircleMarker = L.circle([34, -112], 200000, {
    color: 'red',
});
oneLayer.addLayer(redCircleMarker);

What can I test to find the solution?

Plugin used Leaflet-Measure

Your Answer

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

Browse other questions tagged or ask your own question.