当前位置: 首页 > 知识库问答 >
问题:

如何用java中的waypoints准备google map api请求

艾浩穰
2023-03-14
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();

共有1个答案

许亦
2023-03-14

您可以在GitHub上的源代码中轻松找到waypoints的方法:

https://github.com/googlemaps/google-maps-services-java/blob/master/src/main/java/com/google/maps/directionsapirequest.java

从151行开始:

/**
* Specifies a list of waypoints. Waypoints alter a route by routing it through the specified
* location(s). A waypoint is specified as either a latitude/longitude coordinate or as an address
* which will be geocoded. Waypoints are only supported for driving, walking and bicycling
* directions.
*
* <p>For more information on waypoints, see <a href="https://developers.google.com/maps/documentation/directions/#Waypoints">
* Using Waypoints in Routes</a>.
*/
public DirectionsApiRequest waypoints(String... waypoints) {
  if (waypoints == null || waypoints.length == 0) {
    return this;
  } else if (waypoints.length == 1) {
    return param("waypoints", waypoints[0]);
  } else {
    return param("waypoints", (optimizeWaypoints ? "optimize:true|" : "") + join('|', waypoints));
  }
}
 类似资料:
  • 我是新手,请放心。目前,我正在使用放心的API自动化。我有以下方案要处理 我们有两个 API(例如:API1、API2),API1 会给出用户详细信息的列表。我需要将这些详细信息作为第二个 API 请求的一部分发送。 API1 -响应 API2 -请求:。:在API2请求中,我需要发送“sourceUserId”和“source”详细信息。 userSourceMeta详细信息会根据用户动态变化。

  • 我正在尝试更新我的mySQL数据库中的一个条目。在这里可以很好地工作,例如: 但在这里,我总是得到一个错误,但不知道为什么。 这是我的错误:

  • Waypoints 是一个 jQuery 用来实现捕获各种滚动事件的插件,例如实现无翻页的内容浏览,或者固定某个元素不让滚动等等。支持主流浏览器版本。 在线演示: 无限滚动:http://imakewebthings.github.com/jquery-waypoints/infinite-scroll

  • 问题内容: 我正在尝试准备好的语句,但是下面的代码不起作用。我收到错误消息: 致命错误:在第12行的/var/www/prepared.php中的非对象上调用成员函数execute() 另外,我需要对准备好的语句使用mysqli吗?谁能指出我关于从连接到插入再到带有错误处理的选择的准备好的语句的完整示例? 问题答案: 从文档: 在执行语句或获取行之前,必须使用mysqli_stmt_bind_pa

  • 问题内容: 是的,当我尝试在看起来像这样的变量上使用bindvalues时,我遇到了一个问题: 现在看起来像这样: 但这不起作用,还尝试了以下方法: 并得到了一些语法错误.. 正确的解决方案是什么?我还以为在bindValue(:firstname,$ firstname%)中添加%,但是我也需要在其他地方使用:firstname,也不应使用%。 帮忙谢谢 问题答案: 好的,添加到绑定值: 接着

  • 问题内容: 嗨,我需要在我的网站中使用“准备好的声明”。我尝试使用这个 但这不起作用。当我改变并以它的工作。 问题答案: CodeIgniter不支持预备语句。如果查看CI的Database类的源代码,您将看到它们仅通过用传递的数组中的数据替换问号来解析绑定: https://github.com/EllisLab/CodeIgniter/blob/develop/system/database/