开发者

Android: Move point on the google map when clicking somewhere on the map

I want to give my users oppertinty to choose destination. from the beginning it will already have a point on the map, and after that they can choos开发者_高级运维e/change to another location if they want..

how is it possible to change the point on the map, by clicking somewhere else on the map?


I assume you're talking about a MapView within your application, and not in the Google Maps app. There's a method on a MapView called onTouchEvent(). This callback will be called when a user clicks (or touches) on the map, and you can read the location of the touch from the MotionEvent object that's passed in. From there you can decide what you want to do.

Another way is to extend the Overlay class, and add it to your MapView's Overlay list. Overlay has a method called onTap(), which gives you the GeoPoint where the touch took place. You can then animate to that spot using the MapController to center the map on that spot.

If all you want to do is pan the map sideways, a user can simply touch and drag the map.

For these things to work the MapView must be clickable (settable in XML or with code).

The relevant reference pages are here: URL to Android Maps API


i think this tutorial is perfect one. You should read carefully content of source code. That's all what u need to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜