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

Geocoding v6 not returning addresses like Playground #488

Open
geografa opened this issue Jul 11, 2024 · 1 comment
Open

Geocoding v6 not returning addresses like Playground #488

geografa opened this issue Jul 11, 2024 · 1 comment

Comments

@geografa
Copy link
Contributor

When I attempt to send a request for some specific addresses, the response does not match the v6 API Playground results.

Example:

  • 12303 NE 130th Ln 520 Kirkland WA 98034
  • 464 Valley Brook Ave Lyndhurst NJ 07071

Expect:
Same as playground.

Actual:
The street number is dropped.

  • Northeast 130th Place, Kirkland, Washington 98034, United States;undefined;-122.163203;47.717499
  • Valley Brook Ave, Clifton, New Jersey 07071, United States;undefined;-74.165226;40.862197

Code example:


const mbxGeocode = require("@mapbox/mapbox-sdk/services/geocoding-v6");
const geocodingClient = mbxGeocode({ accessToken: MAPBOX_ACCESS_TOKEN });
const fs = require("fs");

// add your address to this array in the same format as the example addresses
const addresses = [
  "464 Valley Brook Ave Lyndhurst NJ 07071",
  "12303 NE 130th Ln 520  Kirkland WA 98034",
];

function geocodeAddresses(addresses) {
  addresses.forEach((address) => {
    geocodingClient
      .forwardGeocode({
        query: address,
        limit: 1,
        countries: ["US"],
        permanent: false,
      })
      .send()
      .then((response) => {
        const results =
          response.body.features[0].id +
          ";" +
          response.body.features[0].properties.full_address +
          ";" +
          response.body.features[0].properties.coordinates.accuracy +
          ";" +
          response.body.features[0].properties.coordinates.longitude +
          ";" +
          response.body.features[0].properties.coordinates.latitude;
        console.log(results);
      });
  });
}

geocodeAddresses(addresses);

Do the request and params look correct?

@geografa
Copy link
Contributor Author

geografa commented Jul 11, 2024

I may have found the cause. If I remove the countries: ['US'], parameter, the response appears as expected. Still testing.

It's possible this is a case issue. Should be countries: ['us'] (lowercase).

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