谷歌地图模拟随机运动

时间:2013-04-05 02:51:14

标签: jquery google-maps google-maps-api-3

我打算在 Google地图上构建一个模拟移动的应用程序,但是我没有看到任何我想要的例子。我想要的运动是沿着随机路径移动基本上我想要从特定的预定义点向前移动引脚而没有中断或跳过点然后经过一段时间之后让我们说在向左或向右移动10分钟后停止,向前或向后等等。

我不想使用已定义的路径。一旦运动发生在没有休息的顺序中,运动是否会偏离道路并不重要。我还希望能够每10秒记录一次动作。我不确定必须注册哪个事件监听器来处理这个或如何处理它。

我想使用 jquery 来实现它。我接受任何建议,示例和演示(示例不必采用代码片段的形式。它可以是关于如何修改longlat坐标以模拟路径的公式)。基本上,如果我知道如何增加一个longlat坐标以使向前运动,但我不知道如何操纵longlat坐标。

这就是我的想法:

找到一种方法来增加坐标直线移动然后修改度数然后再转动然后再转动等等。

3 个答案:

答案 0 :(得分:1)

the docs开始。去那里搜索“动画符号”(不能直接链接到该部分)。至于改变方向,根据您的标记移动的距离,您可能需要在movable-type找到的Haversine公式。

答案 1 :(得分:1)

谷歌有一个名为Google Playground的工具, 您可以使用Google Maps Api V3检查此动画示例

https://code.google.com/apis/ajax/playground/?exp=earth#animate_v3

答案 2 :(得分:0)

我做了一些代码来模拟北/南和东/西

public static double eastMove(double d, double lat) {

    System.out.println("old North no longitude " + "," + lat);
    double newLatitude;
    double coef = d * 0.0000089;


    newLatitude = lat + coef;
    return newLatitude;
}


public static double northMove(double d, double lat, double lon) {

    System.out.println("old east" + lon + "," + lat);
    double newlongitude;

    double coef = d * 0.0000089;

    newlongitude = lon + coef / Math.cos(lat * 0.018);

    return newlongitude;
}

使用这两个功能:

    newLongitude = northMove(15,Latitude,longitude);


    System.out.print("to North location");
    System.out.print(newLongitude );

    System.out.print(",");
    System.out.println(Latitude);




    newLatitude = eastMove(15,latitude);

    System.out.print("to East location");
    System.out.print(Longitude);

    System.out.print(",");
    System.out.println(newLatitude );