在使用 Google Maps API 3.0 的移动应用程序上添加路径点

发布于 2024-10-28 05:06:32 字数 265 浏览 0 评论 0原文

我正在开发适用于 Android 和 iOS 平台的应用程序。我的客户要求应用程序必须具有“添加路线”功能。 假设我在应用程序上设置了 TO 和 FROM 点,并且我想显示这两点之间的最佳路线。如果只是这两点就好了。有大量资源可帮助您了解如何继续操作。但如果我想添加一些额外的指示,例如“GO THROUGH”,互联网上没有任何答案。 如果您可以向我指出任何适用于移动平台且此功能有效的应用程序(必须使用 Google 地图),那就太好了。也许您有关于该主题的某种文档或其他材料。

谢谢,迈克(波兰)

I am working on the app for Android and iOS platforms. My client requires that the app has to have "add directions" functionality.
Let's say I have a TO and FROM points set on my app, and I want to show the best route between these two points. If it's just these two points it's fine. There's plenty of resources on how to proceed. But if I want to add some extra directions, like GO THROUGH for example, the internet has no answers for me.
If you could point me to any apps (have to use Google Maps) for mobile platforms, where this functionality is working it would be great. Maybe you have some sort of documentation or some other materials on the subject.

Thanks, Mike (poland)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

囍孤女 2024-11-04 05:06:32

尝试将 uri 格式化为:
从:50.74,14.00889+到:51.66444,17.85679+到:52.66444,17.85679
您可以根据需要添加任意数量的+到条款

编辑:
如果您使用 Map api,您应该有这样的代码来计算路线:

    StringBuilder urlString = new StringBuilder();
    urlString.append("http://maps.google.com/maps?f=d&hl=de");
    urlString.append("&saddr=");//from
    urlString.append( Double.toString((double)src.getLatitudeE6()/1.0E6 ));
    urlString.append(",");
    urlString.append( Double.toString((double)src.getLongitudeE6()/1.0E6 ));
    urlString.append("&daddr=");//to
    urlString.append( Double.toString((double)dest.getLatitudeE6()/1.0E6 ));
    urlString.append(",");
    urlString.append( Double.toString((double)dest.getLongitudeE6()/1.0E6 ));
    urlString.append("&ie=UTF8&0&om=0&output=kml");

您应该能够以所描述的格式添加一些航路点。

        urlString.append("+to:")
        urlString.append( Double.toString((double)waypoint.getLatitudeE6()/1.0E6 ));
        urlString.append(",");
        urlString.append( Double.toString((double)waypoint.getLongitudeE6()/1.0E6 ));

try to format the uri like:
from:50.74,14.00889+to:51.66444,17.85679+to:52.66444,17.85679
you can add as much +to terms as you want

edit:
if you ar using the Map api, you supposed to have a code like thisone to calculate a route:

    StringBuilder urlString = new StringBuilder();
    urlString.append("http://maps.google.com/maps?f=d&hl=de");
    urlString.append("&saddr=");//from
    urlString.append( Double.toString((double)src.getLatitudeE6()/1.0E6 ));
    urlString.append(",");
    urlString.append( Double.toString((double)src.getLongitudeE6()/1.0E6 ));
    urlString.append("&daddr=");//to
    urlString.append( Double.toString((double)dest.getLatitudeE6()/1.0E6 ));
    urlString.append(",");
    urlString.append( Double.toString((double)dest.getLongitudeE6()/1.0E6 ));
    urlString.append("&ie=UTF8&0&om=0&output=kml");

you should be able to add some waypoints in the discribed format.

        urlString.append("+to:")
        urlString.append( Double.toString((double)waypoint.getLatitudeE6()/1.0E6 ));
        urlString.append(",");
        urlString.append( Double.toString((double)waypoint.getLongitudeE6()/1.0E6 ));
蓝天白云 2024-11-04 05:06:32

谷歌地图 API v3 有一个方向重绘器。您可以在两点之间渲染一条多线,并且可以拖动多线,即您可以沿路线选取一品脱并将其重新定位为
航路点。请参阅 API 文档。

或者,您可以捕获地图上的点击事件,并将位置推送到中途停留地数组中以传递路由请求。

The google maps api v3 has a directions rederer. You can render a pollyline between two points and have the pollyline be dragable i.e. you can pick a pint along the route and reposition it as a
waypoint. see the api documentation.

alternativly you can capture click events on the map add push the location into an array of stopovers to pass on the the routing request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文