2017-02-02 16 views
0

我有一個帶有地圖的Android應用程序。map:cameraTargetLat或cameraZoom在我的XML中沒有任何效果

我嘗試設置默認的地圖位置,以一個特定的地方,因此應用程序不使用默認位置開始(這似乎是0,0)

但無論我做什麼,地圖依然在開始非洲儘管標籤:

<fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     xmlns:map="http://schemas.android.com/tools"//or "http://schemas.android.com/apk/res-auto", same result 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     map:cameraTargetLat="50.5863828" 
     map:cameraTargetLng="4.0802475" 
     map:cameraZoom="11"/> 

任何想法可能是錯誤的,我在2型動物這種行爲和習慣放棄,但我真的想設置默認的位置,而無需等待和編程這樣做。

enter image description here

+0

'的xmlns:地圖=」 http://schemas.android.com/apk/res-auto「'爲我工作,但採取[這](http://stackoverflow.com/questions/38465977/unexpected-namespace-map-android-google-maps- api/38466409#38466409)納入帳戶 – antonio

+0

這不是同一個問題。我沒有前綴問題。 –

+0

是的,我明白了。我的意思是說我使用'xmlns:map =「http://schemas.android.com/apk/res-auto」'(但意外的命名空間前綴問題) – antonio

回答

0

給你的經緯度在移動地圖到您的默認位置,

map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(23.0225,72.5317) , 14.0f)); 

,如果你想放標誌物有則寫

map.addMarker(new MarkerOptions() 
    .position(new LatLng(23.0225, 72.5315)) 
    .title("Marker")); 
+1

是的,我知道,但我不知道不認爲這真的回答了我的問題..我想通過XML實現移動效果,如文檔所述..而我從來沒有談論過標記 –

相關問題