googlemaps / google-maps-services-js

Node.js client library for Google Maps API Web Services
Apache License 2.0
2.88k stars 634 forks source link

Geocoder: Incorrect typing for GeocodeResult["types"] #402

Closed OscarBarrett closed 3 years ago

OscarBarrett commented 4 years ago

It's currently typed as AddressType, however AddressType does not describe the possible values.

For example, geocoding the name of a car dealership I get the following types

[ 'car_dealer', 'establishment', 'point_of_interest', 'store' ]

Which appear in PlaceType1, PlaceType2, PlaceType2 and PlaceType1 respectively - not a single value from AddressType.

jpoehnelt commented 4 years ago

Do you have an example query returning car dealer as a type in a geocoding result?

OscarBarrett commented 4 years ago
import { Client } from '@googlemaps/google-maps-services-js';

const run = async () => {
  const client = new Client();
  const result = await client.geocode({ params: {
    key: '<key>',
    address: 'Perth 4WD & Commercial Centre',
  } });
  console.log(result.data.results[0].types);
};

run();

[ 'car_dealer', 'establishment', 'point_of_interest', 'store' ]