Advertisement
Guest User

ITISSSS

a guest
Jan 29th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package com.example.maps;
  2.  
  3.  
  4.  
  5.  
  6. import androidx.fragment.app.FragmentActivity;
  7.  
  8. import android.os.Bundle;
  9.  
  10.  
  11. import com.google.android.gms.maps.CameraUpdate;
  12. import com.google.android.gms.maps.CameraUpdateFactory;
  13. import com.google.android.gms.maps.GoogleMap;
  14. import com.google.android.gms.maps.OnMapReadyCallback;
  15. import com.google.android.gms.maps.SupportMapFragment;
  16. import com.google.android.gms.maps.model.LatLng;
  17. import com.google.android.gms.maps.model.MarkerOptions;
  18.  
  19. public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
  20.  
  21. private GoogleMap mMap;
  22. @Override
  23. protected void onCreate(Bundle savedInstanceState) {
  24.  
  25.  
  26.  
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_maps);
  29. // Obtain the SupportMapFragment and get notified when the map is ready to be used.
  30. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  31. .findFragmentById(R.id.map);
  32. mapFragment.getMapAsync(this);
  33. }
  34.  
  35.  
  36. /**
  37. * Manipulates the map once available.
  38. * This callback is triggered when the map is ready to be used.
  39. * This is where we can add markers or lines, add listeners or move the camera. In this case,
  40. * we just add a marker near Sydney, Australia.
  41. * If Google Play services is not installed on the device, the user will be prompted to install
  42. * it inside the SupportMapFragment. This method will only be triggered once the user has
  43. * installed Google Play services and returned to the app.
  44. */
  45. @Override
  46.  
  47. public void onMapReady(GoogleMap googleMap) {
  48. mMap = googleMap;
  49.  
  50. LatLng sagata = new LatLng(38.071228, 14.640205);
  51.  
  52. mMap.addMarker(new MarkerOptions().position(sagata).title("Marker in Scuola Sant'Agata"));
  53. //mMap.moveCamera(CameraUpdateFactory.newLatLng(sagata));
  54.  
  55.  
  56. //Impostiamo la camera più vicina al posto desiderato
  57. CameraUpdate center =
  58. CameraUpdateFactory.newLatLng(new LatLng(38.071228, 14.640205)); //Prendo la posizione di dove ci vogliamo focalizzare
  59. CameraUpdate zoom=CameraUpdateFactory.zoomTo(17); //Scegliamo quanto deve ingrandire
  60. mMap.moveCamera(center); //Specifico che deve mantenere il punto scelto al centro
  61. mMap.animateCamera(zoom);
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement