Android draw a path on a mapView from a large amount of longitude/latitude points(Android从大量的经度/纬度点在mapView上绘制路径)
问题描述
我正在编写一个应用程序,它需要绘制由许多 GPS 点(经纬度)组成的路线".这些点靠得很近,不遵循道路,只需在每个点之间画一条线即可.
I am writing a application that needs to draw a "route" comprised of lots of GPS points (long+lat). The points are close together and don't follow roads, simply drawing a line between each point is ideal.
我当前的实现非常慢,因为我正在遍历所有 GPS 坐标并在逐项叠加中创建一个新的点和叠加项.加载所有这些点并将它们绘制到地图视图大约需要 20 秒.有没有一种方法可以让我从 GPS 坐标构建一系列线或点并将它们绘制到地图视图上?
The current implementation I have is very slow as I am looping over all the GPS coordinates and creating a new Point and overlayitem in an itemized overlay. This takes around 20 seconds for it to load all of these points and draw them to the mapview. Is there a way in which I can construct a series of lines or point from the GPS coordinates and draw them onto the mapview?
当前实现示例:
提前致谢,希望我已经解释得够清楚了.
Thanks in advance, hope I've explained it well enough.
推荐答案
在这里查看我的回复代码示例:
Check my reply with code sample here:
如何绘制使用 kml 文件在地图上的路径?
此示例解析一个 kml 文件(由 Google 地图或 Google 地球提供的用于路线计算的 xml 格式)并将地理点绘制到地图上.如果你已经有一个地理点列表,你可以看看 drawPath() 方法;并调整您将地理坐标参数传递给它的方式(我将它封装到一个简单的 bean 中,命名为 NavigationDataSet).
This example parses a kml files (xml format as provided by Google Maps or Google Earth for route calculation) and draws the geo points onto the map. If you already have a list of geo points, you can just look at the drawPath() method; and adjust the way you pass the geo coords parameters to it (I encapsulated it into a simple bean that I named NavigationDataSet).
这篇关于Android从大量的经度/纬度点在mapView上绘制路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!