com.google.android.gms.maps.OnMapReadyCallback Java Examples
The following examples show how to use
com.google.android.gms.maps.OnMapReadyCallback.
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: MainActivity.java From TutosAndroidFrance with MIT License | 7 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { googleMap.addMarker(new MarkerOptions().title("Paris").position(PARIS)); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(PARIS, 15)); googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); } }); }
Example #2
Source File: ViewCameraActivity.java From evercam-android with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); evercamCamera = VideoActivity.evercamCamera; setContentView(R.layout.activity_view_camera); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync((OnMapReadyCallback) this); setUpDefaultToolbar(); // Initial UI elements initialScreen(); fillCameraDetails(evercamCamera); vendorLogoImageView = (ImageView) findViewById(R.id.vendor_logo_image_view); modelThumbnailImageView = (ImageView) findViewById(R.id.model_thumbnail_image_view); new RequestVendorListTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
Example #3
Source File: AttractionsGridPagerAdapter.java From io2015-codelabs with Apache License 2.0 | 6 votes |
private OnMapReadyCallback getMapReadyCallback(final Attraction attraction) { return new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { Intent intent = new Intent(mActivity, MapActivity.class); intent.putExtra(Constants.EXTRA_ATTRACTION, attraction); mActivity.startActivity(intent); } }); updateMapLocation(attraction); } }; }
Example #4
Source File: MapFragment.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_map, null); getActivity().setTitle("Map"); if (mapFragment == null) { mapFragment = SupportMapFragment.newInstance(); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { LatLng latLng = new LatLng(latitude, longitude); googleMap.addMarker(new MarkerOptions().position(latLng) .title("Singapore")); googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); googleMap.setMinZoomPreference(15.0f); googleMap.setMaxZoomPreference(20.0f); } }); } getChildFragmentManager().beginTransaction().replace(R.id.map, mapFragment).commit(); return view; }
Example #5
Source File: BusinessDetailsActivity.java From YelpQL with MIT License | 6 votes |
private void showPointerOnMap(final double latitude, final double longitude) { mvRestaurantLocation.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { LatLng latLng = new LatLng(latitude, longitude); googleMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_flag)) .anchor(0.0f, 1.0f) .position(latLng)); googleMap.getUiSettings().setMyLocationButtonEnabled(false); googleMap.getUiSettings().setZoomControlsEnabled(true); // Updates the location and zoom of the MapView CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15); googleMap.moveCamera(cameraUpdate); } }); }
Example #6
Source File: NativeGoogleMapFragment.java From AirMapView with Apache License 2.0 | 6 votes |
public void init() { getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { if (googleMap != null && getActivity() != null) { NativeGoogleMapFragment.this.googleMap = googleMap; UiSettings settings = NativeGoogleMapFragment.this.googleMap.getUiSettings(); settings.setZoomControlsEnabled(false); settings.setMyLocationButtonEnabled(false); setMyLocationEnabled(myLocationEnabled); if (onMapLoadedListener != null) { onMapLoadedListener.onMapLoaded(); } } } }); }
Example #7
Source File: AlertView.java From redalert-android with Apache License 2.0 | 6 votes |
void initializeUI() { // Reset activity name (after localization is loaded) setTitle(R.string.appName); // Allow click on home button getSupportActionBar().setDisplayHomeAsUpEnabled(true); // RTL action bar hack RTLSupport.mirrorActionBar(this); // Set up UI setContentView(R.layout.alert_view); // Get map instance ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Initialize map initializeMap(); } }); }
Example #8
Source File: MainActivity.java From live-app-android with MIT License | 6 votes |
public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) { if (mMap == null) { SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; UiSettings uiSettings = googleMap.getUiSettings(); uiSettings.setMapToolbarEnabled(false); onMapReadyCallback.onMapReady(googleMap); } }); } else { onMapReadyCallback.onMapReady(mMap); } }
Example #9
Source File: MapFragment.java From actor-platform with GNU Affero General Public License v3.0 | 6 votes |
@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; }
Example #10
Source File: PlaceMapFragment.java From RxGpsService with Apache License 2.0 | 6 votes |
private void initViews() { getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap gMap) { googleMap = gMap; googleMap.getUiSettings().setAllGesturesEnabled(true); googleMap.clear(); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(DEFAULT_LATLNG, DEFAULT_ZOOM)); setCustomInfoWindow(); PlaceMapFragment.this.setMapListeners(); if (place != null) PlaceMapFragment.this.showPlace(place, false, 0, listener); if (places != null && !places.isEmpty()) PlaceMapFragment.this.showPlaces(places, false, places.get(0).getId(), listener); } }); }
Example #11
Source File: DetailFragment.java From animation-samples with Apache License 2.0 | 5 votes |
private void applyMapPadding() { if (mMapView == null) { return; } mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { View descriptionLayout = getView().findViewById(R.id.description_layout); googleMap.setPadding(0, 0, 0, descriptionLayout.getMeasuredHeight()); } }); }
Example #12
Source File: EditCameraLocationActivity.java From evercam-android with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_camera_location); cameraToUpdate = ViewCameraActivity.evercamCamera; setUpDefaultToolbar(); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync((OnMapReadyCallback) this); }
Example #13
Source File: MapViewHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 5 votes |
@Override public void onMapReady(GoogleMap googleMap) { this.googleMap = googleMap; // trigger listeners for (OnMapReadyCallback onMapReadyListener : onMapReadyListeners) { onMapReadyListener.onMapReady(this.googleMap); } }
Example #14
Source File: MainAct.java From android-rxgeofence with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { setup(googleMap); } }); }
Example #15
Source File: MainActivity.java From ThemedGoogleMap with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ((SupportMapFragment) getSupportFragmentManager().findFragmentById( R.id.vM_apnrm_map)).getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { GoogleMapStyler googleMapStyler = new GoogleMapStyler.Builder(MainActivity.this) .setMainGeometryColorRes(R.color.maingeometrycolor) .setAllPlaceTextStrokeAlpha(-80) .setAllPlaceTextColorRes(R.color.adminstartivelabel) .setAllMainTownTextColorRes(R.color.administativelocality) .setAllPoiTextColorRes(R.color.poitext) .setAllPoiParkBackgroundColorRes(R.color.poiparkbackground) .setAllPoiParkTextColorRes(R.color.poilabel) .setAllRoadBackgroundColorRes(R.color.roadbackground) .setAllRoadTextColorRes(R.color.roadlabel) .setAllRoadArterialBackgroundColorRes(R.color.roadarterialbackground) .setAllRoadArterialStrokeColorRes(R.color.roadarterialstroke) .setAllRoadHighwayBackgroundColorRes(R.color.roadhighway) .setAllRoadHighwayStrokeColorRes(R.color.roadhighwaystroke) .setAllRoadHighwayTextColorRes(R.color.roadhighwaylabel) .setAllRoadLocalBackgroundColorRes(R.color.roadlocal) .setAllRoadLocalStrokeColorRes(R.color.roadlocalstroke) .setAllTransitStationTextColorRes(R.color.transitstationtext) .setAllTransitBackgroundColorRes(R.color.transit) .setAllWaterTextColorRes(R.color.waterlabel) .setAllWaterBackgroundColorRes(R.color.water) .setAllWaterTextStrokeAlpha(-20) .build(); boolean success = googleMap.setMapStyle(googleMapStyler.getMapStyleOptions()); googleMap.setBuildingsEnabled(true); } }); }
Example #16
Source File: ShareTripFragment.java From live-app-android with MIT License | 5 votes |
@Override public void onResume() { super.onResume(); ((MainActivity) getActivity()).getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { presenter.subscribeTripUpdates(googleMap, tripId); } }); }
Example #17
Source File: LocatrFragment.java From AndroidProgramming3e with Apache License 2.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); mClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API) .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(@Nullable Bundle bundle) { getActivity().invalidateOptionsMenu(); } @Override public void onConnectionSuspended(int i) { } }) .build(); getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; updateUI(); } }); }
Example #18
Source File: GalleryFragment.java From animation-samples with Apache License 2.0 | 5 votes |
private void showDetailFragment(@NonNull final GalleryViewHolder holder, @NonNull final Gallery gallery) { // Turn of transition grouping for clicked item view to break card structure. ((ViewGroup) holder.itemView).setTransitionGroup(false); holder.mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { CameraPosition cameraPosition = googleMap.getCameraPosition(); performDetailTransition(holder, gallery, cameraPosition); } }); }
Example #19
Source File: DetailFragment.java From animation-samples with Apache License 2.0 | 5 votes |
private void initMapAsync() { mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { initializeMap(googleMap); } }); }
Example #20
Source File: SignalMapView.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
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; }
Example #21
Source File: PublishFragment.java From kute with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.publishfragment, container, false); mMapView = (MapView) rootView.findViewById(R.id.mapViewpublish); mMapView.onCreate(savedInstanceState); mMapView.onResume(); // needed to get the map to display immediately try { MapsInitializer.initialize(getActivity().getApplicationContext()); } catch (Exception e) { e.printStackTrace(); } mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap mMap) { googleMap = mMap; // For showing a move to my location button if (ActivityCompat.checkSelfPermission(getActivity().getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } googleMap.setMyLocationEnabled(true); // For dropping a marker at a point on the Map LatLng sydney = new LatLng(-34, 151); googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title Publish").snippet("Marker Description")); // For zooming automatically to the location of the marker CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } }); return rootView; }
Example #22
Source File: TrackFragment.java From kute with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.trackfragment, container, false); mMapView = (MapView) rootView.findViewById(R.id.mapView); mMapView.onCreate(savedInstanceState); mMapView.onResume(); // needed to get the map to display immediately try { MapsInitializer.initialize(getActivity().getApplicationContext()); } catch (Exception e) { e.printStackTrace(); } mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap mMap) { googleMap = mMap; // For showing a move to my location button if (ActivityCompat.checkSelfPermission(getActivity().getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } googleMap.setMyLocationEnabled(true); // For dropping a marker at a point on the Map LatLng sydney = new LatLng(-34, 151); googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title track").snippet("Marker Description")); // For zooming automatically to the location of the marker CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } }); return rootView; }
Example #23
Source File: MainActivity.java From journaldev with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); googleMap.addMarker(new MarkerOptions() .position(new LatLng(37.4233438, -122.0728817)) .title("LinkedIn") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))); googleMap.addMarker(new MarkerOptions() .position(new LatLng(37.4629101,-122.2449094)) .title("Facebook") .snippet("Facebook HQ: Menlo Park")); googleMap.addMarker(new MarkerOptions() .position(new LatLng(37.3092293, -122.1136845)) .title("Apple")); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.4233438, -122.0728817), 10)); } }); } }); }
Example #24
Source File: MapViewHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 2 votes |
/** * Add an OnMapReadyCallbackListener to get notified when the GoogleMap has initialized * * @param onMapReadyCallbackListener Listener */ public void addOnMapReadyListener(OnMapReadyCallback onMapReadyCallbackListener) { onMapReadyListeners.add(onMapReadyCallbackListener); }