Closed ajaxlex closed 2 years ago
followup is to review the constructor for that object or read an manual for the library or something of that nature for the correctest way to set the options for the search
search function library found here https://github.com/jgravois/bootstrap-geocoder
references api from here http://esri.github.io/esri-leaflet/api-reference/controls/geosearch.html
Options indicated as passed in as arg to constructor - just have to add useMapBounds to object passed in in script.js
OK. I am sooooooooo wrong.
I thought the search function was searching our data, but it is searching addresses and locations in the region. We will need some kind of filter so we dont, for example, get a list of Giant Eagles from Sudan.
Unfortunately, the nature of the option provided is either on or off, although you can make that conditional depending on the zoom level. This is not really what we want.
It may be possible to modify the provider to only return results from within 10 miles of Pittsburgh, for example.
Hey cool the searchBounds option seems to do what we want.
var nwBoundsCorner = L.latLng(40.507486, -80.063847); var seBoundsCorner = L.latLng(40.385017, -79.837699); var mapBounds = L.latLngBounds(nwBoundsCorner, seBoundsCorner);
Observed Behavior: When entering a search term, the results in the dropdown change based upon the map extents Expected Behavior: When entering a search term, results will represent any records in the dataset that meet the search parameters
The primary map script ( script.js ) includes the following code to add the search to the map
bootstrap-geocoder.js defines the following code at line 70 which is a clue to the behavior issue. I believe this code is responsible for navigating to the selected item on the suggested results, but it points to some inner workings that I think are relevant
GeosearchCore.js defines the following code at line 110 that populates the suggested items
This code references this.searchBounds(), which among other things relies on an options object to make a decision about what to return.
I suspect if we can set the GeosearchCore this.options.useMapBounds to false, the system will search across the breadth of the dataset - although I could be wrong-o! It has happened before :D