2
你好,我想在科特林來實現Google Maps
,但在這些代碼我getMapAsync
是沒有得到所謂的地圖完美展現,但標記不露面科特林與地圖(標記不顯示)
var mapFragment : SupportMapFragment?=null
mapFragment= fragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync {
val sydney = LatLng(22.30, 73.20)
mMap!!.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney"))
mMap!!.moveCamera(CameraUpdateFactory.newLatLng(sydney))
Toast.makeText(activity,"dfgdg",Toast.LENGTH_LONG).show() }
'mapFragment'可能是零,這意味着'fragmentManager'無法找到它。你是否在代碼中的某個地方初始化了'SupportMapFragment'? –
其實地圖在屏幕上顯示,但標記不添加 –
你可以顯示你的佈局XML嗎?或者你在某處調用'SupportMapFragment()'(構造函數)? –