mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
chore: Add mMap instance variable to match wizard.
This commit is contained in:
parent
8985cb9643
commit
98994bde77
@ -28,6 +28,8 @@ import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
private GoogleMap mMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -50,11 +52,13 @@ public class MapsActivity extends AppCompatActivity implements OnMapReadyCallbac
|
||||
*/
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
|
||||
// Add a marker in Sydney and move the camera
|
||||
LatLng sydney = new LatLng(-34, 151);
|
||||
googleMap.addMarker(new MarkerOptions()
|
||||
mMap.addMarker(new MarkerOptions()
|
||||
.position(sydney)
|
||||
.title("Marker in Sydney"));
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,8 @@ import com.google.maps.example.R
|
||||
|
||||
class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
private lateinit var mMap: GoogleMap
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_maps)
|
||||
@ -46,11 +48,13 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
* installed Google Play services and returned to the app.
|
||||
*/
|
||||
override fun onMapReady(googleMap: GoogleMap) {
|
||||
mMap = googleMap
|
||||
|
||||
// Add a marker in Sydney and move the camera
|
||||
val sydney = LatLng(-34.0, 151.0)
|
||||
googleMap.addMarker(MarkerOptions()
|
||||
mMap.addMarker(MarkerOptions()
|
||||
.position(sydney)
|
||||
.title("Marker in Sydney"))
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user