简体   繁体   中英

Is there any way to add MultiPolyline component using react-leaflet?

I am trying to implement an OpenSteetMap view using leaflet. I have created a POC for the same .

var map = L.map('map').setView([9.89445, 76.71272], 12).addLayer(osm);
var latlngs1 = [
    [[9.84644243, 76.81231223],
    [9.91437659, 76.82216573]],
    [[9.86079307, 76.69274206],
    [9.9061336, 76.69914242]]
];
var latlngs2 = [
    [[9.91437659, 76.82216573],
    [9.86079307, 76.69274206]]
];
var polyline1 = L.multiPolyline(latlngs1, {color: 'red'}).addTo(map);
var polyline2 = L.multiPolyline(latlngs2, {color: 'green'}).addTo(map);

Since i am using Reactjs to create the application, i started using react-leaflet library which provide react components.

But i am not able to find MulitPolyline component in react-leaflet. Doc seems like there is no support for MultiPolyline.

Is there any way to add this component in React?

Updated leaflet library to latest version. Instead of multiPolyline used polyLine and it works fine

var map = L.map('map').setView([9.89445, 76.71272], 12).addLayer(osm);
var latlngs1 = [
[[9.84644243, 76.81231223],
[9.91437659, 76.82216573]],
[[9.86079307, 76.69274206],
[9.9061336, 76.69914242]]
];
var latlngs2 = [
[[9.91437659, 76.82216573],
[9.86079307, 76.69274206]]
];
var polyline1 = L.polyline(latlngs1, {color: 'red'}).addTo(map);
var polyline2 = L.polyline(latlngs2, {color: 'green'}).addTo(map);

http://jsfiddle.net/jeffjohny/wnrkq13o/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM