-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat(magnifying glass): use the magnifying glass to find the first choice to see on the map #1600
base: release/16.x
Are you sure you want to change the base?
Changes from all commits
8093275
58ddf57
a3bc176
ab5088f
f52d806
10db31b
aba0e07
27bea56
59e1d6b
754da18
a0fcf94
2ef34bf
c1b8736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ import { ConfigService } from '@igo2/core'; | |
import { BehaviorSubject, Subscription, timer } from 'rxjs'; | ||
import { debounce, distinctUntilChanged } from 'rxjs/operators'; | ||
|
||
import { FEATURE, Feature, FeatureMotion } from '../../feature'; | ||
import { LAYER, LayerOptions, LayerService } from '../../layer'; | ||
import { IgoMap } from '../../map'; | ||
import { SearchSourceService } from '../shared/search-source.service'; | ||
import { SEARCH_TYPES } from '../shared/search.enums'; | ||
import { Research, SearchResult } from '../shared/search.interfaces'; | ||
|
@@ -120,6 +123,11 @@ export class SearchBarComponent implements OnInit, OnDestroy { | |
*/ | ||
@Output() reverseSearchCoordsFormatStatus = new EventEmitter<boolean>(); | ||
|
||
/** | ||
* Map to add layer | ||
*/ | ||
@Input() map: IgoMap; | ||
alecarn marked this conversation as resolved.
Show resolved
Hide resolved
alecarn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Search term | ||
*/ | ||
|
@@ -253,7 +261,8 @@ export class SearchBarComponent implements OnInit, OnDestroy { | |
constructor( | ||
private configService: ConfigService, | ||
private searchService: SearchService, | ||
private searchSourceService: SearchSourceService | ||
private searchSourceService: SearchSourceService, | ||
private layerService: LayerService | ||
) {} | ||
|
||
/** | ||
|
@@ -485,4 +494,51 @@ export class SearchBarComponent implements OnInit, OnDestroy { | |
this.store.updateMany(newResults); | ||
} | ||
} | ||
|
||
/** | ||
* When the user clicks on the magnifying glass and | ||
* this find the first object on the map | ||
*/ | ||
selectFirstElement() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Qu'est-ce qui arrive si les résultats ne sont pas tous arrivés lorsque l'utilisateur clique le bouton? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rien ne s'est passé, s'il y a un résultat, le résultat avec le score le plus élevé sera mis en évidence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mais disons q'un utilisateur clique sur le boutin ou fait enter, mais que seul des résultats partiels sont disponible? Quelle est l'échelle relative comparable entre les résultats? Comment comparer des résultats? Regarde computeTermSimilarity There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chaque résultat a un score donc en utilise le score pour la comparaison There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Le score est-il comparable entre les services de recherche? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. il faudrait idéalement que ce soit sur une échelle absolue et non pas relative, comme pour iCherche There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. le code existant bien tester avec iCherche, le résultats de recherche donne le même objet, donc le score existe si le résultat est une couche ou Feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nominatim? |
||
const results = this.store.all(); | ||
if (results.length === 0) { | ||
return; | ||
} | ||
|
||
// find the highest result score | ||
const result = results.reduce( | ||
(highest, current) => | ||
current.meta.score > highest.meta.score ? current : highest, | ||
results[0] | ||
); | ||
|
||
this.store.state.update(result, { focused: true, selected: true }, true); | ||
|
||
if (this.map) { | ||
this.handleMap(this.map, result); | ||
} | ||
} | ||
|
||
private handleMap( | ||
map: IgoMap, | ||
result: SearchResult<Record<string, any>> | ||
): void { | ||
const { dataType } = result.meta; | ||
|
||
if (dataType === FEATURE) { | ||
const feature = (result as SearchResult<Feature>).data; | ||
map.searchResultsOverlay.setFeatures( | ||
[feature] satisfies Feature[], | ||
FeatureMotion.Default | ||
); | ||
} else if (dataType === LAYER) { | ||
const layerOptions = (result as SearchResult<LayerOptions>).data; | ||
if (layerOptions.sourceOptions.optionsFromApi === undefined) { | ||
layerOptions.sourceOptions.optionsFromApi = true; | ||
} | ||
this.layerService.createAsyncLayer(layerOptions).subscribe((layer) => { | ||
map.addLayer(layer); | ||
}); | ||
} | ||
} | ||
} |
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.
Est-ce que le keydown.enter ne devrait pas re-trigger la recherche également?
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.
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.
oui sélectionner le résultat avec le score le plus élevé
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.
Je crois que enter devrait redéclancher la recherche.