teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

不要なコードの削除

2021/11/10 03:21

投稿

msuke
msuke

スコア15

title CHANGED
File without changes
body CHANGED
@@ -49,55 +49,8 @@
49
49
  <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AI****</string>
50
50
  </resources>
51
51
  ```
52
- ```xml
53
- import androidx.appcompat.app.AppCompatActivity
54
- import android.os.Bundle
55
52
 
56
- import com.google.android.gms.maps.CameraUpdateFactory
57
- import com.google.android.gms.maps.GoogleMap
58
- import com.google.android.gms.maps.OnMapReadyCallback
59
- import com.google.android.gms.maps.SupportMapFragment
60
- import com.google.android.gms.maps.model.LatLng
61
- import com.google.android.gms.maps.model.MarkerOptions
62
- import com.example.samplegooglemap.databinding.ActivityMapsBinding
63
53
 
64
- class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
65
-
66
- private lateinit var mMap: GoogleMap
67
- private lateinit var binding: ActivityMapsBinding
68
-
69
- override fun onCreate(savedInstanceState: Bundle?) {
70
- super.onCreate(savedInstanceState)
71
-
72
- binding = ActivityMapsBinding.inflate(layoutInflater)
73
- setContentView(binding.root)
74
-
75
- // Obtain the SupportMapFragment and get notified when the map is ready to be used.
76
- val mapFragment = supportFragmentManager
77
- .findFragmentById(R.id.map) as SupportMapFragment
78
- mapFragment.getMapAsync(this)
79
- }
80
-
81
- /**
82
- * Manipulates the map once available.
83
- * This callback is triggered when the map is ready to be used.
84
- * This is where we can add markers or lines, add listeners or move the camera. In this case,
85
- * we just add a marker near Sydney, Australia.
86
- * If Google Play services is not installed on the device, the user will be prompted to install
87
- * it inside the SupportMapFragment. This method will only be triggered once the user has
88
- * installed Google Play services and returned to the app.
89
- */
90
- override fun onMapReady(googleMap: GoogleMap) {
91
- mMap = googleMap
92
-
93
- // Add a marker in Sydney and move the camera
94
- val sydney = LatLng(-34.0, 151.0)
95
- mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney"))
96
- mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
97
- }
98
- }
99
- ```
100
-
101
54
  ### 試したこと
102
55
 
103
56
  手持ちの書籍(今知ったんですけど2019年発行のものだから少々古い)によると

1

詳細の追加

2021/11/10 03:21

投稿

msuke
msuke

スコア15

title CHANGED
File without changes
body CHANGED
File without changes