Skip to content

Commit

Permalink
IGN search string length must be between 3 and 200 chars (#4840)
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault authored Oct 7, 2024
1 parent ccbe4e9 commit 4adf5dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions assets/src/modules/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ export default class Search {

// Format answers to highlight searched keywords
var labrex = this._getHighlightRegEx();
const searchQuery = document.getElementById('search-query').value;
switch (searchConfig.service) {
case 'nominatim':
$.get(service
, { "query": $('#search-query').val(), "bbox": extent.toBBOX() }
, { "query": searchQuery, "bbox": extent.toBBOX() }
, data => {
var text = '';
var count = 0;
Expand Down Expand Up @@ -220,8 +221,12 @@ export default class Search {
}, 'json');
break;
case 'ign':
if (searchQuery.length < 3 || searchQuery.length > 200) {
lizMap.addMessage(lizDict['externalsearch.ignlimit'], 'warning', true);
break;
}
let mapExtent4326 = transformExtent(mainLizmap.map.getView().calculateExtent(), mainLizmap.projection, 'EPSG:4326');
let queryParam = '?text=' + $('#search-query').val() + '&type=StreetAddress&maximumResponses=10&bbox=' + mapExtent4326
let queryParam = '?text=' + searchQuery + '&type=StreetAddress&maximumResponses=10&bbox=' + mapExtent4326
$.getJSON(encodeURI(service + queryParam), data => {
let text = '';
let count = 0;
Expand All @@ -238,7 +243,7 @@ export default class Search {
break;
case 'google':
service.geocode({
'address': $('#search-query').val(),
'address': searchQuery,
'bounds': new google.maps.LatLngBounds(
new google.maps.LatLng(extent.top, extent.left),
new google.maps.LatLng(extent.bottom, extent.right)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ externalsearch.search=Searching
externalsearch.notfound=No results
externalsearch.mapdata=Map data
externalsearch.noquery=Search query is empty
externalsearch.ignlimit=IGN search must contain between 3 and 200 characters

timemanager.toolbar.play=Play
timemanager.toolbar.pause=Pause
Expand Down

0 comments on commit 4adf5dd

Please sign in to comment.