-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved options #18
base: master
Are you sure you want to change the base?
Improved options #18
Conversation
… option to change ruler-button-icon
What do you think about this @PropFault ? #19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @PropFault! I apologize for the delayed response. Thanks a lot for the contribution! I really like the idea and refactoring applied here and there. I left some comments :)
} | ||
L.circleMarker(this._clickedLatLong, this.options.circleMarker).bindTooltip(text, {permanent: true, className: 'result-tooltip'}).addTo(this._pointLayer).openTooltip(); | ||
} | ||
this._clickCount++; | ||
}, | ||
_get_text :function(options, result, addedLength = null, totalLength = null){ | ||
var text = ""; | ||
if(options.angleUnit.visibility == "visible"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it makes sense to make this option boolean
instead of string?
if(options.angleUnit.visibility == "visible"){ | ||
text += '<b>' + this.options.angleUnit.label + '</b> ' + this._result.Bearing.toFixed(this.options.angleUnit.decimal) + ' ' + this.options.angleUnit.display + '<br>'; | ||
} | ||
if(options.lengthUnit.visibility == "visible"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, I think it would be nice to have them like visible: true
}, | ||
leafletRuler: { | ||
icon: null, | ||
iconClicked: null // null -> use from css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, instead of this, I would suggest adding another option like useCustomIcon: false
and on _setIcon
method check for that option and return early if false. Something like:
_setIcon: function(target, clicked){
if (!this.options.leafletRuler.useCustomIcon) return;
var icon = clicked? this.options.leafletRuler.iconClicked : this.options.leafletRuler.icon;
target.style.backgroundImage = icon;
}
What do you think?
@@ -58,6 +77,7 @@ | |||
L.DomEvent.on(this._map._container, 'keydown', this._escape, this); | |||
L.DomEvent.on(this._map._container, 'dblclick', this._closePath, this); | |||
this._container.classList.add("leaflet-ruler-clicked"); | |||
this._updateRulerButton(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this function would be called accordingly maybe, like:
if (this.options.leafletRuler.useCustomIcon) {
this._updateRulerButton(true);
}
@@ -117,11 +154,16 @@ | |||
this._calculateBearingAndDistance(); | |||
this._addedLength = this._result.Distance + this._totalLength; | |||
L.polyline([this._clickedLatLong, this._movingLatLong], this.options.lineStyle).addTo(this._tempLine); | |||
if (this._clickCount > 1){ | |||
/*if (this._clickCount > 1){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we can get rid of this commented out code :)
I added the option of hiding/changing visibility of the bearing and distance metrics in the dialogue boxes. I also added an option to change the icon of the ruler-button to a custom one.