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

Autocomplete and Forward Geocoding returning different values #164

Open
mattstrick opened this issue May 18, 2024 · 0 comments
Open

Autocomplete and Forward Geocoding returning different values #164

mattstrick opened this issue May 18, 2024 · 0 comments

Comments

@mattstrick
Copy link

Hi,

When I use the Autocomplete SDK I get different results for the same location than when I use the Forward Geocoding SDK.

Autocomplete Implementation
Radar.ui.autocomplete({ container: container, responsive: true, width: "600px", onSelection: (result) => { setFormattedAddress(result.formattedAddress); setLayer(result.layer); setState(result.state); setCity(result.city); setCounty(result.county); setNeighborhood(result.neighborhood); setCountry(result.country); }, minCharacters: 3, placeholder: "Search address", countryCode: "US,CA", expandUnits: true, });

Autocomplete Response
{ "addressLabel": "3836 N Racine Ave", "number": "3836", "street": "N Racine Ave", "city": "Chicago", "stateCode": "IL", "postalCode": "60613", "county": "Cook", "countryCode": "US", "formattedAddress": "3836 N Racine Ave, Chicago, IL 60613 US", "layer": "address", "latitude": 41.952192, "longitude": -87.6595612, "geometry": { "type": "Point", "coordinates": [ -87.6595612, 41.952192 ] }, "distance": 66796.83975361186, "confidence": "exact", "state": "Illinois", "country": "United States", "countryFlag": "🇺🇸" },

Forward Geocoding Implementation
Radar.forwardGeocode({ query: slug }) .then((result) => { const { addresses } = result; setAddressObject({ state: addresses[0].state as string, county: addresses[0].county as string, city: addresses[0].city as string, neighborhood: addresses[0].neighborhood as string, country: addresses[0].country as string, }); }) .catch((err) => { // handle error from Radar setAddressObject({ state: "", county: "", city: "", neighborhood: "", country: "", }); });

Forward Geocoding Response
{ "latitude": 41.952192, "longitude": -87.659561, "geometry": { "type": "Point", "coordinates": [ -87.659561, 41.952192 ] }, "country": "United States", "countryCode": "US", "countryFlag": "🇺🇸", "county": "Cook County", "distance": 66851, "confidence": "exact", "borough": "North Side", "city": "Chicago", "number": "3836", "neighborhood": "Lakeview", "postalCode": "60613", "stateCode": "IL", "state": "Illinois", "street": "N Racine Ave", "layer": "address", "formattedAddress": "3836 N Racine Ave, North Side, Chicago, IL 60613 USA", "addressLabel": "3836 N Racine Ave" }

Notice that in the Autocomplete Response, county comes back as Cook, and there is no neighborhood attribute. On the Forward Geocoding Response, county comes back as Cook County and there is a neighborhood attribute. I need to have the same data returned for the county attribute, and would also like to get access to the neighborhood attribute on the autocomplete response.

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

1 participant