@Override public void onStart() { super.onStart(); if (geoLocation != null) geoLocation.start(getContext()); this.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { gMap = googleMap; initializeMap(); } }); }
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); } }); }
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); } }); }
private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (mMap == null) { // Try to obtain the map from the SupportMapFragment. ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; } }); // Check if we were successful in obtaining the map. // if (mMap != null) { // setUpMap(); // } } }
@Override public void addFlightPathPoint(final LatLongAlt coord) { final LatLng position = MapUtils.coordToLatLng(coord); getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { if (showFlightPath) { if (flightPath == null) { PolylineOptions flightPathOptions = new PolylineOptions(); flightPathOptions.color(FLIGHT_PATH_DEFAULT_COLOR) .width(FLIGHT_PATH_DEFAULT_WIDTH).zIndex(1); flightPath = googleMap.addPolyline(flightPathOptions); } List<LatLng> oldFlightPath = flightPath.getPoints(); oldFlightPath.add(position); flightPath.setPoints(oldFlightPath); } } }); }
@Override public void updateDroneLeashPath(PathSource pathSource) { List<LatLong> pathCoords = pathSource.getPathPoints(); final List<LatLng> pathPoints = new ArrayList<LatLng>(pathCoords.size()); for (LatLong coord : pathCoords) { pathPoints.add(MapUtils.coordToLatLng(coord)); } if (mDroneLeashPath == null) { final PolylineOptions flightPath = new PolylineOptions(); flightPath.color(DRONE_LEASH_DEFAULT_COLOR).width( MapUtils.scaleDpToPixels(DRONE_LEASH_DEFAULT_WIDTH, getResources())); getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mDroneLeashPath = getMap().addPolyline(flightPath); mDroneLeashPath.setPoints(pathPoints); } }); } else { mDroneLeashPath.setPoints(pathPoints); } }
@Override public void updateMissionPath(PathSource pathSource) { List<LatLong> pathCoords = pathSource.getPathPoints(); final List<LatLng> pathPoints = new ArrayList<>(pathCoords.size()); for (LatLong coord : pathCoords) { pathPoints.add(MapUtils.coordToLatLng(coord)); } if (missionPath == null) { final PolylineOptions pathOptions = new PolylineOptions(); pathOptions.color(MISSION_PATH_DEFAULT_COLOR).width(MISSION_PATH_DEFAULT_WIDTH); getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { missionPath = getMap().addPolyline(pathOptions); missionPath.setPoints(pathPoints); } }); } else { missionPath.setPoints(pathPoints); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.location_fragment, 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; refreshMap(null); } }); return rootView; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment FrameLayout v = (FrameLayout) inflater.inflate(R.layout.fragment_map, container, false); mapView = (MapView) v.findViewById(R.id.map); mapView.onCreate(savedInstanceState); mapView.onResume(); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { Log.i("DevMsg", "Success!!!!!"); myMap = googleMap; populateMap(); } }); return v; }
@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); } }); }
private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (mMap == null) { // Try to obtain the map from the SupportMapFragment. ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)) .getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Check if we were successful in obtaining the map. if (mMap != null) { setUpMap(); } } }); } }
@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; }
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(); } } } }); }
@Override public void loadCameraPosition() { getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { final SharedPreferences settings = mAppPrefs.prefs; final CameraPosition.Builder camera = new CameraPosition.Builder(); camera.bearing(settings.getFloat(PREF_BEA, DEFAULT_BEARING)); camera.tilt(settings.getFloat(PREF_TILT, DEFAULT_TILT)); camera.zoom(settings.getFloat(PREF_ZOOM, DEFAULT_ZOOM_LEVEL)); camera.target(new LatLng(settings.getFloat(PREF_LAT, DEFAULT_LATITUDE), settings.getFloat(PREF_LNG, DEFAULT_LONGITUDE))); googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(camera.build())); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_view); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } mLatlng = getIntent().getStringExtra("latlng"); if (mapMessageLocation == null) { mapMessageLocation = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapMessageLocation)); } mapMessageLocation.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap map) { loadMap(map, mLatlng); } }); }
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); } }; }
/** * Contains the basics for setting up the map. */ private void setUpMap() { if (Utils.checkNetwork(getActivity())) { if (mMap == null) { mMapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { Log.i(TAG, "onMapReady"); mMap = googleMap; postSyncMapSetup(); } }); } } else { Utils.connectToast(getActivity()); } }
@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); }
private void setUpMapIfNeeded() { if (mMap == null) { ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) .getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; setUpMap(); } }); } }
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; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_map, 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 dropping a marker at a point on the Map LatLng sydney = new LatLng(-34, 151); googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title").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; }
/** * Last step, we initialize the map * @param fctx * @param loc */ public static void initMap(final Activity fctx, final Location loc) { MapFragment mapFragment = (MapFragment) fctx.getFragmentManager().findFragmentById(R.id .map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { gmap = googleMap; myOnMapReady(fctx, googleMap, loc); } }); }
public static void initMap2(final Activity ctx, final Location location, final int permissionCode) { code = permissionCode; MapFragment mapFragment = (MapFragment) ctx.getFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { myOnMapReady2(ctx, googleMap, location, permissionCode); } }); }
@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(); } }); }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); mClient = new GoogleApiClient.Builder(getContext()).addApi(LocationServices.API) .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(@Nullable Bundle bundle) { getActivity().invalidateOptionsMenu(); findImage(); } @Override public void onConnectionSuspended(int i) { } }) .build(); getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; updateUI(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.place_details); mContext = this; mResources = getResources(); mMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.place_map); mMapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap map) { mMap = map; updateUI(); } }); mPlaceId = getIntent().getIntExtra(EXTRA_PLACE_POSITION, -1); final VisitableGenerator generator = VisitableGenerator.get(this); mPlace = generator.getPlace(mPlaceId); mLocation = new Location(""); mLocation.set(mPlace.getLocation()); mPlaceImageViewFull = (ImageView) findViewById(R.id.place_image_full); mPlaceCaption = (TextView) findViewById(R.id.place_caption_full); mWebView = (WebView) findViewById(R.id.web_view); mBackupEmptyView = (TextView) findViewById(R.id.place_backup_empty_view); mIndicator = (ProgressBar) findViewById(R.id.indicator); mVisitedCheckBox = (CheckBox) findViewById(R.id.visited_check_box); mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); mProgressBar.setMax(100); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView webView, int newProgress) { if (newProgress == 100) { mProgressBar.setVisibility(View.GONE); } else { mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setProgress(newProgress); } } }); mWebView.setWebViewClient(new WebViewClient()); mWebView.loadUrl(mPlace.getWikiUrl()); Bitmap bitmap = PictureUtils.decodeBitmapFromResource(getResources(), mPlace.getImgResourceId(), 400, 400); mPlaceImageViewFull.setImageBitmap(bitmap); mPlaceCaption.setText(mPlace.getPlaceNameResId()); this.getSupportActionBar().setTitle(mPlace.getPlaceNameResId()); mVisitedCheckBox.setChecked(mPlace.isVisited()); mVisitedCheckBox.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { mPlace.setVisited(isChecked); } }); mConnManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = mConnManager.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnected(); if (!isConnected) { mIndicator.setVisibility(View.INVISIBLE); mBackupEmptyView.setText(R.string.empty_placeholder); } }
private void fillMap(){ final MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { map = googleMap; map.setMyLocationEnabled(false); map.getUiSettings().setTiltGesturesEnabled(false); map.getUiSettings().setMyLocationButtonEnabled(false); map.getUiSettings().setMapToolbarEnabled(false); map.clear(); boolean first = true; PolylineOptions line = new PolylineOptions(); map.addPolyline(line); for (ChronicleEvent event : bartour.getChronicle().getChronicleEvents(LocationChronicleEvent.class)) { LocationChronicleEvent locationEvent = (LocationChronicleEvent) event; if (first) { first = false; map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locationEvent.getLatitude(), locationEvent.getLongitude()), 15)); } MarkerOptions marker = new MarkerOptions(); LatLng latLng = new LatLng(locationEvent.getLatitude(), locationEvent.getLongitude()); marker.title(locationEvent.getLocationName().toString()) .position(latLng); if (locationEvent instanceof ATMLocationChronicleEvent) { marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_money_pin)); } else { marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action_beer_pin)); } map.addMarker(marker); line.add(latLng); } map.addPolyline(line); } }); }
/** * The method initializes Google map. * * @param bundle @see {@link GoogleMap} * @return instance {@link GoogleMap} * @see {@link GoogleMap} */ public void initializeGoogleMap(final Bundle bundle) { mapView = (MapView) getView().findViewById(R.id.fr_road_issue_mapview); mapView.onCreate(bundle); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { map = googleMap; initMap(googleMap); } }); }
@MainThread /* default */ static Observable<LocatedBitmap> create(@NonNull final MapView mapView) { final int[] locationOnScreen = new int[] {0, 0}; mapView.getLocationOnScreen(locationOnScreen); return Observable.create(new Observable.OnSubscribe<LocatedBitmap>() { @Override public void call(final Subscriber<? super LocatedBitmap> subscriber) { mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull final GoogleMap googleMap) { googleMap.snapshot(new GoogleMap.SnapshotReadyCallback() { @Override public void onSnapshotReady(@Nullable final Bitmap bitmap) { if (bitmap != null) { subscriber.onNext( new LocatedBitmap(bitmap, locationOnScreen)); subscriber.onCompleted(); } else { subscriber.onError(new MapSnapshotFailedException()); } } }); } }); } }); }
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()); } }); }
private void initMapAsync() { mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { initializeMap(googleMap); } }); }
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); } }); }
@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); } }); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); // find the Toolbar, set it as ActionBar and handle Up button Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // find the other items ImageView imageView = (ImageView) findViewById(R.id.image); TextView description = (TextView) findViewById(R.id.description); // open the parcel with the name "pasar" final PasarMalam pasarMalam = getIntent().getParcelableExtra("pasar"); getSupportActionBar().setTitle(pasarMalam.name); // set the screen title Glide.with(this).load(pasarMalam.imageUrl).into(imageView); description.setText(pasarMalam.desc); // find the Map, similar to GoogleMapsFragment SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { // create LatLng based on the Pasar Malam coordinate, and add the pin LatLng latLng = new LatLng(pasarMalam.latitude, pasarMalam.longitude); googleMap.addMarker(new MarkerOptions().position(latLng)); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15)); } }); }
@Override public void onClick(final View v){ if (mapButton != null && satelliteButton != null) { if (mapView != null) { mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final GoogleMap googleMap) { if (v.equals(mapButton)) { if (googleMap.getMapType() != GoogleMap.MAP_TYPE_NORMAL) googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); mapButton.setSelected(true); satelliteButton.setSelected(false); } else if (v.equals(satelliteButton) ) { if (googleMap.getMapType() != GoogleMap.MAP_TYPE_SATELLITE) googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); mapButton.setSelected(false); satelliteButton.setSelected(true); } } }); } } NGEAnalyticData.reportEvent(getActivity(), this, NGEAnalyticData.AnalyticAction.ACTION_SET_MAP_TYPE, v.equals(mapButton) ? "road" : "satellite", null); }
@Override public void onClick(final View v){ if (mapButton != null && satelliteButton != null) { if (mapView != null) { //final LatLng location = new LatLng(selectedLocationItem.latitude, selectedLocationItem.longitude); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final GoogleMap googleMap) { if (v.equals(mapButton)) { if (googleMap.getMapType() != GoogleMap.MAP_TYPE_NORMAL) googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); mapButton.setSelected(true); satelliteButton.setSelected(false); } else if (v.equals(satelliteButton) ) { if (googleMap.getMapType() != GoogleMap.MAP_TYPE_SATELLITE) googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); mapButton.setSelected(false); satelliteButton.setSelected(true); } } }); } } NGEAnalyticData.reportEvent(getActivity(), this, NGEAnalyticData.AnalyticAction.ACTION_SET_MAP_TYPE, v.equals(mapButton) ? "road" : "satellite", null); }
@Override public void call(final Subscriber<? super GoogleMap> subscriber) { MainThreadSubscription.verifyMainThread(); OnMapReadyCallback callback = new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(googleMap); } } }; mapFragment.getMapAsync(callback); }
@Override public void call(final Subscriber<? super GoogleMap> subscriber) { MainThreadSubscription.verifyMainThread(); OnMapReadyCallback callback = new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(googleMap); } } }; fragment.getMapAsync(callback); }