how can i use googlemap gRPC in android?

24 views Asked by At

I would like to use routeAPI - gRPC on Android. But in none of the documents, I can't find how to define the message in the proto file.

What I looked for as much as I could is this document.

https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2?hl=ko#computeroutesrequest

Is there a way for me to implement route API pathfind on android with gRPC? or googleMap gRPC android Example?

Thank you.

I want to use gRPC in android

1

There are 1 answers

1
DazWilkin On

I'm going to answer your question literally (I'm not familiar with the Maps API and so unable to comment on other ways that this may be done).

Google publishes all (most!?) of its gRPC services in a public GitHub repo called googleapis.

Google's gRPCs are namespaced google and are then namespaced by service e.g. maps and, in your case google/maps/routing/v2 contains multiple protos but the one of primary interest is routes_service.proto and specifically line 87 which defines ComputeRoutes which, I think is what you're after!?

rpc ComputeRoutes(ComputeRoutesRequest) returns (ComputeRoutesResponse)

Now (!) generally (!?) Google publishes SDKs that implement the gRPC stubs for these services. Please ensure that the SDK doesn't already exist as it will save you time.

However, because gRPC defines the services (rpc's and method's), we can generate the stubs for ourselves:

If you clone googleapis, the protocol buffer proto_path (import path) should be this repo's root folder and you can generate the services in routes_service.proto using the fully-qualified path google/maps/routing/v2/routes_service.proto

routes_service.proto has a slew of imports but these are a combination of:

  • other references in googleapis;
  • Google's well-known types (which should be automatically supported).