Google-maps – How to convert Google map route into array of coordinates

google mapsgps

Is there any tool or method in order to convert Google Map route, direction into array of lat/lon coordinates? What I am trying to do is to simulate NMEA sentences in order to test my application.

Best Answer

*** UPDATED FOR 2020 GOOGLE MAPS UI ***

I found this video extremely helpful, the first part of it concerns your question. It shows you how you can plot a route on a map and then export it.

Steps:

  • Sign into your google account/If you don't have one then you will need to create one to do it this way

  • Go to google maps (https://maps.google.com/)

  • Click on "My Places", then on the "Maps" tab click "Create Map"

  • From the toolbar under the search bar click on "Draw a line" and choose the type of route

  • Find the area you want on the map, click once to set starting point.

  • Draw the route you want, and then double click to set ending point. (you can use single click to fix points within your route if it goes round weird corners and the path moves)

  • When you are happy with your route click on the 3 dots to the right of the map's name and select "Export to KML/KMZ"

  • Change the option "Entire map" to just the route you have selected and "Download" as KML

  • Open the KML file in your favorite text editor (e.g. Notepad++) and find the < coordinates > tag (the one inside the < LineString > tag if there is more than one) which will contain all the coordinates of your route