質問編集履歴
2
不要なコードの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -100,101 +100,7 @@
|
|
100
100
|
|
101
101
|
```
|
102
102
|
|
103
|
-
```xml
|
104
103
|
|
105
|
-
import androidx.appcompat.app.AppCompatActivity
|
106
|
-
|
107
|
-
import android.os.Bundle
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
import com.google.android.gms.maps.CameraUpdateFactory
|
112
|
-
|
113
|
-
import com.google.android.gms.maps.GoogleMap
|
114
|
-
|
115
|
-
import com.google.android.gms.maps.OnMapReadyCallback
|
116
|
-
|
117
|
-
import com.google.android.gms.maps.SupportMapFragment
|
118
|
-
|
119
|
-
import com.google.android.gms.maps.model.LatLng
|
120
|
-
|
121
|
-
import com.google.android.gms.maps.model.MarkerOptions
|
122
|
-
|
123
|
-
import com.example.samplegooglemap.databinding.ActivityMapsBinding
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
private lateinit var mMap: GoogleMap
|
132
|
-
|
133
|
-
private lateinit var binding: ActivityMapsBinding
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
138
|
-
|
139
|
-
super.onCreate(savedInstanceState)
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
binding = ActivityMapsBinding.inflate(layoutInflater)
|
144
|
-
|
145
|
-
setContentView(binding.root)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
150
|
-
|
151
|
-
val mapFragment = supportFragmentManager
|
152
|
-
|
153
|
-
.findFragmentById(R.id.map) as SupportMapFragment
|
154
|
-
|
155
|
-
mapFragment.getMapAsync(this)
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
/**
|
162
|
-
|
163
|
-
* Manipulates the map once available.
|
164
|
-
|
165
|
-
* This callback is triggered when the map is ready to be used.
|
166
|
-
|
167
|
-
* This is where we can add markers or lines, add listeners or move the camera. In this case,
|
168
|
-
|
169
|
-
* we just add a marker near Sydney, Australia.
|
170
|
-
|
171
|
-
* If Google Play services is not installed on the device, the user will be prompted to install
|
172
|
-
|
173
|
-
* it inside the SupportMapFragment. This method will only be triggered once the user has
|
174
|
-
|
175
|
-
* installed Google Play services and returned to the app.
|
176
|
-
|
177
|
-
*/
|
178
|
-
|
179
|
-
override fun onMapReady(googleMap: GoogleMap) {
|
180
|
-
|
181
|
-
mMap = googleMap
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
// Add a marker in Sydney and move the camera
|
186
|
-
|
187
|
-
val sydney = LatLng(-34.0, 151.0)
|
188
|
-
|
189
|
-
mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney"))
|
190
|
-
|
191
|
-
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
|
-
}
|
196
|
-
|
197
|
-
```
|
198
104
|
|
199
105
|
|
200
106
|
|
1
詳細の追加
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|