动画显示谷歌地图和谷歌街景的路线

发布于 2024-12-26 02:31:20 字数 411 浏览 3 评论 0原文

我正在开发一个路线跟踪 webbapp,我认为将路线动画化而不是仅仅将其显示在地图上会很酷。

我认为这非常酷: http://tripgeo.com/DirectionsMapExamples.aspx?id=2< /a>

我想为我的路线实现这个,但是: 据我了解(当我继续阅读代码时),它们只有一个开始/结束地址,其余部分是生成的。由于我有完整的路线,这对我来说不起作用。

我需要实现的是一个脚本,用于检查全景图每个路线点的街景 API,如果可用则显示它,否则跳到下一个。

这超出了我与地图/街景交互的知识,我很想听听以前做过这样的事情的人,如果可能的话给我一些指示:)

I'm working on a routetracking webbapp and thought it would be cool to animate the route instead of just showing it on a map.

I think this is pretty cool: http://tripgeo.com/DirectionsMapExamples.aspx?id=2

I would like to implement this for my routes but:
For what i understand (as i cont read the code) they only have a start/end address, the rest is generated. As I got a complete route this wont work for me.

What I need to implement is then a script that checks streetview API for every routepoint for a panorama and if available display it else skip to the next one.

This exceeds my knowledge of interacting with maps/streetview and would love to hear for anyone that has done such a thing before and if possible give me some pointers :)

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

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

发布评论

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

评论(2

扮仙女 2025-01-02 02:31:20

我正在做一些非常相似的事情,这就是我的想法。显示路线后,您就知道存储在“腿”或“航点”中的信息(无论您想用哪种方式表达)。然后,每秒使用 setTimeout 或 setInterval 重新加载 div,并在每次重新加载时将图标的位置更新为腿中的 start_point。

这是 requestHandler 方法,

var i = 0;
function requestHandler(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(result); //Your directionsDisplay object
        var myRoute = result.routes[0].legs[0];
        if(i < myRoute.steps.length; i++) {
           //Write the code to include the icon using google.maps API
        }
    }
setTimeout(requestHandler,1000);
}

我知道这可能不是完美的解决方案,但您只需要修改它即可。我也在尝试寻找完美的解决方案。

I am doing something very similar, and this is my idea. Once you have shown the route, you know the information stored in 'legs' or 'waypoints' (whichever way you would like to put it). Then, reload the div using setTimeout or setInterval for every second and at each reload, update the position of your icon to that start_point in the leg.

Here is the requestHandler method

var i = 0;
function requestHandler(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(result); //Your directionsDisplay object
        var myRoute = result.routes[0].legs[0];
        if(i < myRoute.steps.length; i++) {
           //Write the code to include the icon using google.maps API
        }
    }
setTimeout(requestHandler,1000);
}

I know this may not be the perfect solution, but you just need to tinker around with it. I'm playing with it to find the perfect solution as well.

千年*琉璃梦 2025-01-02 02:31:20

只要您只有几个需要访问的点(最多 8 个,除非商业客户为 23 个),您可以指定路线将经过的航点。

您仍然可以通过编程方式完成此操作。

请查看这篇文章了解更多信息。
规范中有关航路点的信息请参见规范。

As long as you only have a few points you need to visit (up to 8 unless business customer when it is 23), you can specify waypoints which the route will then go through.

You can still do it programmatically.

Check this article for more information.
More info about waypoints here in the specs.

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