Search in sources :

Example 6 with GoogleMap

use of com.google.android.gms.maps.GoogleMap in project actor-platform by actorapp.

the class MapFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    longitude = getArguments().getDouble("longitude");
    latitude = getArguments().getDouble("latitude");
    final MapView map = new MapView(getActivity());
    map.onCreate(null);
    map.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(GoogleMap googleMap) {
            mapController = googleMap;
            googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title(""));
            googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 16));
            map.onResume();
        }
    });
    return map;
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) MapView(com.google.android.gms.maps.MapView) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) LatLng(com.google.android.gms.maps.model.LatLng)

Example 7 with GoogleMap

use of com.google.android.gms.maps.GoogleMap in project Signal-Android by WhisperSystems.

the class SignalMapView method display.

public ListenableFuture<Bitmap> display(final SignalPlace place) {
    final SettableFuture<Bitmap> future = new SettableFuture<>();
    this.mapView.onCreate(null);
    this.mapView.onResume();
    this.mapView.setVisibility(View.VISIBLE);
    this.imageView.setVisibility(View.GONE);
    this.mapView.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(final GoogleMap googleMap) {
            googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLong(), 13));
            googleMap.addMarker(new MarkerOptions().position(place.getLatLong()));
            googleMap.setBuildingsEnabled(true);
            googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            googleMap.getUiSettings().setAllGesturesEnabled(false);
            googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {

                @Override
                public void onMapLoaded() {
                    googleMap.snapshot(new GoogleMap.SnapshotReadyCallback() {

                        @Override
                        public void onSnapshotReady(Bitmap bitmap) {
                            future.set(bitmap);
                            imageView.setImageBitmap(bitmap);
                            imageView.setVisibility(View.VISIBLE);
                            mapView.setVisibility(View.GONE);
                            mapView.onPause();
                            mapView.onDestroy();
                        }
                    });
                }
            });
        }
    });
    this.textView.setText(place.getDescription());
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) Bitmap(android.graphics.Bitmap) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback)

Example 8 with GoogleMap

use of com.google.android.gms.maps.GoogleMap in project Remindy by abicelis.

the class PlaceActivity method onMapReady.

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {

        @Override
        public void onMapLongClick(LatLng latLng) {
            //Save lat and long
            mPlace.setLatitude(latLng.latitude);
            mPlace.setLongitude(latLng.longitude);
            //Add/Update marker and circle
            if (mPlaceMarker == null)
                drawMarkerWithCircle(latLng, mPlace.getRadius());
            else
                updateMarkerWithCircle(latLng);
            //Request its location
            Location loc = new Location(LocationManager.GPS_PROVIDER);
            loc.setLatitude(mPlaceMarker.getPosition().latitude);
            loc.setLongitude(mPlaceMarker.getPosition().longitude);
            SnackbarUtil.showSnackbar(mMapContainer, SnackbarUtil.SnackbarType.NOTICE, R.string.activity_place_snackbar_fetching_address, SnackbarUtil.SnackbarDuration.LONG, null);
            fetchAddressFromLocation(loc);
        }
    });
    /*
     * Request location permission, so that we can get the location of the
     * device. The result of the permission request is handled by a callback,
     * onRequestPermissionsResult.
     */
    if (ContextCompat.checkSelfPermission(this.getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        setUpMap();
    } else
        ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSION_REQUEST_ACCESS_FINE_LOCATION_SHOW_ICON_IN_MAP);
}
Also used : GoogleMap(com.google.android.gms.maps.GoogleMap) LatLng(com.google.android.gms.maps.model.LatLng) Location(android.location.Location)

Aggregations

GoogleMap (com.google.android.gms.maps.GoogleMap)8 LatLng (com.google.android.gms.maps.model.LatLng)6 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)5 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 Bitmap (android.graphics.Bitmap)1 Location (android.location.Location)1 View (android.view.View)1 MapFragment (com.google.android.gms.maps.MapFragment)1 MapView (com.google.android.gms.maps.MapView)1 SupportMapFragment (com.google.android.gms.maps.SupportMapFragment)1 Marker (com.google.android.gms.maps.model.Marker)1 Polygon (com.google.android.gms.maps.model.Polygon)1 PolygonOptions (com.google.android.gms.maps.model.PolygonOptions)1 Polyline (com.google.android.gms.maps.model.Polyline)1 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SettableFuture (org.thoughtcrime.securesms.util.concurrent.SettableFuture)1