【问题标题】:Android place ImageView on the equator of mapAndroid 将 ImageView 放在地图的赤道上
【发布时间】:2017-02-28 17:03:48
【问题描述】:

我有一张地图,我想在其上放置 ImageView,使其尖端接触赤道。我将属性 centerVertical=true 和 centerHorizo​​ntal=true 赋予 ImageView,但它没有定位在赤道上。我得到了中心地图,但我希望 ImageView 位于地图的赤道上。

截图:

代码:

@Override
    public void onMapReady(GoogleMap googleMap) {
        this.googleMap = googleMap;
        googleMap.getUiSettings().setZoomControlsEnabled(true);
        googleMap.getUiSettings().setCompassEnabled(true);
        //center of map
        LatLng centerOfMap=this.googleMap.getCameraPosition().target;
}

marker_view.xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <ImageView
        android:id="@+id/marker_icon_view"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="162dp"
        android:contentDescription="@string/app_name"
        android:src="@drawable/marker" />
</RelativeLayout>

【问题讨论】:

    标签: android dictionary


    【解决方案1】:

    您应该使用标记。您也可以自定义它们。请查看 Google 和 SO 提供的以下文档。

    https://developers.google.com/maps/documentation/android-api/marker

    How to create a custom-shaped bitmap marker with Android map API v2

    【讨论】:

    • 我希望即使用户移动地图也能看到标记
    • 使用 Projection 类我得到了赤道 LatLng(0.0,0.0) 的屏幕位置,但它显示 x 和 y 值为 0。
    • 只需为您的drawable/marker 设置双倍高度,其中心应位于底部。并查看this 对话。
    猜你喜欢
    • 1970-01-01
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多