我正在尝试使用 com.google.maps
google库从java准备以下网址 . 我没有找到适当的库方法来添加航点 . 请让我知道如何添加航点到谷歌 Map API .
我遵循以下方法将原点和目的地添加到GeoAPi上下文 .
GeoApiContext context = new GeoApiContext();
context.setApiKey("AIzaSyDhhwfZgJv4DCVuX-RDuXLXfoHWL6FIPAw");
LatLng originLatLng = new LatLng(17.4366668,78.3982614);
LatLng destinationLatLng = new LatLng(17.42955,78.34171);
LatLng wayPoints = new LatLng(17.4477, 78.38264);
DirectionsResult result = DirectionsApi.newRequest(context)
.origin(originLatLng)
.destination(destinationLatLng)
.waypoints("17.44027,78.39431", "17.43149,78.38817")
.await();
2 回答
您可以在Github上的源代码中轻松找到路标的方法:
https://github.com/googlemaps/google-maps-services-java/blob/master/src/main/java/com/google/maps/DirectionsApiRequest.java
从第151行开始:
可以使用LatLng传递航路点参数 . 以下是适合我的代码示例: