谷歌地图API V2 - 如何保持一个标记在屏幕的中心,而用户滚动地图? [英] Google Map API V2 - How do I keep a marker in the center of the screen while user is scrolling the map?

查看:522
本文介绍了谷歌地图API V2 - 如何保持一个标记在屏幕的中心,而用户滚动地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌地图API V2 - 如何保持一个标记在屏幕的中心,而用户滚动地图

Google Map API V2 - How do I keep a marker in the center of the screen while user is scrolling the map ?

我的目的是让用户选择一个位置。我用下面的code添加标记(这是从 com.example.mapdemo 在Android SDK中)

My purpose is to let user choose a location. I use the following code to add a marker (it's from the com.example.mapdemo in Android SDK)

mMap.addMarker(new MarkerOptions()
    .position(new LatLng(0, 0))
    .title("Marker"));

我如何保持标志在屏幕的中央,然后检索它的位置?

How do I keep the marker in the center of the screen and then retrieve it's location?

推荐答案

我不认为你实际上可以保持一个标志在屏幕中间,容易浮起来。我的建议是,以欺骗用户。添加您的标记图像上就像一个按钮,地图上。可以将其放置在使用的XML布局屏幕的中间。然后,当用户选择一个位置,就检索GPS在屏幕的中间协调。

I do not think that you can actually keep a marker in the middle of the screen and float it easily. My suggestion is to trick your user. Add your marker image onto the map like a button. you can place it in the middle of the screen using the xml layout. Then when your user selects a location just retrieve the gps coordinates from the middle of the screen.

在一个侧面说明,你也可以直接做标记拖动然后用户可以拖动地图。

On a side note you could also just make your marker draggable Then the user could drag it around the map.

mMap.addMarker(new MarkerOptions().position(coordinate)
                    .title("Your Title")
                    .snippet("Please move the marker if needed.")
                    .draggable(true)); 

这篇关于谷歌地图API V2 - 如何保持一个标记在屏幕的中心,而用户滚动地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆