大家好,
我使用的谷歌地图V2,我必须通过触摸它来绘制在地图上的片段的形状。 也就是说,如果我旋转应生成的形状在地图上我的手指。 我得到的问题,因为谷歌mapV2不提供经纬度,长的,当我们触摸 地图。我有没有必要去点击MapV2所以点击监听器是没有用的我。
I am using Google map V2 and I have to draw a shape on the map fragment by touching it. i.e if I rotate my fingers on the map a shape should be generated. I am getting problem because Google mapV2 does not provide lat ,long when we touch the map. I have no need to click on MapV2 so click listener is not useful for me.
所以,请分享任何想法或code。通过获得从地图的经纬度 触摸它。所以,我会通过触摸地图上画出一个形状。
So please share any idea or code to get the latitude and longitude from the map by touching it. So that I would draw a shape by touching the map.
GoogleMap的
没有触摸监听器,所以你必须重写的onTouchEvent
您 MapFragment
的父视图。一旦你有你的触摸事件的屏幕坐标,你可以得到的纬度/龙使用投影
(文件here).简单地做
GoogleMap
doesn't have a touch listener, so you'll have to override onTouchEvent
for the parent view of your MapFragment
. Once you have the screen coordinates of your touch event, you can get the Lat/Long by using Projection
(Doc here). Simply do
经纬度COORDS = mapFragment.getMap()getProjection()fromScreenLocation(点);
其中,点
是一个 点
描述你的触摸事件的位置。
Where point
is a Point
describing the location of your touch event.
一旦你的经纬度
描述你的触摸事件,可以得出使用形状或者圆
或多边形
。谷歌的绘制形状教程将做解释它的一个更好的工作比我:形状 - 谷歌地图V2
Once you have the LatLng
describing your touch event, you can draw shapes using either Circle
or Polygon
. Google's tutorial on drawing shapes will do a better job of explaining it than I could: Shapes - Google Maps v2
希望这有助于!
上一篇:为什么我只有asp.net成员表的一个子集?子集、成员、asp、net
下一篇:如何在MJPEG流为3GP或MP4格式的视频文件保存到Android上的SD卡视频文件、格式、如何在、MJPEG