Code example for GoogleMap

Methods: addMarkeranimateCameramoveCamerasetMapTypesetMyLocationEnabled

0
 
    } 
 
    private void setUpMap() { 
        // Enable Location 
        googleMap.setMyLocationEnabled(true);
 
        // get Location manager 
        LocationManager locationManager = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
 
        // Create Criteria Object to Retrieve Provider 
        Criteria criteria = new Criteria();
 
        // Get the name of the Best Provider 
        String provider = locationManager.getBestProvider(criteria, true);
 
        //Current Location 
 
        Location location = locationManager.getLastKnownLocation(provider);
 
        //setMapType 
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
 
        //Get current Latitude 
        double latitude = location.getLatitude();
        //get Current Longitude 
        double longitude = location.getLongitude();
 
        //Latln Object 
 
        LatLng latLng = new LatLng(latitude, longitude);
 
        // Show the Current Location in Google Map 
 
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
 
        // Zoom In 
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
        googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("You are Here"));
    } 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
Contextual code suggestions in your IDE  Get Codota for Java