Android 折线地图 api
好吧,我是android的初学者,我需要更具体地使用设备上的地图(折线)我需要做这样的事情。
这是一个网络应用程序,我用来追踪我所在城市的巴士路线和巴士站,我已被要求在 Android 中做同样的事情!我一直在检查android的地图api,没有在JS api中找到任何类似于折线的东西,有没有办法实现这一点?
我添加简单的叠加层没有问题我一直在检查android开发者网站中的基本教程,但我不知道如何绘制折线。
well, im a begginer in android and i need to use maps on the device more specifically (polylines) i need to do something like this.
this is a web app i did to track down bus routes and bus-stops on my city , and i've been asked to do the same thing in android! ive been checking the maps api for android and did not found anything similar to polyline in JS api , is there a way to achieve this?
i have no problem adding simple overlays i've been checking the basic tutorials in android developer site, but i dont know how to draw the polyline.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Android Google Maps API 中没有这样的 API。您只能先列出要绘制的路线的实际 GeoPoints,然后在 Overlay 对象上绘制点和线。没有简单的方法可以做到这一点。
There no such API in Android Google Maps API. You can only first list the actual GeoPoints of the route that you want to draw and then draw the points and lines on a Overlay object. There's just no easy way to do that.
一种更简单的方法是获取点并扩展将显示图像的 ImageView 来绘制点,而不是只需要传递要绘制的点。
在我的项目中,我这样做了:
}
当您扩展 Imageview 并使用 xml 创建布局时,不要忘记将新小部件的整个包放入其中,例如:
com.Myapp.MyImageView
A more easy way to do that is get your points and extend the ImageView that will display your image to draw the points, than you just need to pass the points that you want to draw .
In my project I did this:
}
When you extends the Imageview and create the layout with xml don`t forget to put the entire package of you new widget like:
com.Myapp.MyImageView
FvZ的答案有效,但不是原生方式,地图上有折线,一个简单的例子
https://stackoverflow.com/a/21877742/618419
另外看看Android文档,他们有很多简单的以及精心整理的示例:
http://developer.android.com/参考/com/google/android/gms/maps/model/Polyline.html
FvZ's answer works but is not the native way, there are polylines on the map, a simple example
https://stackoverflow.com/a/21877742/618419
Also take a look at the Android Documentation, they have many simple and well put-together examples:
http://developer.android.com/reference/com/google/android/gms/maps/model/Polyline.html