简体   繁体   English

Google Maps Javascript API距离矩阵请求限制

[英]Google Maps Javascript API Distance Matrix Request Limitations

The distance matrix request in Google Maps API is limited to 25 destinations. Google Maps API中的距离矩阵请求仅限于25个目的地。 I want to be able to get my current location using geolocation and find the closest train station based on a database of train station addresses that I have compiled. 我希望能够使用地理位置获取当前位置,并根据我编译的火车站地址数据库找到最近的火车站。 My problem is that my database might contain 100+ train stations, so I need to split up my one big distance matrix request into multiple small ones. 我的问题是我的数据库可能包含100多个火车站,所以我需要将我的一个大距离矩阵请求分成多个小的。 When Google Maps API returns the result, it normalizes the format of the address, which makes it difficult to programmatically pair the response with the original database row based on the address string. 当Google Maps API返回结果时,它会对地址格式进行规范化,这使得很难根据地址字符串以编程方式将响应与原始数据库行配对。 Also, these are asynchronous requests, which means that the responses could come in any order. 此外,这些是异步请求,这意味着响应可以按任何顺序排列。 Is there some way of passing an index to the callback function, so that I can pair the responses with the requests? 有没有办法将索引传递给回调函数,以便我可以将响应与请求配对? What is the best method of handling this? 处理此问题的最佳方法是什么?

Do an initial cut of train stations by using the straight line distance (which can be computed directly from the geographic coordinates, using the haversine formula). 通过使用直线距离(可以使用半正弦公式直接从地理坐标计算)对火车站进行初始切割。 Only send the 25 closest stations to the distance matrix. 仅将25个最近的站发送到距离矩阵。

If you store the lat/lng coordinates in your database you can use the Haversine Formula to find the nearest station. 如果将lat / lng坐标存储在数据库中,则可以使用Haversine公式查找最近的工作站。 This DEMO uses this technique. 这个DEMO使用这种技术。 The database was derived from data obtained from Geonames 该数据库源自从Geonames获得的数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Maps JavaScript API 的 Google Maps Distance Matrix 语言规范 - Google Maps Distance Matrix Language specification for Google Maps JavaScript API 传递带有Google Maps Distance Matrix请求的标识符 - Passing an Identifier with a Google Maps Distance Matrix Request 使用谷歌地图距离矩阵api JSON输出获取距离 - get distance using google maps distance matrix api JSON output Google Maps API 距离矩阵 - 延迟请求(客户端)另外 100 个元素的时间 - Google Maps API Distance Matrix - Delay time to request (client-side) another 100 elements 在Google Maps Javascript API中将距离转换为英里数 - Converting Distance to miles in Google Maps Javascript API 使用Javascript查询Google Distance Matrix API - Using Javascript to query Google Distance Matrix API Google Maps Distance Matrix API Rounding JS API v3 - Google Maps Distance Matrix API Rounding JS API v3 Google Maps Distance Matrix Api中的目的地限制是什么? - What is the limit of destinations in Google Maps Distance Matrix Api? Google Maps Distance Matrix Service API返回错误的项目 - Google Maps Distance Matrix Service API returning wrong items Javascript 和异步问题(使用 yandex maps api 构建距离矩阵) - Javascript and async problem (building distance matrix with yandex maps api)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM