Google 地图 api 方向 用户定义的步骤

发布于 2024-09-04 08:11:51 字数 380 浏览 11 评论 0原文

我有一个谷歌地图服务,上面标有商店。 我还有路线服务(然后您定义两个或更多地址,它会在这张地图上向您显示一条路线,请参阅谷歌地图 api 路线)。所以我希望通过这种方式向您展示最近的商店。当然,它也可能是位于我路上的下一条路的商店,所以它也应该包含在列表中。

到目前为止,我只发现了从 google 地图 api 获得的方向对象中的一系列步骤。但这些步骤是由谷歌预定义的,因此它们可能彼此太近,也可能太远(如果您的路线的一部分是高速公路或者您的路上没有任何特殊的步骤等)

所以,我想做的事。我想在从谷歌指示中获得的线路上制定自己的步骤(例如,每 500 名会议者将这些步骤放在我的线路上等),然后在每一步中搜索大约 200 名会议者的任何商店。

可以做吗?我在互联网上找不到这个想法的任何解决方案。

I have a google map service with the stores mapped on it.
I also have directions service (then you define two addresses or more and it shows you a way on this map, see google map api directions). So I waте to show the nearest stores to this way. Of course it could be the store located in the next streat of my way, so it also should be included to the list.

So far I just found only an array of steps in the directions object which I get from google maps api. But these steps are predefined by google, so they can be too close one each to other and they also can be too far (if a part of your route is a highway or there is no any special steps on your way etc.)

So, what I want to do. I want to make my own steps on the line that I get from google directions (for example to put these steps on my line every 500 meeters etc.), and after that to search every step for any stores around 200 meeters.

Is it possible to do? I cannot find any solution of this idea in internet.

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

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

发布评论

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

评论(1

帅哥哥的热头脑 2024-09-11 08:11:51

我想我找到了解决方案。

这是如果有人遇到同样的问题

for (var i = 0; i < directionResult.routes[0].overview_path.length; i++) {
    var marker = new google.maps.Marker({
        position: directionResult.routes[0].overview_path[i],
        map: myMap
    });
}

I think I found a solution.

Here it is if somebody will get the same problem

for (var i = 0; i < directionResult.routes[0].overview_path.length; i++) {
    var marker = new google.maps.Marker({
        position: directionResult.routes[0].overview_path[i],
        map: myMap
    });
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文