Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. package com.example.tutorialspoint7.myapplication;
  2.  
  3. import android.support.v4.app.FragmentActivity;
  4. import android.os.Bundle;
  5.  
  6. import com.google.android.gms.maps.CameraUpdateFactory;
  7. import com.google.android.gms.maps.GoogleMap;
  8. import com.google.android.gms.maps.OnMapReadyCallback;
  9. import com.google.android.gms.maps.SupportMapFragment;
  10. import com.google.android.gms.maps.model.LatLng;
  11. import com.google.android.gms.maps.model.MarkerOptions;
  12.  
  13. public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
  14.  
  15.    private GoogleMap mMap;
  16.  
  17.    @Override
  18.    protected void onCreate(Bundle savedInstanceState) {
  19.       super.onCreate(savedInstanceState);
  20.       setContentView(R.layout.activity_maps);
  21.       // Obtain the SupportMapFragment and get notified when the map is ready to be used.
  22.       SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  23.          .findFragmentById(R.id.map);
  24.       mapFragment.getMapAsync(this);
  25.    }
  26.    
  27.    /**
  28.       * Manipulates the map once available.
  29.       * This callback is triggered when the map is ready to be used.
  30.       * This is where we can add markers or lines, add listeners or move the camera.
  31.       * In this case, we just add a marker near Sydney, Australia.
  32.       * If Google Play services is not installed on the device.
  33.       * This method will only be triggered once the user has installed
  34.          Google Play services and returned to the app.
  35.    */
  36.  
  37.    @Override
  38.    public void onMapReady(GoogleMap googleMap) {
  39.       mMap = googleMap;
  40.       // Add a marker in Sydney and move the camera
  41.       LatLng TutorialsPoint = new LatLng(21, 57);
  42.       mMap.addMarker(new
  43.          MarkerOptions().position(TutorialsPoint).title("Tutorialspoint.com"));
  44.       mMap.moveCamera(CameraUpdateFactory.newLatLng(TutorialsPoint));
  45.    }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement