Android的图形页面坐标x屏幕位置 [英] Android MapView coordinates x screen position
问题描述
我开发了需要处理MapView类Android应用程序。我基本上需要做的就是要摆正屏幕PIN码的中心,这将是比使用相对布局的MapView。用户可以根据他的意愿移动地图。移动地图和定位PIN码后,我需要从这一立场得到协调(纬度和经度)。
I am developing an android application which needs to handle mapview. What I basically need to do is to put right on the center of the screen a PIN, which will be over the mapview using relative layout. The user can move the map according to his will. After moving the map and positioning the PIN, I need to get the coordinated (lat and lng) from that position.
有基本上类似于该用户可以请求一个驾驶室中的应用。
UberCab
It is basically similar to the application that the user can request a cab. UberCab
第三段说:固定栓下的地图和[使用]整个地图例如,作为该公司的博客文章解释说,当你订购的车,你可以通过移动设置拿起位置精确地设置您的位置。在Android应用程序的信息面板有一个干净的透明性让您专注在地图上,并在你的方向。
The third paragraph says: "For example, as explained on the company’s blog post, when you are ordering a car you can set the pick up location by moving "the map under the stationary pin and [using] the entire map to set your location accurately. The information panels on the Android app have a clean transparency that allows you to focus on the map, and where you’re headed."
我的布局将是这个样子:
My layout will be this way:
<RelativeLayout android:id="@+id/mapviewContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/tvCurrentAddress">
<ImageView android:id="@+id/pin_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pin_red"
android:layout_centerInParent="true" />
<com.google.android.maps.MapView android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="@string/mapKey" />
</RelativeLayout>
我想实现同样的事情。有谁知道如何实现这一目标?
I would like to achieve the same thing. Does anyone know how to achieve this?
感谢您的关注。
T
推荐答案
您不会与一个RelativeLayout的事情。 //$c$c.google.com/android/add-ons/google-apis/reference/index:引脚和基本上什么在链接到地理坐标绘制的MapView类是使用的叠加或更常见的的 ItemizedOverlay 。
You would not do with with a RelativeLayout. Pins and basically anything drawn on a MapView that is linked to geo coordinates is drawn using an Overlay or more commonly an ItemizedOverlay.
虽然回答您的主要问题。您可以通过一个类似的系统转换坐标像素坐标:
Though to answer your main question. You can convert coordinates to pixel coordinates by a system similar to this:
GeoPoint location;
-- get the location someway like through the onTap method --
Point screenPoint = new Point();
mapView.getProjection().toPixels(location, screenPoint);
现在screenPoint将有GeoPoint对象的像素坐标。
Now screenPoint will have the pixel coordinates of the GeoPoint.
这篇关于Android的图形页面坐标x屏幕位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!