Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Leaflet direction arrow
var L = require('leaflet');
module.exports = L.CircleMarker.extend({
initialize: function(latLng, heading, options) {
this._heading = heading;
L.CircleMarker.prototype.initialize.call(this, latLng, options);
},
setHeading: function(heading) {
this._heading = heading;
this.redraw();
},
getPathString: function () {
var p = this._point,
r = this._radius;
if (this._checkIfEmpty()) {
return '';
}
return 'M0,' + (-r - 1) + ' ' +
'L-3,' + (-r) + ' ' +
'L0,' + (-r - 8) + ' ' +
'L3,' + (-r) + ' z';
},
_updatePath: function() {
var p = this._point;
this._container.setAttributeNS(null, "transform", 'translate(' + p.x + ',' + p.y + ') rotate(' + this._heading + ')');
L.CircleMarker.prototype._updatePath.call(this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment