perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

Don't show all markers #538

Closed raulallende2025 closed 5 years ago

raulallende2025 commented 5 years ago

Hi. only show first and last markers on my map

L.Routing.control({ collapsible: true, collapseBtnClass: 'ods-icon-route', waypoints, lineOptions: { styles: [{ color: waypoints[0].color, opacity: 1, weight: 3 }] }, createMarker: function (i, waypoint, n) { if (i === 0) { const marker = L.marker(waypoint.latLng, { draggable: false, icon: L.divIcon({ className: '', html: <span style="color: ${waypoint.color}; font-weight: bold" class="ods-icon-home ods-mt-5 ods-mr-5"></span> }) }) return marker } else if (i === n - 1) { const marker = L.marker(waypoint.latLng, { draggable: false, icon: L.divIcon({ className: '', html: <div style="background: ${waypoint.color}; width: 15px; height: 15px; border-radius: 50%"/> }) }) return marker } else { const marker = L.marker(waypoint.latLng, { draggable: false, icon: L.divIcon({ className: '', html: <div style="background: ${waypoint.color}; width: 10px; height: 10px; border-radius: 50%"/> }) }) return marker.bindTooltip(waypoint.tooltip).openTooltip() } } }).addTo(this.$refs.myMap.mapObject)