Skip to content

Commit

Permalink
coordinates field fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brookgagnon committed Oct 24, 2024
1 parent 4225dfb commit ac0eb77
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions ui/fields/coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ class OBFieldCoordinates extends OBField {
}

renderView() {
if (this._lat != null && this._lng != null) {
render(html` <div>${this._lat}, ${this._lng}</div> `, this.root);
let lat = null;
let lng = null;

if (this._lat != null) {
lat = parseFloat(this._lat).toFixed(5);
}

if (this._lng != null) {
lng = parseFloat(this._lng).toFixed(5);
}

if (lat != null && lat != null) {
render(html` <div>${lat}, ${lng}</div> `, this.root);
} else {
render(html` <div></div> `, this.root);
}
Expand Down Expand Up @@ -85,15 +96,19 @@ class OBFieldCoordinates extends OBField {

_updateLat(event) {
const lat = parseFloat(event.target.value);
if (lat >= -90 && lat <= 90) {
if (isNaN(lat)) {
this._lat = null;
} else if (lat >= -90 && lat <= 90) {
this._lat = lat;
}
this.refresh();
}

_updateLng(event) {
const lng = event.target.value;
if (lng >= -180 && lng <= 180) {
if (isNaN(lng)) {
this._lng = null;
} else if (lng >= -180 && lng <= 180) {
this._lng = lng;
}
this.refresh();
Expand Down

0 comments on commit ac0eb77

Please sign in to comment.