我在我的android应用程序中添加了标记,但我需要制作一个功能,如果我在街道上添加标记,我需要在最近的已知街道上添加标记。就像在这个例子中:Add marker to nearest known street,但我需要使用android。Android:从标记点得到最近的街道
,这是我的标记坐标:
MarkerOptions marker = new MarkerOptions().position(
markerLatLng = new LatLng(point.latitude, point.longitude)).title("my marker");
现在我需要执行异步任务发送坐标,谷歌和检索最近的路coordinates.What网址我应该使用吗?
然后我打算坐标添加到ArrayList中:
locationArray.add(new LatLng(point.latitude, point.longitude));
,并显示标记在我的地图:
mGoogleMap.addMarker(marker);
我在API管理器中开启:Google Maps Directions API
和Google Maps Roads API
问题是什么URL
在我的AsynTask
应该用来获得最近的街道坐标?
也许我需要使用这个:https://maps.googleapis.com/maps/api/directions/output?parameters
并将我的标记坐标添加到参数?
所以,要找到最近的街道,我应该使用'DirectionsAPI'还是'GeocodeAPI'? – Darius92
地理编码,如果在方向api中尝试此操作,您将获得“无效请求”。 –