private void setUpMap() {
    verifyLocationPermission();

    mMap.setOnMapClickListener(this);
    mMap.setOnInfoWindowClickListener(this);

    UiSettings settings = mMap.getUiSettings();
    settings.setAllGesturesEnabled(true);
    settings.setMapToolbarEnabled(false);

    // Use stops location if present, otherwise set a geo point in
    // central Stockholm.
    LatLng latLng;
    int zoom;
    if (mStop.getLocation() != null) {
      latLng = new LatLng(mStop.getLocation().getLatitude(), mStop.getLocation().getLongitude());
      zoom = 16;
    } else {
      latLng = new LatLng(59.325309, 18.069763);
      zoom = 12;
    }

    mMarker =
        mMap.addMarker(
            new MarkerOptions()
                .position(latLng)
                .title(getString(R.string.tap_to_select_this_point))
                .visible(true)
                .draggable(true)
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
    mMarker.showInfoWindow();

    mMap.moveCamera(
        CameraUpdateFactory.newCameraPosition(CameraPosition.fromLatLngZoom(latLng, zoom)));
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_maps, container, false);
    setUpMapIfNeeded();
    if (savedInstanceState != null) {
      mMap.getCameraPosition();
      //  mMap = savedInstanceState.get   ///getInt(KEY_QUOTE_INDEX);
    }
    mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
    UiSettings uiSettings = mMap.getUiSettings();
    uiSettings.setZoomControlsEnabled(true);
    mMap.setMyLocationEnabled(true);
    uiSettings.setMapToolbarEnabled(true);
    //  CustomMapFragment mapFragment = new CustomMapFragment();
    // FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    // transaction.add(R.id.map_container, mapFragment).commit();
    return rootView;
    //
    // changes the map from street to view to satellite.

  }
Esempio n. 3
0
 @Override
 public void onMapReady(GoogleMap googleMap) {
   mGoogleMap = googleMap;
   mMarkersAdapter = new MarkersAdapter(getActivity(), googleMap);
   mMarkersAdapter.setFeatureMode(mFeatureMode);
   mMarkersAdapter.setFullInfoWindowEnabled(true);
   UiSettings settings = googleMap.getUiSettings();
   settings.setMyLocationButtonEnabled(true);
   settings.setCompassEnabled(true);
   settings.setAllGesturesEnabled(mMapGestureEnabled);
   settings.setMapToolbarEnabled(false);
   googleMap.setOnCameraChangeListener(this);
   googleMap.setOnMarkerClickListener(this);
   googleMap.setInfoWindowAdapter(mMarkersAdapter);
   googleMap.setOnInfoWindowClickListener(this);
   googleMap.setPadding(0, mToolbar.getHeight(), 0, mMapBottomPadding);
   getLoaderManager().initLoader(LOADER_MAP, null, mMapCallback);
   if (mMapLocation != null) {
     googleMap.moveCamera(
         CameraUpdateFactory.newLatLngZoom(
             new LatLng(mMapLocation.getLatitude(), mMapLocation.getLongitude()), DEFAULT_ZOOM));
     mMapLocation = null;
   }
 }