Skip to content

Instantly share code, notes, and snippets.

@perliedman
Created March 11, 2016 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perliedman/4409e2b4ce0b9b00c933 to your computer and use it in GitHub Desktop.
Save perliedman/4409e2b4ce0b9b00c933 to your computer and use it in GitHub Desktop.
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