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

local geocoder not displaying typed result #169

Closed
rcowling opened this issue Nov 12, 2018 · 5 comments
Closed

local geocoder not displaying typed result #169

rcowling opened this issue Nov 12, 2018 · 5 comments

Comments

@rcowling
Copy link

Hello,

I am using the mapbox localgeocoder to work with my goejson data. I am using it with zip codes. Whenever I type in a zipcode from my geojson data for example: "97230" it is not the first result on the list, sometimes it is the 5th or 6th result, sometimes it is not on the list at all. Is there a way to correct this?

Using the method here: `https://www.mapbox.com/mapbox-gl-js/example/forward-geocode-custom-data/

``

@andrewharvey
Copy link
Collaborator

res.features = res.features ? localGeocoderRes.concat(res.features) : localGeocoderRes;

The localGeocoder results should appear at the top do you have a minimal example you can share of the issue?

@rcowling
Copy link
Author

mapbox-gl-geocoder/lib/index.js

Line 190 in c6a1450

res.features = res.features ? localGeocoderRes.concat(res.features) : localGeocoderRes;
The localGeocoder results should appear at the top do you have a minimal example you can share of the issue?

@andrewharvey here is a working example: https://rcowling.github.io/oregon/

Lets say if you want to use zipcode '97230' which I know is in my dataset. If I type 972... it doesn't even come up at or when I type the full thing. Sometimes it comes up but is not the first result. Can you provide any insight? Thanks!

@rcowling
Copy link
Author

rcowling commented Nov 13, 2018

I have tried this using a different dataset, I thought maybe it was my data but same result. The data is coming from a tileset in mapbox studio, perhaps that is why?

In additional is an example screenshot. You can see the result I am searching for does not come up first. https://i.imgur.com/Cx8tiIr.png

@andrewharvey
Copy link
Collaborator

@rcowling looking at your code there:

var geocoder = new MapboxGeocoder({
--
  | accessToken: mapboxgl.accessToken,
  | zoom: 8,
  | minLength: 5,
  | limit: 5,
  | bbox: [-124.5664, 41.9920, -116.4633, 46.2938], // replace this with the bbox of the state
  | types: 'postcode',
  | placeholder: "Enter a Zip Code."
  | });

You never pass it the localGeocoder option, so it won't be using any of your supplied data.

You need to pass that option, it won't automatically detect and use your own dataset/tileset data.

Take a look at the example https://docs.mapbox.com/mapbox-gl-js/example/forward-geocode-custom-data/

@andrewharvey
Copy link
Collaborator

closing as I can't see anything to address on the mapbox-gl-geocoder side, please feel free to post back if that's wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants