Skip to content

Add support for non-Node worker environments #5786

Open

Description

@iBobik

What would you like to see in the library?

Support for non-NodeJS runtimes like Cloudflare workers. Currently this library fails to compile for Cloudflare when using Nitro framework. In other workers it could just fail in runtime.

Describe alternatives you've considered

It works to use this library only for Typescript types and send requests the other way:

import type { protos } from '@googlemaps/places'

const data = await $fetch<protos.google.maps.places.v1.IAutocompletePlacesResponse>('https://places.googleapis.com/v1/places:autocomplete', {
  method: 'POST',
  body: {
    input,
    languageCode: language,
    sessionToken,
    locationBias: { rectangle: {
      low: { latitude: businessArea.minLat, longitude: businessArea.minLng },
      high: { latitude: businessArea.maxLat, longitude: businessArea.maxLng },
    } },
  } as protos.google.maps.places.v1.IAutocompletePlacesRequest,
  headers: { 'X-Goog-Api-Key': googleMapsApiKey },
})

Activity

  1. added
    type: feature request
    on Nov 5, 2024
  2. OultimoCoder commented on Nov 6, 2024

    @OultimoCoder

    Please do this

  3. ninadsutrave commented on Nov 27, 2026

    @ninadsutrave

    If you're only importing it for the types, google-maps-fetch might save you the package: typed requests and responses for Places (New), Routes and Geocoding, using only fetch, and it runs on Workers. Your autocomplete call would be:

    const { suggestions } = await maps.places.autocomplete({ input, sessionToken, languageCode: language, locationBias })

    https://github.com/ninadsutrave/google-maps-fetch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    size: ltype: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions