diff --git a/examples/icon-draw.png b/examples/icon-draw.png new file mode 100644 index 0000000..6b979fa Binary files /dev/null and b/examples/icon-draw.png differ diff --git a/examples/icon-end.png b/examples/icon-end.png new file mode 100644 index 0000000..2763505 Binary files /dev/null and b/examples/icon-end.png differ diff --git a/examples/icon-normal.png b/examples/icon-normal.png new file mode 100644 index 0000000..a8a8f58 Binary files /dev/null and b/examples/icon-normal.png differ diff --git a/examples/icon-start.png b/examples/icon-start.png new file mode 100644 index 0000000..6c24f60 Binary files /dev/null and b/examples/icon-start.png differ diff --git a/examples/styling.html b/examples/styling.html index a17c8df..52f30aa 100644 --- a/examples/styling.html +++ b/examples/styling.html @@ -56,6 +56,12 @@ } } } + ,icons: { + start: new L.Icon({iconUrl: 'icon-start.png'}) + ,end: new L.Icon({iconUrl: 'icon-end.png'}) + ,normal: new L.Icon({iconUrl: 'icon-normal.png'}) + ,draw: new L.Icon({iconUrl: 'icon-draw.png'}) + } ,snapping: { layers: [] } diff --git a/src/L.Routing.js b/src/L.Routing.js index f49948f..2a4dfcd 100644 --- a/src/L.Routing.js +++ b/src/L.Routing.js @@ -186,6 +186,23 @@ L.Routing = L.Control.extend({ ,timeoutID : null }; + var icons = this.options.icons; + if (!prev) { + marker.setIcon(icons.start); + } else if (!next) { + marker.setIcon(icons.end); + } else { + marker.setIcon(icons.normal); + } + + if (this._waypoints._first && next && next._leaflet_id === this._waypoints._first._leaflet_id) { + next.setIcon(icons.normal); + } + if (this._waypoints._last && prev && prev._leaflet_id === this._waypoints._last._leaflet_id && prev._leaflet_id !== this._waypoints._first._leaflet_id) { + prev.setIcon(icons.normal); + } + + if (this._waypoints._first === null && this._waypoints._last === null) { this._waypoints._first = marker; this._waypoints._last = marker; @@ -246,10 +263,12 @@ L.Routing = L.Control.extend({ if (this._waypoints._first && marker._leaflet_id === this._waypoints._first._leaflet_id) { this._waypoints._first = next; + next.setIcon(this.options.icons.start); } if (this._waypoints._last && marker._leaflet_id === this._waypoints._last._leaflet_id) { this._waypoints._last = prev; + prev.setIcon(this.options.icons.end); } if (prev !== null) {