react-google-maps icon indicating copy to clipboard operation
react-google-maps copied to clipboard

New Routes api key does not work with Directions api

Open benderlidze opened this issue 10 months ago • 12 comments

Description

The problem is that I created a new Google Maps account and a new API key, but there is no Directions API. They say you should use the Routes API. However, when I use the new API key with the Routes API enabled, I get MapsRequestError: DIRECTIONS_ROUTE: REQUEST_DENIED: There was an issue performing a Directions request. Uncaught (in promise) MapsRequestError: DIRECTIONS_ROUTE: REQUEST_DENIED: The webpage is not allowed to use the directions service.

When I use an old API key from 5 years ago with the Directions API enabled, it works fine.

Steps to Reproduce

Create new google account and Reoutes api.

Environment

  • Library version:
  • Google maps version: weekly
  • Browser and Version:
  • OS:

Logs


benderlidze avatar Mar 12 '25 21:03 benderlidze

This doesn't have anything to do with the react-library, but let's see if I can help you anyway...

Have you checked that not only the Routes API is enabled for your GCP project, but also the Directions API is enabled for the Maps API Key (https://console.cloud.google.com/google/maps-apis/credentials)?

usefulthink avatar Mar 12 '25 21:03 usefulthink

@usefulthink It looks like the Directions API no longer exists. There is only the Routes API. https://developers.google.com/maps/documentation/routes/migrate-routes

Image

benderlidze avatar Mar 12 '25 22:03 benderlidze

After a bit of searching, I found the answer: the old version of the Places API, the Directions API and the Distance Matrix API as well as their classes in the Maps JavaScript API have been declared "legacy", which means they can no longer be enabled for new projects. Most annoying is that they did this without having a replacement for the DirectionsService or DirectionsRenderer available (yet). Sounds like we need to get to work updating all relevant examples here...

A bit more info can be found here: https://developers.google.com/maps/legacy

usefulthink avatar Mar 12 '25 22:03 usefulthink

I seem to have the same issue with the new Places API.

I get "This API project is not authorized to use this API. Places API error: ApiNotActivatedMapError", while having "Places API (new)" enabled and no API restrictions on my API key.

Geocoding works with the same API key.

sanderquirynen avatar Mar 13 '25 11:03 sanderquirynen

yeah, with the places API things are slightly different. At least there are new parts of the Maps JavaScript API to use them with. PlacesService, Autocomplete, and SearchBox from google.maps.places are all using the legacy Places API, and the Place class and AutocompleteSuggestion are using the new APIs.

usefulthink avatar Mar 13 '25 14:03 usefulthink

@usefulthink do you know how we can enable the legacy Places API? I can't find that on the "APIs & Services" page.

sahibjotsaggu avatar Mar 19 '25 04:03 sahibjotsaggu

@sahibjotsaggu It might still be possible using this direct link: https://console.cloud.google.com/apis/library/places-backend.googleapis.com

usefulthink avatar Mar 21 '25 16:03 usefulthink

@sahibjotsaggu It might still be possible using this direct link: https://console.cloud.google.com/apis/library/places-backend.googleapis.com

This worked, thanks! Where can one find a direct link to the legacy directions and distancematric apis?

zerdotre avatar Mar 24 '25 14:03 zerdotre

Should be those three. But this might be only temporary, since the documentation on the legacy features says those APIs can no longer be activated for new projects.

usefulthink avatar Mar 24 '25 17:03 usefulthink

thank you, found them. indeed just eplacing places with directions or distance-matrix in the url. Yeah they cant be found in the library anymore but with direct links they can be enabled. Fortunately.

On Mon, 24 Mar 2025 at 20:45, Martin Schuhfuss @.***> wrote:

Should be those three. But this might be only temporary, since the documentation on the legacy features https://developers.google.com/maps/legacy says those APIs can no longer be activated for new projects.

— Reply to this email directly, view it on GitHub https://github.com/visgl/react-google-maps/issues/712#issuecomment-2748948284, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3B6HAJVM36J2KRQIASGCQT2WBADFAVCNFSM6AAAAABY4UGITWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONBYHE2DQMRYGQ . You are receiving this because you commented.Message ID: @.***> [image: usefulthink]usefulthink left a comment (visgl/react-google-maps#712) https://github.com/visgl/react-google-maps/issues/712#issuecomment-2748948284

Should be those three. But this might be only temporary, since the documentation on the legacy features https://developers.google.com/maps/legacy says those APIs can no longer be activated for new projects.

— Reply to this email directly, view it on GitHub https://github.com/visgl/react-google-maps/issues/712#issuecomment-2748948284, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3B6HAJVM36J2KRQIASGCQT2WBADFAVCNFSM6AAAAABY4UGITWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONBYHE2DQMRYGQ . You are receiving this because you commented.Message ID: @.***>

zerdotre avatar Mar 24 '25 17:03 zerdotre

I've created a new example showing how to use render results from the Routes-API using a simple Polyline component: https://visgl.github.io/react-google-maps/examples/routes-api

usefulthink avatar Apr 09 '25 10:04 usefulthink

Great! Thanks, I'll check it out.

On Wed, 9 Apr 2025 at 13:05, Martin Schuhfuss @.***> wrote:

I've created a new example showing how to use render results from the Routes-API using a simple Polyline component: https://visgl.github.io/react-google-maps/examples/routes-api

— Reply to this email directly, view it on GitHub https://github.com/visgl/react-google-maps/issues/712#issuecomment-2789122854, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3B6HAO67GCTXSMN7BD5HOT2YTWFLAVCNFSM6AAAAABY4UGITWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBZGEZDEOBVGQ . You are receiving this because you commented.Message ID: @.***> usefulthink left a comment (visgl/react-google-maps#712) https://github.com/visgl/react-google-maps/issues/712#issuecomment-2789122854

I've created a new example showing how to use render results from the Routes-API using a simple Polyline component: https://visgl.github.io/react-google-maps/examples/routes-api

— Reply to this email directly, view it on GitHub https://github.com/visgl/react-google-maps/issues/712#issuecomment-2789122854, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3B6HAO67GCTXSMN7BD5HOT2YTWFLAVCNFSM6AAAAABY4UGITWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBZGEZDEOBVGQ . You are receiving this because you commented.Message ID: @.***>

zerdotre avatar Apr 09 '25 12:04 zerdotre