簡體   English   中英

谷歌地圖未顯示標記Android

[英]Google Maps not showing marker android

因此,我嘗試實現自己的Google Maps Activity版本,但無濟於事。 我遇到了一個問題,我的標記沒有顯示,經過幾個小時的弄不清之后,我刪除了代碼並復制了這個工作示例。 除了,當我運行它時,這是同樣的問題。 地圖不會縮放到指定位置,也不會顯示地圖標記。 這使我相信onReady部分存在問題,但是我不確定。 我曾嘗試遵循其他堆棧問題/答案,但似乎無法找出問題所在。 它顯示Google Map,我可以手動放大它,並更新街道和其他信息,但沒有標記。

Pastebin鏈接到Java代碼

XML檔案:
<fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.test.logintest.MapsActivity" />

嘗試通過在onMapReady()方法中添加markeroptions代碼。 當位置發生變化(onLocationChanged())時,它可能會像您當前正在添加標記的那樣工作。

LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Position");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
    mCurrLocationMarker = mGoogleMap.addMarker(markerOptions);

找到了問題。 這實際上是我其他Java文件中的錯誤。 我試圖切換活動,但沒有實際切換活動,而是僅更改了視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM