Created
March 11, 2016 09:18
-
-
Save perliedman/4409e2b4ce0b9b00c933 to your computer and use it in GitHub Desktop.
Leaflet direction arrow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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