Java Code Examples for com.google.android.gms.maps.MapView#getMapAsync()
The following examples show how to use
com.google.android.gms.maps.MapView#getMapAsync() .
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: RawMapViewDemoActivity.java From android-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.raw_mapview_demo); // *** IMPORTANT *** // MapView requires that the Bundle you pass contain _ONLY_ MapView SDK // objects or sub-Bundles. Bundle mapViewBundle = null; if (savedInstanceState != null) { mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY); } mMapView = (MapView) findViewById(R.id.map); mMapView.onCreate(mapViewBundle); mMapView.getMapAsync(this); }
Example 2
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 3
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Enables or disables the compass. * * @param map * @param compassButton */ @ReactProp(name = "compassButton") public void setCompassButton(MapView map, boolean compassButton) { this.compassButton = compassButton; map.getMapAsync(this); }
Example 4
Source File: MapLocationViewHolder.java From android-map_list with MIT License | 5 votes |
public MapLocationViewHolder(Context context, View view) { super(view); mContext = context; title = (TextView) view.findViewById(R.id.title); description = (TextView) view.findViewById(R.id.description); mapView = (MapView) view.findViewById(R.id.map); mapView.onCreate(null); mapView.getMapAsync(this); }
Example 5
Source File: LocalPlacesAdapter.java From ratebeer with GNU General Public License v3.0 | 5 votes |
public MapHeaderHolder(View v) { super(v); mapView = (MapView) v; // Call through onCreate and onResume because we had these already but the MapView did not yet exist then mapView.onCreate(null); mapView.onResume(); mapView.getMapAsync(googleMap -> googleMap.getUiSettings().setMapToolbarEnabled(false)); }
Example 6
Source File: AtlasFragment.java From memoir with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_atlas, container, false); MapsInitializer.initialize(getActivity()); mMapView = (MapView) v.findViewById(R.id.map_view); mMapView.onCreate(mBundle); mMapView.getMapAsync(this); return v; }
Example 7
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Enables or disables the My Location button. * * @param map * @param myLocationButton */ @ReactProp(name = "myLocationButton") public void setMyLocationButton(MapView map, boolean myLocationButton) { this.myLocationButton = myLocationButton; map.getMapAsync(this); }
Example 8
Source File: GalleryAdapter.java From animation-samples with Apache License 2.0 | 5 votes |
private void initializeMapView(MapView mapView) { mapView.onCreate(null); mapView.getMapAsync(mInitialOnMapReadyCallback); // lite mode enabled within map's layout declaration // Requirement to set clickable to false in order to not open the Google Maps application. // See: https://developers.google.com/maps/documentation/android-api/events#disabling_click_events_in_lite_mode mapView.setClickable(false); }
Example 9
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Controls whether rotate gestures are enabled (default) or disabled. * * @param map * @param rotateGestures */ @ReactProp(name = "rotateGestures") public void setRotateGestures(MapView map, boolean rotateGestures) { this.rotateGestures = rotateGestures; map.getMapAsync(this); }
Example 10
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Controls whether tilt gestures are enabled (default) or disabled. * * @param map * @param tiltGestures */ @ReactProp(name = "tiltGestures") public void setTiltGestures(MapView map, boolean tiltGestures) { this.tiltGestures = tiltGestures; map.getMapAsync(this); }
Example 11
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Controls whether zoom gestures are enabled (default) or disabled. * * @param map * @param zoomGestures */ @ReactProp(name = "zoomGestures") public void setZoomGestures(MapView map, boolean zoomGestures) { this.zoomGestures = zoomGestures; map.getMapAsync(this); }
Example 12
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Controls whether scroll gestures are enabled (default) or disabled. * * @param map * @param scrollGestures */ @ReactProp(name = "scrollGestures") public void setScrollGestures(MapView map, boolean scrollGestures) { this.scrollGestures = scrollGestures; map.getMapAsync(this); }
Example 13
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Sets the user's location marker, if it has been enabled. * * @param showsUserLocation */ @ReactProp(name = "showsUserLocation") public void setShowsUserLocation(MapView map, boolean showsUserLocation) { this.showsUserLocation = showsUserLocation; map.getMapAsync(this); }
Example 14
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Adds marker icons to the map. * * @param map * @param markers */ @ReactProp(name = "markers") public void setMarkers(MapView map, ReadableArray markers) { this.markers = markers; map.getMapAsync(this); }
Example 15
Source File: PPTGoogleMapManager.java From react-native-maps with MIT License | 5 votes |
/** * Sets the user's location marker, if it has been enabled. * * @param map * @param cameraPosition */ @ReactProp(name = "cameraPosition") public void setCameraPosition(MapView map, ReadableMap cameraPosition) { float zoom = (float) cameraPosition.getDouble("zoom"); if (cameraPosition.hasKey("auto") && cameraPosition.getBoolean("auto")) { Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location == null) { return; } cameraUpdate = CameraUpdateFactory.newLatLngZoom( new LatLng(location.getLatitude(), location.getLongitude()), zoom ); map.getMapAsync(this); } else { cameraUpdate = CameraUpdateFactory.newLatLngZoom( new LatLng( cameraPosition.getDouble("latitude"), cameraPosition.getDouble("longitude") ), zoom ); map.getMapAsync(this); } }
Example 16
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 17
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; }