Draw route over the street on the map

Asked

Viewed 2,476 times

6

I have a feature that captures the positions of gps every 10 seconds.

Every 30 seconds or if there’s a 20 degree change in the Bearing (Compare the last position with the current one) store to send to the service.

After, the user can view the route!

Draw the route through a Polyline , and as the capture time of the positions is a bit large (thinking about the battery consumption) it stays this way:

inserir a descrição da imagem aqui

Is there any way soften the route design?

Or is there any way to draw the Polyline over the street?

Thanks in advance!

  • So that the Polyline can be softer you have to use more points.

  • So my fear is to end the user’s data plan, not counting the battery that will drain...

1 answer

2


To create a simple app that finds routes between two places based on Google Map address, you can use Google Map Direction API.

The Google Maps Directions API is a service that calculates routes between places using an HTTP request.

A Google Maps Directions API request has the following format:

https://maps.googleapis.com/maps/api/directions/output?parameters

where output can be one of the following values:

  • json (recommended) indicates the output in Javascript Object Notation (JSON)
  • xml indicates the output as XML

To access the Google Maps Directions API via HTTP, use:

http://maps.googleapis.com/maps/api/directions/output?parameters

Github has a project where you can start your application: Googlemapdirectionsimple Create a simple app that find a path between two Places.

Screenshots

inserir a descrição da imagem aqui

Updating

Google has made a change to the guidelines regarding the terms of use. Now in order to use your Google Maps API services, you need to enter the key into the URL. See how get a key/authentication.

For example, who wants to leave São Paulo and go to Curitiba, you should do so:

https://maps.googleapis.com/maps/api/directions/json?origin=Sao+Paulo&destination=Curitiba&&key=YOUR_API_KEY

See here the first steps for the use of the service.

Details

  • Thank you @seamusd, I will search and validate your reply!

  • 2

    @Thiagoluizdomacoski Opa! Anything, make your observations and we will try to solve together! Hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.