Java 类com.google.android.gms.maps.CameraUpdate 实例源码
项目:YelpQL
文件:BusinessDetailsActivity.java
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);
}
});
}
项目:GoogleMapsLayout-Android
文件:MapLayout.java
/**
* Updates camera
* @param shouldAnimate flag indicating if the camera should be animated or moved immediately
* @param zoom zoom level
*/
private void updateCamera(boolean shouldAnimate, float zoom){
if(MapLayout.location ==null)
return;
CameraPosition.Builder cameraPositionBuilder = new CameraPosition.Builder().target(MapLayout.location);
cameraPositionBuilder.zoom(zoom);
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPositionBuilder.build());
if(shouldAnimate)
mGoogleMap.animateCamera(cameraUpdate);
else
mGoogleMap.moveCamera(cameraUpdate);
}
项目:Dispatch
文件:MainActivity.java
public void PlacePinAndPositionCamera(LatLng addressPosition) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(addressPosition);
mMap.addMarker(markerOptions
.title("Crisis Location").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(addressPosition, 12));
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(addressPosition);
LatLngBounds bounds = builder.build();
int padding = 150; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
}
项目:referendum_1o_android
文件:VoteFragment.java
public void showColegiElectoralData(final ColegiElectoral colegiElectoral) {
LatLng latLng = new LatLng(colegiElectoral.getLat(), colegiElectoral.getLon());
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16);
mGoogleMap.animateCamera(cameraUpdate);
txtNomLocal.setText(colegiElectoral.getLocal());
txtAdresa.setText(colegiElectoral.getAdresa());
txtLocalitat.setText(colegiElectoral.getMunicipi());
txtDistricte.setText(colegiElectoral.getDistricte() != null ? StringsManager.getString("data_districte", colegiElectoral.getDistricte()) : "");
txtSeccio.setText(colegiElectoral.getSeccio() != null ? StringsManager.getString("data_seccio", colegiElectoral.getSeccio()) : "");
txtMesa.setText(colegiElectoral.getMesa() != null ? StringsManager.getString("data_mesa", colegiElectoral.getMesa()) : "");
icnCalendari.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addEventToCalendar(colegiElectoral);
}
});
bsb.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:Habitizer
文件:MapController.java
/**
* For actually moving the map to the desired location.
* @param fctx
* @param loc
*/
public static void gotoLocation(Activity fctx, Location loc) {
Location locc = loc;
sloc = loc;
if(loc == null){
locc = getCurrentLocation(fctx);
}
if(code == AddHabitEventActivity.EVENT_PERMISSION_CHECK){
}
float zoom = 15.0f;
if(locc == null){
DummyMainActivity.toastMe("Could not get location", fctx);
}else{
double[] d = {locc.getLatitude(), locc.getLongitude()};
AddHabitEventActivity.setLocation(d);
LatLng ll = new LatLng(locc.getLatitude(), locc.getLongitude());
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, zoom);
gmap.moveCamera(update);
}
}
项目:Android-Programming-BigNerd
文件:LocatrFragment.java
private void updateUI() {
if (mMap == null || mMapImage == null) {
return;
}
Log.d(TAG, "updateUI: ");
LatLng itemPoint = new LatLng(mMapItem.getLat(), mMapItem.getLon());
LatLng myPoint = new LatLng(mCurrentLocation.getLatitude(),
mCurrentLocation.getLongitude());
BitmapDescriptor itemBitmap = BitmapDescriptorFactory.fromBitmap(mMapImage);
MarkerOptions itemMarker = new MarkerOptions()
.position(itemPoint)
.icon(itemBitmap);
MarkerOptions myMarker = new MarkerOptions()
.position(myPoint);
mMap.clear();
mMap.addMarker(itemMarker);
mMap.addMarker(myMarker);
LatLngBounds bounds = new LatLngBounds.Builder()
.include(itemPoint)
.include(myPoint)
.build();
int margin = getResources().getDimensionPixelSize(R.dimen.map_inset_margin);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
mMap.animateCamera(update);
}
项目:mobile-app-dev-book
文件:TripMapFragment.java
private void refreshMarkers() {
// if (allMarkers.size() == allTrips.size()) return;
LatLngBounds.Builder boundBuilder = new LatLngBounds.Builder();
allMarkers.clear();
gMap.clear();
for (Trip t : allTrips) {
DateTime begDate = DateTime.parse(t.getStartDate());
DateTime endDate = DateTime.parse(t.getEndDate());
LatLng thisLoc = new LatLng(t.getLat(), t.getLng());
Marker m = gMap.addMarker(
new MarkerOptions().position(thisLoc).title(t.getName())
.snippet(formatDate(begDate, endDate)));
m.setTag(t);
allMarkers.add(m);
boundBuilder.include(thisLoc);
}
if (allMarkers.size() > 0) {
int screenWidth = getResources().getDisplayMetrics().widthPixels;
int screenHeight = getResources().getDisplayMetrics().heightPixels;
LatLngBounds bound = boundBuilder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bound,
screenWidth, screenHeight, 56);
gMap.animateCamera(cameraUpdate);
}
}
项目:RoadLab-Pro
文件:MeasurementsGoogleMapHelper.java
public void fitMap(GoogleMap map, List<LatLng> locations, boolean animate, int padding) {
if (map == null) {
return;
}
LatLngBounds bounds = getLatLngBounds(locations);
if (bounds == null ) {
return;
}
CameraUpdate cUpdate = null;
try {
cUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
if (animate) {
map.animateCamera(cUpdate);
} else {
map.moveCamera(cUpdate);
}
} catch (Exception e) {
Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
}
}
项目:WalkGraph
文件:MapFragmentImpl.java
/**
* Zooms in on map based most recent or previous day's graph.
*
* Uses the first day's location as the first point and
* the last location of graph as the last point for area to zoom
* in on around the map.
*
* Calls drawGraph(graph) to show graph points.
*/
@Override
public void updateMapArea() {
Graph graph = mapPresenter.getRecentGraph();
if (googleMap == null){
Log.d(TAG, "Google map is null");
return;
}
Location first = graph.getLocations().get(0);
Location last = graph.getLocations().get(graph.getLocations().size() - 1);
LatLng firstPoint = new LatLng(first.getLatitude(), first.getLongitude());
LatLng lastPoint = new LatLng(last.getLatitude(), last.getLongitude());
LatLngBounds bounds = new LatLngBounds.Builder()
.include(firstPoint)
.include(lastPoint)
.build();
int margin = getResources().getDimensionPixelSize(R.dimen.map_inset);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
googleMap.animateCamera(update);
drawGraph(graph);
}
项目:instantsearch-android-examples
文件:MapWidget.java
private void updateMapPOIs() {
googleMap.clear();
if (hits.isEmpty()) {
return;
}
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (final JSONObject hit: hits) {
final MarkerOptions marker = HitMarker.marker(hit);
builder.include(marker.getPosition());
googleMap.addMarker(marker);
}
LatLngBounds bounds = builder.build();
// update the camera
int padding = 10;
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.animateCamera(cu);
}
项目:SpotlessGHack-Intellibins-Android
文件:MapsActivity.java
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setBuildingsEnabled(true);
mMap.setIndoorEnabled(true);
if (MiscHelper.isPermitted(this, Manifest.permission.ACCESS_FINE_LOCATION) &&
MiscHelper.isPermitted(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
mMap.setMyLocationEnabled(true); // Ignore this
Location location = getCurrentLocation();
if(location != null) {
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 20);
mMap.moveCamera(cameraUpdate);
onLocationChanged(location);
}
} else{
ActivityCompat.requestPermissions(
this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
CODE_GET_GPS_PERMISSION
);
}
}
项目:MikuyConcept
文件:ExploreFragment.java
@Override
public void showAvailableRestaurants(List<Restaurant> items) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Restaurant restaurant : items) {
Marker marker = this.googleMap.addMarker(
new MarkerOptions()
.position(new LatLng(restaurant.latitude, restaurant.longitude))
.title(restaurant.name)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.mikuy_marker))
.snippet(restaurant.category));
marker.setTag(restaurant);
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 100);
this.googleMap.moveCamera(cu);
}
项目:PhoneChat
文件:PluginMap.java
/**
* Move the camera of the map
* @param cameraUpdate
* @param durationMS
* @param callbackContext
*/
private void myAnimateCamera(final CameraUpdate cameraUpdate, final int durationMS, final CallbackContext callbackContext) {
GoogleMap.CancelableCallback callback = new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
callbackContext.success(ANIMATE_CAMERA_DONE);
}
@Override
public void onCancel() {
callbackContext.success(ANIMATE_CAMERA_CANCELED);
}
};
if (durationMS > 0) {
map.animateCamera(cameraUpdate, durationMS, callback);
} else {
map.animateCamera(cameraUpdate, callback);
}
}
项目:simple-map-android
文件:ActivityMap.java
private void loadMapPins(List<Unit> units) {
mMap.clear();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Unit u : units) {
mMap.addMarker(new MarkerOptions()
.title(u.getNome())
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action_pin))
.snippet(u.buildSnippet())
.position(new LatLng(u.getGeo().getLatitude(), u.getGeo().getLongitude())));
builder.include(new LatLng(u.getGeo().getLatitude(), u.getGeo().getLongitude()));
}
LatLngBounds bounds = builder.build();
int padding = (int) (16 * getResources().getDisplayMetrics().density);
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
}
项目:MapViewPager
文件:MapViewPager.java
private void moveToSingle(Adapter adapter, int index, boolean animate) {
CameraPosition cp = adapter.getCameraPosition(index);
CameraUpdate cu;
if (cp != null && cp.target != null
&& cp.target.latitude != 0.0
&& cp.target.longitude != 0.0) {
cu = CameraUpdateFactory.newCameraPosition(cp);
if (hidden) showMarkers();
if (markers.get(index) != null) markers.get(index).showInfoWindow();
}
else {
cu = defaultPosition;
hideInfoWindowSingle();
}
if (animate) map.animateCamera(cu);
else map.moveCamera(cu);
}
项目:Japp16
文件:GoogleJotiMap.java
@Override
public void animateCamera(LatLng latLng,int zoom, final IJotiMap.CancelableCallback cancelableCallback) {
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, zoom);
if (cancelableCallback != null) {
googleMap.animateCamera(cameraUpdate, new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
cancelableCallback.onFinish();
}
@Override
public void onCancel() {
cancelableCallback.onCancel();
}
});
} else {
googleMap.animateCamera(cameraUpdate, null);
}
}
项目:mytracks
文件:MyTracksMapFragment.java
/**
* Updates the current location.
*
* @param forceZoom true to force zoom to the current location regardless of
* the keepCurrentLocationVisible policy
*/
private void updateCurrentLocation(final boolean forceZoom) {
getActivity().runOnUiThread(new Runnable() {
public void run() {
if (!isResumed() || googleMap == null || onLocationChangedListener == null
|| currentLocation == null) {
return;
}
onLocationChangedListener.onLocationChanged(currentLocation);
if (forceZoom || (keepCurrentLocationVisible && !isLocationVisible(currentLocation))) {
LatLng latLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
CameraUpdate cameraUpdate = forceZoom ? CameraUpdateFactory.newLatLngZoom(
latLng, DEFAULT_ZOOM_LEVEL)
: CameraUpdateFactory.newLatLng(latLng);
googleMap.animateCamera(cameraUpdate);
}
};
});
}
项目:mytracks
文件:MyTracksMapFragment.java
/**
* Shows a marker by moving the camera over the marker.
*
* @param id the marker id
*/
private void showMarker(final long id) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (!isResumed() || googleMap == null) {
return;
}
MyTracksProviderUtils MyTracksProviderUtils = Factory.get(getActivity());
Waypoint waypoint = MyTracksProviderUtils.getWaypoint(id);
if (waypoint == null) {
return;
}
Location location = waypoint.getLocation();
if (location == null) {
return;
}
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
keepCurrentLocationVisible = false;
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, DEFAULT_ZOOM_LEVEL);
googleMap.moveCamera(cameraUpdate);
}
});
}
项目:trail-android
文件:MapsActivity.java
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap map) {
mMap = map;
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(POINT_A);
builder.include(POINT_B);
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 200);
mMap.moveCamera(cu);
mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
startAnim();
}
});
}
项目:PGMacTips
文件:MapUtilities.java
public static CameraUpdate calculateZoomLevel(@NonNull LatLng latLng, float radiusInMeters,
@NonNull DisplayManagerUtilities dmu){
if(radiusInMeters < 0){
radiusInMeters = 10;
}
int width, height;
Point point = dmu.getAppUsableScreenSize();
if(point != null) {
width = point.x;
height = point.y;
} else {
width = dmu.getPixelsWidth();
height = dmu.getPixelsHeight();
}
LatLngBounds latLngBounds = calculateBounds(latLng, radiusInMeters);
return CameraUpdateFactory.newLatLngBounds(latLngBounds, width, height, 0);
}
项目:sample-transport-app
文件:RouteMapServiceTest.java
@Test
public void shouldAddRouteToMap() {
// given
RouteMapData routeMapData = prepareRouteMapData();
doAnswer(mapLoadedCallbackAnswer).when(googleMap).setOnMapLoadedCallback(any(GoogleMap.OnMapLoadedCallback.class));
doAnswer(newLatLngBoundsAnswer).when(googleMap).addPolyline(any(PolylineOptions.class));
when(CameraUpdateFactory.newLatLngBounds(any(LatLngBounds.class), anyInt())).thenReturn(cameraUpdate);
// when
routeMapService.addRouteToMap(googleMap, routeMapData);
// then
verify(googleMap, times(1)).addPolyline(any(PolylineOptions.class));
verify(googleMap, times(2)).addMarker(any(MarkerOptions.class));
verify(googleMap, times(1)).animateCamera(any(CameraUpdate.class));
}
项目:Runch
文件:MapActivity.java
public void onMapReady(final GoogleMap map) {
lat = getIntent().getDoubleExtra(EXTRA_LATITUDE, 0);
lng = getIntent().getDoubleExtra(EXTRA_LONGITUDE, 0);
map.setMyLocationEnabled(true);
map.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
LatLng me = new LatLng(location.getLatitude(), location.getLongitude());
map.addMarker(new MarkerOptions().position(me).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
}
});
LatLng restaurant = new LatLng(lat, lng);
Marker marker = map.addMarker(new MarkerOptions().title(getIntent().getStringExtra(RESTAURANT_NAME)).position(restaurant));
marker.showInfoWindow();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(restaurant, 15f);
map.moveCamera(cameraUpdate);
}
项目:smartpublictransport-as
文件:DirectionActivity.java
/**
* Zooms in to the {@link #selectedMarker}, or show all if null. Requires
* map to be fully drawn.
*/
private void focusOnSelectedMarker(Integer lastSelectedMarker) {
if (map != null) {
if (lastSelectedMarker != null) {
markers.get(lastSelectedMarker).hideInfoWindow();
}
CameraUpdate cameraUpdate;
if (selectedMarker == null) {
cameraUpdate = CameraUpdateFactory.newLatLngBounds(
allPointsBounds, BOUNDS_PADDING);
initSelectedStep(null, null);
} else {
cameraUpdate = CameraUpdateFactory.newLatLngZoom(
markers.get(selectedMarker).getPosition(), FOCUS_ZOOM);
markers.get(selectedMarker).showInfoWindow();
initSelectedStep(markers.get(selectedMarker).getTitle(),
markers.get(selectedMarker).getSnippet());
stepListView.setItemChecked(selectedMarker, true);
}
map.animateCamera(cameraUpdate);
slidingUpLayout.collapsePane();
}
}
项目:geohashdroid
文件:ExpeditionMode.java
private void zoomToIdeal(Location current) {
// We can't do an ideal zoom if we don't have permissions!
if(arePermissionsDenied()) {
Log.i(DEBUG_TAG, "Tried to do an ideal zoom after permissions were denied, ignoring...");
return;
}
// Where "current" means the user's current location, and we're zooming
// relative to the final destination, if we have it yet. Let's check
// that latter part first.
if(mCurrentInfo == null) {
Log.i(DEBUG_TAG, "zoomToIdeal was called before an Info was set, ignoring...");
return;
}
// As a side note, yes, I COULD probably mash this all down to one line,
// but I want this to be readable later without headaches.
LatLngBounds bounds = LatLngBounds.builder()
.include(new LatLng(current.getLatitude(), current.getLongitude()))
.include(mCurrentInfo.getFinalDestinationLatLng())
.build();
CameraUpdate cam = CameraUpdateFactory.newLatLngBounds(bounds, mCentralMap.getResources().getDimensionPixelSize(R.dimen.map_zoom_padding));
mMap.animateCamera(cam);
}
项目:geohashdroid
文件:ExpeditionMode.java
private void zoomToInitialCurrentLocation(Location loc) {
// This is called during initial lookup, just to make sure the map's at
// a location OTHER than dead zero while we potentially wait for a stock
// value to come in. The zoom will be to half a degree around the
// current point, just to grab an entire graticule's space.
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(new LatLng(loc.getLatitude() - .5, loc.getLongitude() - .5));
builder.include(new LatLng(loc.getLatitude() - .5, loc.getLongitude() + .5));
builder.include(new LatLng(loc.getLatitude() + .5, loc.getLongitude() - .5));
builder.include(new LatLng(loc.getLatitude() + .5, loc.getLongitude() + .5));
CameraUpdate cam = CameraUpdateFactory.newLatLngBounds(builder.build(), mCentralMap.getResources().getDimensionPixelSize(R.dimen.map_zoom_padding));
try {
// And don't worry, when the stock comes in, that'll fire off a new
// animateCamera() call, which in turn will cancel this one.
mMap.animateCamera(cam);
} catch(IllegalStateException ise) {
// I really hope it's ready to go by now...
Log.w(DEBUG_TAG, "The map isn't ready for animating yet!");
}
}
项目:flowzr-android-black
文件:LocationActivity.java
@Override
protected void onResume() {
super.onResume();
//Now set the map
setUpMapIfNeeded();
if (orbLocation.id == -1) {
if (MyPreferences.isUseMyLocation(this)) {
mUpdatesRequested=true;
}
} else {
mMarker=mMap.addMarker(new MarkerOptions().position(new LatLng(orbLocation.latitude, orbLocation.longitude)).title(orbLocation.name).draggable(true));
LatLng latLng = new LatLng(orbLocation.latitude, orbLocation.longitude);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng,15);
mMap.animateCamera(cameraUpdate);
}
}
项目:flowzr-android-black
文件:LocationActivity.java
/**
* Report location updates to the UI.
*
* @param location The updated location.
*/
@Override
public void onLocationChanged(Location location) {
if (orbLocation.id == -1) {
if (MyPreferences.isUseMyLocation(this)) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng,15);
mMap.animateCamera(cameraUpdate);
orbLocation.latitude=latLng.latitude;
orbLocation.longitude=latLng.longitude;
mMarker=mMap.addMarker(new MarkerOptions().position(latLng).draggable(true));
mMarker.setPosition(latLng);
new SolveSaveLocationTask(getBaseContext(), false).execute(orbLocation);
}
mUpdatesRequested=false;
stopPeriodicUpdates();
}
}
项目:AndroidCamp
文件:MainActivity.java
@Override
public void onLocationChanged(Location location) {
// Report to the UI that the location was updated
String msg = "Updated Location: " +
Double.toString(location.getLatitude()) + "," +
Double.toString(location.getLongitude());
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
Log.w(TAG, "Location: " + msg);
mGoogleApiClient.disconnect();
LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(position, 10.0f);
mMap.animateCamera(update);
(new GetAddressTask(this)).execute(location);
}
项目:xamoom-pingeborg-android
文件:MapFragment.java
/**
* Zooms map to display all markers.
*/
public void zoomMapAcordingToMarkers() {
//zoom to display all markers
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Marker marker : markerMap.keySet()) {
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();
//move camera to calulated point
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 70);
mGoogleMap.moveCamera(cu);
//remove progressBar
mProgressBar.setVisibility(View.GONE);
}
项目:xamoom-pingeborg-android
文件:MapFragment.java
/**
* Zooms the map to a marker, so that it will be above
* the MapAdditionFragment.
*
* @param marker A Marker from a GoogleMap.
*/
public void zoomMapToMarker(Marker marker) {
//move camera to display marker above the mapAddtionFragment
Projection projection = mGoogleMap.getProjection();
LatLng markerLatLng = new LatLng(marker.getPosition().latitude,
marker.getPosition().longitude);
Point markerScreenPosition = projection.toScreenLocation(markerLatLng);
Point pointHalfScreenAbove = new Point(markerScreenPosition.x,
markerScreenPosition.y + (this.getResources().getDisplayMetrics().heightPixels / 5));
LatLng aboveMarkerLatLng = projection
.fromScreenLocation(pointHalfScreenAbove);
marker.showInfoWindow();
CameraUpdate center = CameraUpdateFactory.newLatLng(aboveMarkerLatLng);
mGoogleMap.animateCamera(center);
}
项目:AndroidSlidingPanelAdvanced
文件:MainActivity.java
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.
mMap = mMapFragment.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setCompassEnabled(false);
mMap.getUiSettings().setZoomControlsEnabled(false);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
CameraUpdate update = getLastKnownLocation();
if (update != null) {
mMap.moveCamera(update);
}
}
}
}
项目:AndroidMapTest
文件:MapsActivity.java
private void zoomToPoints() {
try {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
// for (Marker marker : markers) {
builder.include(myLatLng);
builder.include(shopLatLng);
// }
LatLngBounds bounds = builder.build();
int padding = 50; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
}
catch (Exception e)
{
///possible error:
/// java.lang.NullPointerException: Attempt to invoke interface method 'org.w3c.dom.NodeList org.w3c.dom.Document.getElementsByTagName(java.lang.String)' on a null object reference
}
}
项目:passarola
文件:MapsActivity.java
private void showMarkers(List<PlaceViewModel> places) {
if (googleMap != null && !places.isEmpty()) {
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (PlaceViewModel placeViewModel : places) {
Marker marker = googleMap.addMarker(createMarkerOption(placeViewModel));
boundsBuilder.include(marker.getPosition());
markersMap.put(placeViewModel.getLatLng(), new Pair<>(placeViewModel, marker));
}
LatLngBounds bounds = boundsBuilder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 160);
googleMap.animateCamera(cameraUpdate);
} else {
onPlacesErrorEvent(new Exception("Google map is not instantiated"));
}
}
项目:mobile-android-survey-app
文件:GeofieldFragment.java
private void setLocation(double latitude, double longitude, boolean marker) {
Log.i(this, "setLocation %f,%f", latitude, longitude);
this.latitude = latitude;
this.longitude = longitude;
if (latitude != 0.0 && longitude != 0.0 && marker) {
if (map != null) {
map.clear();
LatLng latLng = new LatLng(latitude, longitude);
map.addMarker(new MarkerOptions()
.position(latLng)
.draggable(true)
.title(getString(R.string.current_location))
.snippet(String.format("%f,%f", latitude, longitude)));
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15);
map.animateCamera(cameraUpdate);
}
}
}
项目:GetThere
文件:RouteMap.java
private void CreateMarkers(){
mMap.clear();
float tempLat, tempLongitude;
busMarkers = new ArrayList<>();
busMarkers.clear();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for(int i =0; i < longitudeList.size(); i++){
tempLat = (latitudeList.get(i)/(float)100000);
tempLongitude = (longitudeList.get(i)/(float)100000);
System.out.println("Lat:" + tempLat + "Long:" + tempLongitude);
Marker marker = mMap.addMarker(new MarkerOptions().position(new LatLng(tempLat,tempLongitude)).title(routeName).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
builder.include(new LatLng(tempLat,tempLongitude));
busMarkers.add(marker);
marker.setVisible(true);
}
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,70);
mMap.animateCamera(cu);
}
项目:application-cafe-jeunesse-android
文件:GoogleMapFragment.java
@Override
public void onResume() {
super.onResume();
if (mMap == null) {
// Au besoin (pas déjà fait), on recharge la map
mMap = mMapFragment.getMap();
// TODO chargement de la map dans une tâche asynchrone afin de diminuer
// l'impression de lag (la vue se charge d'abord, puis la map)
setUpMap();
}
// mise à jour de la position
if(mLocation !=null) {
CameraUpdate center= CameraUpdateFactory.newLatLngZoom(
new LatLng(mLocation.getLatitude(), mLocation.getLongitude()),
15);
mMap.moveCamera(center);
}
if(mDataSource != null)
mDataSource.open();
}
项目:AndroidSlidingUpPanelFourSquareLike
文件:MainActivity.java
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.
mMap = mMapFragment.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setCompassEnabled(false);
mMap.getUiSettings().setZoomControlsEnabled(false);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
CameraUpdate update = getLastKnownLocation();
if (update != null) {
mMap.moveCamera(update);
}
}
}
}
项目:neo4art
文件:PluginMap.java
/**
* Move the camera of the map
* @param cameraUpdate
* @param durationMS
* @param callbackContext
*/
private void myAnimateCamera(final CameraUpdate cameraUpdate, final int durationMS, final CallbackContext callbackContext) {
GoogleMap.CancelableCallback callback = new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
callbackContext.success();
}
@Override
public void onCancel() {
callbackContext.success();
}
};
if (durationMS > 0) {
map.animateCamera(cameraUpdate, durationMS, callback);
} else {
map.animateCamera(cameraUpdate, callback);
}
}
项目:neo4art
文件:PluginMap.java
/**
* Move the camera of the map
* @param cameraUpdate
* @param durationMS
* @param callbackContext
*/
private void myAnimateCamera(final CameraUpdate cameraUpdate, final int durationMS, final CallbackContext callbackContext) {
GoogleMap.CancelableCallback callback = new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
callbackContext.success();
}
@Override
public void onCancel() {
callbackContext.success();
}
};
if (durationMS > 0) {
map.animateCamera(cameraUpdate, durationMS, callback);
} else {
map.animateCamera(cameraUpdate, callback);
}
}
项目:neo4art
文件:PluginMap.java
/**
* Move the camera of the map
* @param cameraUpdate
* @param durationMS
* @param callbackContext
*/
private void myAnimateCamera(final CameraUpdate cameraUpdate, final int durationMS, final CallbackContext callbackContext) {
GoogleMap.CancelableCallback callback = new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
callbackContext.success();
}
@Override
public void onCancel() {
callbackContext.success();
}
};
if (durationMS > 0) {
map.animateCamera(cameraUpdate, durationMS, callback);
} else {
map.animateCamera(cameraUpdate, callback);
}
}