Skip to content

Geocoding v6 not returning addresses like Playground #488

@geografa

Description

@geografa

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions