2016-10-19 28 views
0

我有一個地圖,我想放置ImageView,其頂端觸及赤道。我將屬性centerVertical = true和centerHorizo​​ntal = true賦予ImageView,但它沒有定位在赤道上。我得到了地圖的中心,但我希望ImageView定位在地圖的赤道上。Android地圖ImageView在赤道上的地圖

截圖:

enter image description here

代碼:

@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> 

回答

0

您應該使用標記。您也可以自定義它們。查看Google和SO的以下文檔。

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

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

+0

我想,即使用戶移動地圖 – jobin

+0

使用投影類我赤道的經緯度(0.0,0.0)的屏幕位置可看到的標記,但它表明X y值爲0. – jobin

+0

只需將「雙倍高度」設置爲「drawable/marker」,其中心應位於底部。並看看[this](http://stackoverflow.com/q/40112760/6950238)的對話。 –

相關問題