如何在android中的地图触摸位置上动态绘制形状 [英] How to draw a shape dynamically on map touched location in android
问题描述
我想画一个形状,无论用户触摸地图,都应该动态绘制。我对绘制这些形状没有任何想法。我怎么能做到这一点?我可以通过画布完成这件事吗?我使用MapFragment。
请参阅图片, $ b
请给我任何想法!您可以通过添加一个 View $ c $>来完成任何帮助!
c>叠加地图。
Polyline
对象(最初为空)将成为你的路线
LatLng
使用 Projection
Polyline
您完成了。
<请注意,这会消耗所有会以其他方式进行地图平移或缩放的事件。您必须有其他方式与地图进行交互,或者使用某些标志启用消费事件。
I want to draw a shape, wherever the user touches the map, the should be drawn dynamically. I don't have any idea about drawing these shapes. How could I achieve this? Can I get this done through canvas? I am using MapFragment.
Please see the image,
Please give me any idea!! Any help is appreciated!!
You can do that by adding a View
overlaying the map.
- have a
Polyline
object (initially empty) that will be your line - handle onTouchEvent on that
View
- translate x,y from events to
LatLng
usingProjection
- add new point to
Polyline
And you are done.
Note that this consumes all the events that would otherwise make map pan or zoom. You will have to have some other way to interact with map or enable consuming events using some flag.
这篇关于如何在android中的地图触摸位置上动态绘制形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!