Search in sources :

Example 1 with OnMapReadyCallback

use of com.google.android.gms.maps.OnMapReadyCallback in project NPSmiles by bmcglynn1.

the class ItemOneFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.activity_contact_page, container, false);
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
    OnMapReadyCallback obj = new OnMapReadyCallback() {

        @Override
        public void onMapReady(GoogleMap googleMap) {
            mMap = googleMap;
            LatLng smiles = new LatLng(39.104729, -77.191294);
            mMap.addMarker(new MarkerOptions().position(smiles).title("North Potomac Smiles, LLC."));
            mMap.moveCamera(CameraUpdateFactory.newLatLng(smiles));
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(smiles, 16));
        }
    };
    mapFragment.getMapAsync(obj);
    return view;
}
Also used : SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) LatLng(com.google.android.gms.maps.model.LatLng) View(android.view.View)

Example 2 with OnMapReadyCallback

use of com.google.android.gms.maps.OnMapReadyCallback 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 3 with OnMapReadyCallback

use of com.google.android.gms.maps.OnMapReadyCallback 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)

Aggregations

GoogleMap (com.google.android.gms.maps.GoogleMap)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)3 LatLng (com.google.android.gms.maps.model.LatLng)2 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 MapView (com.google.android.gms.maps.MapView)1 SupportMapFragment (com.google.android.gms.maps.SupportMapFragment)1 SettableFuture (org.thoughtcrime.securesms.util.concurrent.SettableFuture)1