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

BUGFIX: do not use nominatim "display name" because it is not a displ… #663

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
],
"dependencies": {
"@fortawesome/fontawesome-free": "^5.12.1",
"@fragaria/address-formatter": "^2.6.4",
"@nextcloud/moment": "^1.1.1",
"@nextcloud/router": "^1.0.0",
"@nextcloud/vue": "^1.1.0",
"@nextcloud/moment": "^1.1.1",
"d3": "^3.5.17",
"i18next-client": "^1.11.4",
"leaflet": "^1.7.1",
Expand Down
19 changes: 16 additions & 3 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import TracksController from './tracksController';

import { brify, getUrlParameter, formatAddress } from './utils';

import addressFormatter from '@fragaria/address-formatter';

(function($, OC) {
var geoLinkController = {
marker: null,
Expand Down Expand Up @@ -1632,6 +1634,15 @@ import { brify, getUrlParameter, formatAddress } from './utils';
this.search(str, this.handleSearchResult, this);
},


formatAddress: function(searchResult) {
const displayName = addressFormatter.format(searchResult.address, {
countryCode: OC.getLocale(),
output: 'array',
});
return displayName.join(', ');
},

handleSearchResult: function(results, that, isCoordinateSearch = false, searchString = '') {
if (results.length === 0) {
OC.Notification.showTemporary(t('maps', 'No search result'));
Expand All @@ -1646,7 +1657,8 @@ import { brify, getUrlParameter, formatAddress } from './utils';
newData.push(...that.currentLocalAutocompleteData);
for (var i=0; i < results.length; i++) {
if (isCoordinateSearch && !results[i].maps_type) {
const label = results[i].display_name + ' (' + searchString + ')'
const displayName = searchController.formatAddress(results[i]);
const label = displayName + ' (' + searchString + ')'
newData.push({
type: 'address',
label: label,
Expand All @@ -1665,10 +1677,11 @@ import { brify, getUrlParameter, formatAddress } from './utils';
lng: results[i].lon
});
} else {
const displayName = searchController.formatAddress(results[i]);
newData.push({
type: results[i].maps_type ?? 'address',
label: results[i].display_name,
value: results[i].display_name,
label: displayName,
value: displayName,
result: results[i],
lat: results[i].lat,
lng: results[i].lon
Expand Down