Java Code Examples for com.google.android.gms.maps.GoogleMap#setOnMapLoadedCallback()

The following examples show how to use com.google.android.gms.maps.GoogleMap#setOnMapLoadedCallback() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDetailActivity.java    From google-io-2014-compat with Apache License 2.0 6 votes vote down vote up
private void setupMap() {
    final GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    double lat = getIntent().getDoubleExtra("lat", 37.6329946);
    double lng = getIntent().getDoubleExtra("lng", -122.4938344);
    float zoom = getIntent().getFloatExtra("zoom", 15);

    LatLng position = new LatLng(lat, lng);
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(position, zoom));
    map.addMarker(new MarkerOptions().position(position));

    // We need the snapshot of the map to prepare the shader for the circular reveal.
    // So the map is visible on activity start and then once the snapshot is taken, quickly hidden.
    map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            map.snapshot(new GoogleMap.SnapshotReadyCallback() {
                @Override
                public void onSnapshotReady(Bitmap bitmap) {
                    mapLoaded(bitmap);
                }
            });
        }
    });
}
 
Example 2
Source File: MapsActivity.java    From google-maps-clustering with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(final GoogleMap googleMap) {
    googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(NETHERLANDS, 0));
        }
    });

    ClusterManager<SampleClusterItem> clusterManager = new ClusterManager<>(this, googleMap);
    clusterManager.setCallbacks(new ClusterManager.Callbacks<SampleClusterItem>() {
        @Override
        public boolean onClusterClick(@NonNull Cluster<SampleClusterItem> cluster) {
            Log.d(TAG, "onClusterClick");
            return false;
        }

        @Override
        public boolean onClusterItemClick(@NonNull SampleClusterItem clusterItem) {
            Log.d(TAG, "onClusterItemClick");
            return false;
        }
    });
    googleMap.setOnCameraIdleListener(clusterManager);

    List<SampleClusterItem> clusterItems = new ArrayList<>();
    for (int i = 0; i < 20000; i++) {
        clusterItems.add(new SampleClusterItem(
                RandomLocationGenerator.generate(NETHERLANDS)));
    }
    clusterManager.setItems(clusterItems);
}
 
Example 3
Source File: DetailFragment.java    From animation-samples with Apache License 2.0 4 votes vote down vote up
private void initializeMap(final GoogleMap googleMap) {
    googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(mCameraPosition));
    googleMap.setOnMapLoadedCallback(getOnMapLoadedCallback(googleMap));
    setMarkers(googleMap);
}