diff --git a/app/javascript/controllers/geocode_controller.js b/app/javascript/controllers/geocode_controller.js index 6dcfc24b43..34801a7a73 100644 --- a/app/javascript/controllers/geocode_controller.js +++ b/app/javascript/controllers/geocode_controller.js @@ -259,6 +259,14 @@ export default class extends Controller { ] } + // Computes the center of a Google Maps Rectangle's LatLngBoundsLiteral object + centerFromBounds(bounds) { + let lat = (bounds?.north + bounds?.south) / 2.0 + let lng = (bounds?.east + bounds?.west) / 2.0 + if (bounds?.west > bounds?.east) { lng += 180 } + return { lat: lat, lng: lng } + } + // takes a LatLngBoundsLiteral object {south:, west:, north:, east:} updateBoundsInputs(bounds) { if (!this.hasSouthInputTarget) return false @@ -369,6 +377,13 @@ export default class extends Controller { } } + clearAutocompleterSwapBuffer() { + if (this.autocomplete_buffer) { + clearTimeout(this.autocomplete_buffer) + this.autocomplete_buffer = 0 + } + } + // Sorts the LocationElevationResponse.results.elevation objects and // computes the high and low of these results using bounds and center highAndLowOf(results) {