本文整理匯總了Java中com.google.android.gms.maps.CameraUpdate類的典型用法代碼示例。如果您正苦於以下問題:Java CameraUpdate類的具體用法?Java CameraUpdate怎麽用?Java CameraUpdate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CameraUpdate類屬於com.google.android.gms.maps包,在下文中一共展示了CameraUpdate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showPointerOnMap
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
});
}
示例2: updateCamera
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
/**
* 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);
}
示例3: PlacePinAndPositionCamera
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
示例4: showColegiElectoralData
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
示例5: gotoLocation
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
/**
* 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);
}
}
示例6: updateUI
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
示例7: refreshMarkers
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
}
示例8: fitMap
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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() : "");
}
}
示例9: updateMapArea
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
/**
* 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);
}
示例10: updateMapPOIs
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
示例11: onMapReady
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
/**
* 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
);
}
}
示例12: showAvailableRestaurants
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
@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);
}
示例13: myAnimateCamera
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
/**
* 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);
}
}
示例14: loadMapPins
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}
示例15: moveToSingle
import com.google.android.gms.maps.CameraUpdate; //導入依賴的package包/類
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);
}