- 528 名前:デフォルトの名無しさん (ワッチョイ c301-+Do1) [2020/06/14(日) 19:03:28 ID:/+z0TSBQ0.net]
- MapView.getMapAsync()をコールしてもGoogleMapが起動しないのですがFragmentを利用しないと出来ないのでしょうか?
■activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.gms.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="wrap_content" android:apiKey="@string/google_maps_key" /> </LinearLayout> class MapsActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val mv = findViewById<MapView>(R.id.mapView) mv.getMapAsync { p0 -> val sydney = LatLng(-34.0, 151.0) p0!!.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney")) p0!!.moveCamera(CameraUpdateFactory.newLatLng(sydney)) } } }
|

|