相关疑难解决方法(0)

使用Google Maps API获取旅行时间数据

我使用谷歌地图api遇到的所有例子似乎都显示了某种地图.当您要求从A到B进入某个站点的道路描述时,我想通过他们为您提供的汽车估计行程时间数据.而且只有那些数据.是否可以在不为最终访问者加载地图的情况下?

api google-maps travel-time

33
推荐指数
5
解决办法
9万
查看次数

将折线转换为路线

我有一个应用程序跟踪车辆并在地图上绘制他们的旅行路线的折线.我想使用路线服务路线将此折线转换为路线.这将允许我能够拖动路径并操纵它等.

问题是我想不出一个很好的解决方案,我不确定它是否可行.如果我将折线的坐标数组传递到路线服务路线,它只使用折线的起点和终点绘制路线,而不考虑其间的任何坐标.

我尝试使用折线坐标数组生成一个'waypoints'数组,方法是将它平均分割并在两者之间获得8个坐标,并将这些坐标作为路点传递,但现在根本无法渲染.如果我使用通过绘制路由生成的坐标数组来测试代码,那么我知道代码正常工作.我认为它失败了,因为其中一些坐标可能稍微不在路上(它是从GPS定位绘制的折线,因此它不是100%准确),而Google不会将它捕捉到最近的接受位置.

谁能想到解决这个问题?

这是代码示例,使它更清晰:

// In the polyline app
var encoded_path = google.maps.geometry.encoding.encodePath(coordinate_array)



// In the route app
var coordinates = google.maps.geometry.encoding.decodePath(encoded_path);

var waypoints = [];

// Evenly get coordinates across the entire array to be used as waypoints
for (var i = 1; i <= 8; ++i) {
   var index = Math.floor((coordinates.length/10) * i);

   if (index >= coordinates.length - 1)
      break;

   waypoints.push({
      'location': new google.maps.LatLng(coordinates[index].lat(), coordinates[index].lng()),
      'stopover': false
   });
}

var request = {
   origin: coordinates[0],
   destination: coordinates[coordinates.length …
Run Code Online (Sandbox Code Playgroud)

google-maps google-maps-api-3

14
推荐指数
1
解决办法
2809
查看次数

基于运输时间的热图/等高线(反向等时轮廓)

注意:的解决方案也适用于我.

我试图根据运输时间绘制轮廓.为了更清楚,我想将具有相似行程时间(比如说10分钟间隔)的点聚类到特定点(目的地)并将它们映射为轮廓或热图.

现在,我唯一的想法就是gmapsdistance找到不同来源的旅行时间,然后将它们聚类并在地图上绘制.但是,正如您所知,这绝不是一个强大的解决方案.

线在GIS社区和这一次说明了类似的问题,但对于内特定的时间范围原点目的地.我想找到我可以在一定时间内前往目的地的起源.

现在,下面的代码显示了我的基本想法:

library(gmapsdistance)


set.api.key("YOUR.API.KEY") 

mdestination <- "40.7+-73"
morigin1 <- "40.6+-74.2"
morigin2 <- "40+-74"

gmapsdistance(origin = morigin1,
              destination = mdestination,
              mode = "transit")

gmapsdistance(origin = morigin2,
              destination = mdestination,
              mode = "transit")
Run Code Online (Sandbox Code Playgroud)

此地图也可能有助于理解这个问题:

1

更新I:

使用这个答案,我可以从原点得到我可以去的点数,但是我需要反转它并找到旅行时间等于某一时间到目的地的点数;

library(httr)
library(googleway)
library(jsonlite)

appId <- "TravelTime_APP_ID"
apiKey <- "TravelTime_API_KEY"
mapKey <- "GOOGLE_MAPS_API_KEY"

location <- c(40, -73)
CommuteTime <- (5 / 6) * 60 * 60

url <- "http://api.traveltimeapp.com/v4/time-map"

requestBody <- paste0('{ …
Run Code Online (Sandbox Code Playgroud)

google-maps r google-api googleway travel-time

9
推荐指数
2
解决办法
729
查看次数

查找给定半径内的地址

我需要找到给定半径内的所有地址.我已经实现了以下功能.

Google Places API

这仅提供半径内的业务地址.它接受radius作为参数. https://maps.googleapis.com/maps/api/place/textsearch/json?key=myAPIKey&location=6.914701,79.973085&radius=100&sensor=false&hl=en&query=*

谷歌反向地理编码

它只是将给定的lat和lng转换为地址.这实际上并不符合我的要求.并且它不接受radius作为参数. http://maps.googleapis.com/maps/api/geocode/json?latlng=6.914701,79.973085&sensor=false

有没有办法让所有地址都在给定的半径范围内.特别居住的地址.

php google-maps reverse-geocoding google-places-api

5
推荐指数
1
解决办法
7409
查看次数

从纬度和长度中查找一定范围内的一组坐标

我正在开发一个涉及谷歌地图的JavaScript项目.

目标是在一组纬度经度坐标的n公里内找出16-20个坐标点,使得如果连接的16个点将围绕原始坐标形成圆.

最终的目标是使它能够找到坐标以绘制和连接谷歌地图,以围绕给定的坐标集创建一个圆圈.

代码将类似于:

var coordinates = Array();
function findCoordinates(lat, long, range) {
}
coordinates = findCoordinates(-20, 40, 3);
Run Code Online (Sandbox Code Playgroud)

现在让魔法发生在findCoordinates()函数中.

javascript google-maps latitude-longitude coordinates

2
推荐指数
1
解决办法
9746
查看次数