Search in sources :

Example 21 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project collect by opendatakit.

the class GeoShapeGoogleMapActivity method zoomToBounds.

private void zoomToBounds() {
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        public void run() {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (Marker marker : markerArray) {
                builder.include(marker.getPosition());
            }
            LatLngBounds bounds = builder.build();
            // offset from edges of the map in pixels
            int padding = 200;
            CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
            map.animateCamera(cu);
        }
    }, 100);
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) Handler(android.os.Handler) Marker(com.google.android.gms.maps.model.Marker) CameraUpdate(com.google.android.gms.maps.CameraUpdate)

Example 22 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project collect by opendatakit.

the class GeoTraceGoogleMapActivity method zoomToBounds.

private void zoomToBounds() {
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        public void run() {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (Marker marker : markerArray) {
                builder.include(marker.getPosition());
            }
            LatLngBounds bounds = builder.build();
            // offset from edges of the map in pixels
            int padding = 200;
            CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
            map.animateCamera(cu);
        }
    }, 100);
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) Handler(android.os.Handler) Marker(com.google.android.gms.maps.model.Marker) CameraUpdate(com.google.android.gms.maps.CameraUpdate)

Example 23 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project IITB-App by wncc.

the class MapFragment method onMapReady.

@Override
public void onMapReady(GoogleMap gMap) {
    googleMap = gMap;
    if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        checkLocationPermission();
    } else {
        googleMap.setMyLocationEnabled(true);
        googleMap.getUiSettings().setMyLocationButtonEnabled(false);
    }
    locationButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FFFFFF")));
    // Initialize Google Play Services
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            // Location Permission already granted
            buildGoogleApiClient();
            googleMap.setMyLocationEnabled(true);
        } else {
            // Request Location Permission
            checkLocationPermission();
        }
    } else {
        buildGoogleApiClient();
        googleMap.setMyLocationEnabled(true);
    }
    googleMap.getUiSettings().setZoomGesturesEnabled(true);
    LatLngBounds iitbBounds = new LatLngBounds(new LatLng(19.1249000, 72.9046000), new LatLng(19.143522, 72.920000));
    googleMap.setLatLngBoundsForCameraTarget(iitbBounds);
    googleMap.setMaxZoomPreference(30);
    googleMap.setMinZoomPreference(14.5f);
    // Position the map's camera near Mumbai
    LatLng iitb = new LatLng(19.1334, 72.9133);
    googleMap.addMarker(new MarkerOptions().position(iitb).title("Marker in IITB"));
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(iitb));
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) LatLng(com.google.android.gms.maps.model.LatLng)

Example 24 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project HikingApp by wickhama.

the class CustomMapFragment method moveCameraToTrail.

public void moveCameraToTrail() {
    if (mBuilder != null) {
        LatLngBounds bounds = mBuilder.build();
        mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 200));
    }
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds)

Example 25 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project android-samples by googlemaps.

the class MarkerCloseInfoWindowOnRetapDemoActivity method onMapReady.

@Override
public void onMapReady(GoogleMap map) {
    mMap = map;
    // Hide the zoom controls.
    mMap.getUiSettings().setZoomControlsEnabled(false);
    // Add lots of markers to the map.
    addMarkersToMap();
    // Set listener for marker click event.  See the bottom of this class for its behavior.
    mMap.setOnMarkerClickListener(this);
    // Set listener for map click event.  See the bottom of this class for its behavior.
    mMap.setOnMapClickListener(this);
    // Override the default content description on the view, for accessibility mode.
    // Ideally this string would be localized.
    map.setContentDescription("Demo showing how to close the info window when the currently" + " selected marker is re-tapped.");
    LatLngBounds bounds = new LatLngBounds.Builder().include(PERTH).include(SYDNEY).include(ADELAIDE).include(BRISBANE).include(MELBOURNE).build();
    mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds)

Aggregations

LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)42 LatLng (com.google.android.gms.maps.model.LatLng)27 CameraUpdate (com.google.android.gms.maps.CameraUpdate)11 Marker (com.google.android.gms.maps.model.Marker)6 Intent (android.content.Intent)5 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)5 ArrayList (java.util.ArrayList)5 View (android.view.View)4 JSONException (org.json.JSONException)4 Handler (android.os.Handler)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 AutocompletePrediction (com.google.android.gms.location.places.AutocompletePrediction)3 AutocompletePredictionBuffer (com.google.android.gms.location.places.AutocompletePredictionBuffer)3 GoogleMap (com.google.android.gms.maps.GoogleMap)3 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 SuppressLint (android.annotation.SuppressLint)2 Cursor (android.database.Cursor)2