// UI settings of map private void mapUiSetting(boolean flag) { uiSettings.setZoomControlsEnabled(flag); uiSettings.setCompassEnabled(flag); uiSettings.setMyLocationButtonEnabled(flag); uiSettings.setScrollGesturesEnabled(flag); uiSettings.setZoomGesturesEnabled(flag); uiSettings.setTiltGesturesEnabled(flag); uiSettings.setRotateGesturesEnabled(flag); }
public void disableGestures() { UiSettings uiSettings = googleMap.getUiSettings(); uiSettings.setMyLocationButtonEnabled(false); uiSettings.setTiltGesturesEnabled(false); uiSettings.setZoomGesturesEnabled(false); uiSettings.setZoomControlsEnabled(false); uiSettings.setRotateGesturesEnabled(false); uiSettings.setMyLocationButtonEnabled(false); uiSettings.setScrollGesturesEnabled(false); uiSettings.setCompassEnabled(false); }
/** * Manipulates the map once available. This callback is triggered when the map is ready to be * used. This is where we can add markers or lines, add listeners or move the camera. In this * case, we just add a marker near Sydney, Australia. If Google Play services is not installed on * the device, the user will be prompted to install it inside the SupportMapFragment. This method * will only be triggered once the user has installed Google Play services and returned to the * app. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // mMap.setMyLocationEnabled(true); mMap.setBuildingsEnabled(true); mMap.setTrafficEnabled(true); UiSettings gmapsettings = mMap.getUiSettings(); gmapsettings.setMyLocationButtonEnabled(true); gmapsettings.setCompassEnabled(true); gmapsettings.setZoomControlsEnabled(true); gmapsettings.setZoomControlsEnabled(true); gmapsettings.setScrollGesturesEnabled(true); gmapsettings.setRotateGesturesEnabled(true); Intent ri = getIntent(); Bundle a = ri.getExtras(); String start = a.getString("start"); String end = a.getString("end"); Geocoder geocoder = new Geocoder(this); List<Address> addresses = null; try { addresses = geocoder.getFromLocationName(start, 1); } catch (IOException e) { e.printStackTrace(); } double slatitude = addresses.get(0).getLatitude(); double slongitude = addresses.get(0).getLongitude(); // Add a marker to start LatLng smarker = new LatLng(slatitude, slongitude); mMap.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.markers1)) .position(smarker) .title("Pick Up")); mMap.moveCamera(CameraUpdateFactory.newLatLng(smarker)); try { addresses = geocoder.getFromLocationName(end, 1); } catch (IOException e) { e.printStackTrace(); } double elatitude = addresses.get(0).getLatitude(); double elongitude = addresses.get(0).getLongitude(); // Add a marker to end LatLng emarker = new LatLng(elatitude, elongitude); mMap.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.markers2)) .position(emarker) .title("Destination")); mMap.moveCamera(CameraUpdateFactory.newLatLng(emarker)); LatLng origin = smarker; LatLng dest = emarker; // Getting URL to the Google Directions API String url = getDirectionsUrl(origin, dest); DownloadTask downloadTask = new DownloadTask(); // Start downloading json data from Google Directions API downloadTask.execute(url); mMap.animateCamera(CameraUpdateFactory.newLatLng(smarker)); }