TransWikia.com

How to convert Google map route into array of coordinates?

Web Applications Asked on November 26, 2021

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.

4 Answers

I think this app will help you a lot.

https://play.google.com/store/apps/details?id=geo.location.tracker.and.editor

enter image description here

This is a tool to track your routes and you can export it as GEO JSON file. You can customize the distance between every two points. Click on the start tracking button and you have to move on your route. (walking, driving, etc.) There is a feature on this app that edits your tracked list. So you can remove or edit tracked coordinates. You can import external GEO JSON files and edit that JSONs as well. You can find more on the app's help section Simple description - https://www.youtube.com/watch?v=JyBTYD0wgiU.

enter image description here

enter image description here

Answered by dilupa sampath on November 26, 2021

You can use directionsService.route result to fetch each step's coordinates. For example.

var request = {

    origin: start_point,

    destination: end_point,

    travelMode: 'DRIVING'

  };

  directionsService.route(request, function(result, status) {

    if (status == 'OK') {

      directionsRenderer.setDirections(result);

      var directionsData = result.routes[0].legs[0];

      var steps = [];

      for (var i = 0; i < directionsData.steps.length; i++) {

        steps[i]['lat'] =  directionsData.steps[i].start_point.lat();

        steps[i]['lng'] = directionsData.steps[i].start_point.lng());
      
       }

    }
  });

You can change this as per your used technology.

Answered by Satyandra Shakya on November 26, 2021

*** 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

Answered by Yiannis on November 26, 2021

You can play with the Google Maps API, or, if you're just interested in quickly finding the coordinates of the waypoints on a Google Map route, you can generate a .gpx file (in either Garmin or "generic" format) using this tool

http://www.cgtk.co.uk/navigation/gpx

The resulting .gpx file has the data you need, in decimal degrees of lat & long. According to the instructions, Google's free API limits to 10 waypoints. Note that I don't have affiliation with A. S. Buden (http://www.cgtk.co.uk/)

Answered by Charles Lindsay on November 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP