Search code examples
javascriptangularleafletapache-zeppelinpolyline

How to add polyline into Leaflet map


I'm using zeppelin and angular interpreter. I have tried three different ways. None of them was successful. But simple markers showed up.

1st one

var array =  [];
all_properties.forEach(item =>{
    array.push(new L.LatLng(item[0], item[1]));
});
 var firstpolyline = new L.polyline(array, {
color: 'red',
weight: 5,
opacity: 1,
smoothFactor: 1
});
firstpolyline.addTo(map);

2nd one

var poly = new L.polyline(all_properties, {
color: 'green',
weight: 5,
opacity: 1,
smoothFactor: 1
});
poly.addTo(map);

3rd one

var polylinePoints = [
        [lat, long],
        [lat1, long1]
      ];            
var polyline = L.polyline(polylinePoints).addTo(map); 

There is no error...

Any ideas? Thx

Edit: When I show points as markers, all of them showed up one the map. This set of markers should me polyline tho...

arr_markers = [];
all_properties.forEach(item =>{
arr_markers.push(L.marker([ item[0], item[1]], {icon: basicIcon}));
});

polyGroup = L.layerGroup(arr_markers).addTo(map);

polyline from markers


Solution

  • Weird thing happened. I just logged off and logged in and the polygon showed up. Actually all of them. Maybe something was cached in my browser (Firefox), or in Zeppelin, or interpreter (restarting of angular interpeter did not help tho...)

    leaflet with polygon