您好我正在尝试在kotlin中实现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() }
答案 0 :(得分:1)
-33.8479731,150.6517908
mapFragment?.getMapAsync { map -> // <- this is the map that you got async not mMap val sydney = LatLng(-33.8479731, 150.6517908) map.addMarker(... map.moveCamera(... }