本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.animateCamera方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleMap.animateCamera方法的具体用法?Java GoogleMap.animateCamera怎么用?Java GoogleMap.animateCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.GoogleMap
的用法示例。
在下文中一共展示了GoogleMap.animateCamera方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: zoomToPolyline
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public static void zoomToPolyline(GoogleMap map, Polyline p) {
if (p == null || p.getPoints().isEmpty())
return;
LatLngBounds.Builder builder = LatLngBounds.builder();
for (LatLng latLng : p.getPoints()) {
builder.include(latLng);
}
final LatLngBounds bounds = builder.build();
try{
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
} catch (Exception e){
e.printStackTrace();
}
}
示例2: fitMap
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的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() : "");
}
}
示例3: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setMapToolbarEnabled(false);
LatLng latLng = mPointOfInterest.latLng;
if (latLng != null) {
googleMap.addMarker(new MarkerOptions().position(latLng)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16f));
}
}
示例4: cameraCorrection
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private static void cameraCorrection(final Context ctx, final GoogleMap gmap, final LatLng start, final LatLng end, final VMargin padding) {
GoogleMap.CancelableCallback cameraOnFinish=new GoogleMap.CancelableCallback(){
@Override
public void onFinish() {
cameraCorrection(ctx, gmap, start, end, padding);
}
@Override
public void onCancel() {
// TODO: Implement this method
}
};
Point addr_startPoint=gmap.getProjection().toScreenLocation(start);
Point addr_endPoint = gmap.getProjection().toScreenLocation(end);
DisplayMetrics dm=ctx.getResources().getDisplayMetrics();
int maxX=dm.widthPixels;
if (addr_startPoint.y < padding.searchbar_margin || addr_endPoint.y < padding.searchbar_margin) {
gmap.animateCamera(CameraUpdateFactory.zoomBy(-1f), 1000, cameraOnFinish);
android.util.Log.d("jos", "Batas atas");
} else if (addr_startPoint.x < dp2px(ctx, 10) || addr_endPoint.x < dp2px(ctx, 10) || addr_startPoint.x > maxX - dp2px(ctx, 10) || addr_endPoint.x > maxX - dp2px(ctx, 10)) {
gmap.animateCamera(CameraUpdateFactory.zoomBy(-0.2f), 1000, cameraOnFinish);
android.util.Log.d("jos", "Batas samping");
} else if (addr_startPoint.y > (dm.heightPixels - padding.tariffview_margin) || addr_endPoint.y > (dm.heightPixels - padding.tariffview_margin)) {
gmap.animateCamera(CameraUpdateFactory.zoomBy(-0.2f), 1000, cameraOnFinish);
android.util.Log.d("jos", "Batas bawah");
}else{
if(camcallback!=null) camcallback.onComplete();
}
android.util.Log.d("jos", "batas: " + (dm.heightPixels - padding.tariffview_margin));
android.util.Log.d("jos", "marker: " + addr_endPoint.y);
android.util.Log.d("jos", "70dp: " + dp2px(ctx, 70));
}
示例5: requestCenterCamera
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public static void requestCenterCamera(final Context ctx, final GoogleMap gmap, final LatLng start, final LatLng end, final VMargin padding, OnCameraComplete x) {
final LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(start).include(end);
camcallback=x;
gmap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0), 1000, new GoogleMap.CancelableCallback(){
@Override
public void onFinish() {
cameraCorrection(ctx, gmap, start, end, padding);
}
@Override
public void onCancel() {
// TODO: Implement this method
}
});
}
示例6: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(eve.getPlace().getLat(),eve.getPlace().getLon()))
.zoom(17)
.bearing(0)
.tilt(80)
.build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
googleMap.addMarker(new MarkerOptions().position(new LatLng(eve.getPlace().getLat(),eve.getPlace().getLon())));
}
示例7: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
//crt list
crt[0] = new crtLocation(36.796043,10.176679 ,"Rue de Angleterre, Tunis");
crt[1] = new crtLocation(36.811240,10.168087 ,"DNSP, Rue du Fort, Tunis");
crt[2] = new crtLocation(36.768390,10.231351 ,"Centre National de Formation des volontaires");
crt[3] = new crtLocation(36.765738,10.249805 ,"Comité Local megrine");
crt[4] = new crtLocation(36.857147,10.188060 ,"Croissant Rouge Tunisien");
crt[5] = new crtLocation(35.857905,10.598179 ,"comité local Hammam Sousse");
crt[6] = new crtLocation(34.731843,10.759640,"Rue El Arbi Zarrouk, Sfax");
crt[7] = new crtLocation(33.504106,11.088150 ,"Mouensa, Zarzis ");
crt[8] = new crtLocation(36.441899,10.729911 ," Comité Regional De Nabeul");
crt[9] = new crtLocation( 35.829321,10.638072 ,"Comité Local de Sousse");
crt[10] = new crtLocation(33.137021,11.220034 ,"Comité Local Benguerdane");
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (int i = 0;i<11;i++) {
marker = map.addMarker(new MarkerOptions()
.position(new LatLng(crt[i].getX(), crt[i].getY()))
.title("Croissant Rouge Tunisien")
.snippet(crt[i].getAdresse()));
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();
int padding = 0; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.animateCamera(cu);
}
示例8: recapDisplayTrack
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
* Display the given Track on the given GoogleMap. The argument color indicates the desired color for
* the Track to be shown. Also takes care to center the camera on the displayed Track. Used for recaps
*
* @param track Track to be shown
* @param googleMap map where the Track must be shown
* @param color color for the Track to be shown
*/
public static void recapDisplayTrack(Track track, GoogleMap googleMap, int color) {
if(track == null || googleMap == null) {
throw new IllegalArgumentException();
}
if (track.getTotalCheckPoints() != 0) {
// Build polyline and latitude, longitude bounds
PolylineOptions polylineOptions = new PolylineOptions();
List<CheckPoint> trackPoints = track.getCheckpoints();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (CheckPoint checkPoint : trackPoints) {
LatLng latLng = new LatLng(checkPoint.getLatitude(), checkPoint.getLongitude());
polylineOptions.add(latLng);
builder.include(latLng);
}
googleMap.addPolyline(polylineOptions.color(color));
// Center camera on past run
LatLngBounds bounds = builder.build();
int padding = 40;
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.animateCamera(cameraUpdate);
}
}
示例9: onClick
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onClick(View v)
{
final FragmentManager fm = ((FragmentActivity) getActivity()).getSupportFragmentManager();
final FragmentTransaction ft;
final GoogleMap map = gMap;
switch (v.getId())
{
case R.id.mapChooseButton:
ft = fm.beginTransaction();
final RMBTMapFilterFragment mapFilterFragment = new RMBTMapFilterFragment();
ft.replace(R.id.fragment_content, mapFilterFragment, "map_filter");
ft.addToBackStack("map_filter");
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
break;
case R.id.mapLocateButton:
if (map != null && geoLocation != null)
{
final Location location = geoLocation.getLastKnownLocation();
if (location != null)
{
final LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
gMap.animateCamera(CameraUpdateFactory.newLatLng(latlng));
}
}
break;
case R.id.mapHelpButton:
((RMBTMainActivity) getActivity()).showUrl("", false, AppConstants.PAGE_TITLE_HELP); // TODO: put correct
// help url
break;
case R.id.mapZoomInButton:
if (map != null)
map.animateCamera(CameraUpdateFactory.zoomIn());
break;
case R.id.mapZoomOutButton:
if (map != null)
map.animateCamera(CameraUpdateFactory.zoomOut());
break;
case R.id.mapLocationSearchButton:
if (map != null) {
MapLocationSearch.showDialog(this);
}
break;
default:
break;
}
}
示例10: zoomToMarker
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public static void zoomToMarker(GoogleMap map, CustomMarker m) {
final LatLngBounds bounds = new LatLngBounds(m.getPosition(), m.getPosition());
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 400));
}