Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

PropFault
Copy link

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.

@ElSabio97
Copy link

What do you think about this @PropFault ? #19

Copy link
Owner

@gokertanrisever gokertanrisever left a 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"){
Copy link
Owner

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>&nbsp;' + this._result.Bearing.toFixed(this.options.angleUnit.decimal) + '&nbsp;' + this.options.angleUnit.display + '<br>';
}
if(options.lengthUnit.visibility == "visible"){
Copy link
Owner

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
Copy link
Owner

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);
Copy link
Owner

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){
Copy link
Owner

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants