add extra mapbox-gl-geocoder examples - #5915
Conversation
ed0ce7f to
df425fd
Compare
df425fd to
adf7793
Compare
adf7793 to
45af8d7
Compare
|
This PR is ready now. |
| filter: function (item) { | ||
| // returns true if item contains New South Wales region | ||
| return item.context.map((i) => { | ||
| return (i.id.startsWith('region') && i.text === "New South Wales"); |
There was a problem hiding this comment.
There's no support in IE for startsWith right?
There was a problem hiding this comment.
I've included a polyfill since I feel startsWith is much more readable than the alternative of i.id.substr(0, 6) === 'region' and simpler than a regexp.
There was a problem hiding this comment.
👍 looks like that just needs a no-extend-native line for tests to pass.
There was a problem hiding this comment.
Sorry, but after thinking some more I think it's probably better to simply split and shift since "id of the feature of the form {index}.{id}"
| description: >- | ||
| Use the [mapbox-gl-geocoder](https://github.com/mapbox/mapbox-gl-geocoder) | ||
| control to search for places using Mapbox Geocoding API limiting results | ||
| to a region |
| type: "Point", | ||
| coordinates: [lng, lat] | ||
| }, | ||
| place_name: 'Lat: ' + lat + ', Lng: ' + lng, // eslint-disable-line camelcase |
There was a problem hiding this comment.
Hmm that's annoying we have to eslint disable here but 🤷♂️
There was a problem hiding this comment.
yes but I don't see any other way around it since place_name is defined in the carmen geojson spec
| Use the [mapbox-gl-geocoder](https://github.com/mapbox/mapbox-gl-geocoder) | ||
| control to search for places using Mapbox Geocoding API, supplementing | ||
| results from a local data source or function, in this case to match | ||
| geographic coordinates provided as input |
| description: >- | ||
| Use the [mapbox-gl-geocoder](https://github.com/mapbox/mapbox-gl-geocoder) | ||
| control to search for places using Mapbox Geocoding API on an input search | ||
| box external to the map |
| @@ -0,0 +1,13 @@ | |||
| /*--- | |||
| title: Use the geocoder on an external search box | |||
There was a problem hiding this comment.
Could the title and description be worded a little differently? I'm not sure a user looking to add a geocoder to an element outside the map would think to search "external search box".
There was a problem hiding this comment.
I've changed the title to: "Place the geocoder input outside the map" and descirption to:
Use the mapbox-gl-geocoder
control to search for places using Mapbox Geocoding API attached to an
element outside the map
|
Thanks for the review @tristen, I've implemented some changes. |
4a2cd7f to
32ef2a2
Compare
|
@andrewharvey Not sure if it's worth ticketing, but I just ran across |
|
hey @ChrisLoer it's supposed to allow the implementer to do mapbox/mapbox-gl-geocoder#121, but being generic so you can supplement the geocoder with your own non-mapbox geocoder data, eg from your Dataset is this the unclear regex?
to match queries like
as their coordinates |
|
🤔 I thought I tried the simple "x,y" syntax and I was getting results with random addresses that contained those numbers. But I can't reproduce that behavior now -- works easily. Probably just ignore me. 😳 Although adding something like "provided as input in the format ', '" would still make the example a bit more accessible I think. |
|
hmm we're getting to the point where a thanks @andrewharvey ! |
Launch Checklist
This tackles the first part of mapbox/mapbox-gl-geocoder#138 adding more examples of mapbox-gl-geocoder. I think it's better to keep all GL JS ecosystem examples together here making them easier to find and to re-use existing infrastructure compared to having a separate mapbox-gl-geocoder examples page.
Additional examples are:
using localGeocoder to search with lat/lon coordinates
using filter to limit results to a region from the Mapbox Geocoding API
search box outside the map Attach controls to arbitrary DOM nodes #3685 (comment) add example to use any element as the geocoder input mapbox-gl-geocoder#137 ( thanks to @tristen for providing this one at https://bl.ocks.org/tristen/a09627f01d3a3bc54139d52a5eb01386 ) (this one in particular keeps coming up with users)
keep map in sync with geocoder proximity bias Proximity updates based on map movement mapbox-gl-geocoder#118 (comment)
Before this can be merged: