从Google地图行程中获取经度 [英] Get latitude longitude from google maps itinerary

查看:83
本文介绍了从Google地图行程中获取经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以帮助我解决这一点.

I would like to know if someone can help me about this point.

我有一个基于Google地图的脚本,可以计算行程.我想知道是否有可能获得例如以每1公里为一个纬度-经度的此行程的数组. 如果行程为100公里,我将得到一个包含100个数据的数组

I have a script based on google maps who calculate itinerary. I would like to know if it is possible to get an array of this itinerary with the latitude-longitude every 1 kilometer for example. If the itinerary is 100 kilometers long, i'll get an array with 100 datas

  • (纬度,经度,0)
  • (纬度,经度,1)
  • (纬度,经度,...)
  • (纬度,经度,99)

我需要它,因为我想在行程附近提出点数兴趣. 例如: https://roadtrippers.com/

I need it because i would like to propose points interest near an itinerary. Example: https://roadtrippers.com/

  1. 您选择旅行的开始
  2. 您选择旅行的目的地
  3. 它建议您在行程附近可以做什么

推荐答案

DirectionsService类将通过

The DirectionsService class will give you a response with a DirectionsResult object. This object has a property called overview_path that gives, from the docs:

一组LatLngs,代表此路线的整个路线.这 简化了路径,使其适用于以下情况: 顶点数量很少(例如静态Maps API URL).

An array of LatLngs representing the entire course of this route. The path is simplified in order to make it suitable in contexts where a small number of vertices is required (such as Static Maps API URLs).

您可以使用它们执行位置搜索(使用位置库)在overview_path数组中返回的每个LatLng半径内获取兴趣点等.

You can use these to perform places searches (with the places library) to get points of interest, etc, within a radius from each LatLng that's returned in the overview_path array.

示例:

var request = {
  origin: start_point,
  destination: end_point,
  travelMode: google.maps.TravelMode.DRIVING
};

var directionsService = new google.maps.DirectionsService();
directionsService.route(request, function(response, status) {
  if (status == google.maps.DirectionsStatus.OK) {
    var path = (response.routes[0].overview_path);
  }
});

这篇关于从Google地图行程中获取经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆