当前位置: 首页>>代码示例>>Java>>正文


Java GoogleMap.setOnCameraMoveListener方法代码示例

本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.setOnCameraMoveListener方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleMap.setOnCameraMoveListener方法的具体用法?Java GoogleMap.setOnCameraMoveListener怎么用?Java GoogleMap.setOnCameraMoveListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.maps.GoogleMap的用法示例。


在下文中一共展示了GoogleMap.setOnCameraMoveListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
	this.googleMap = googleMap;

	// Move camera to Porto Alegre
	LatLng portoAlegre = new LatLng(-30.039005, -51.224059);
	this.googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(portoAlegre, 14));
	customizeMap();
	customizeMapLocation();

	// Set map specific listeners
	googleMap.setOnMarkerClickListener(this);
	googleMap.setOnCameraMoveListener(this);

	mapViewModel = new MapViewModel(this.googleMap, this);
	binding.setViewModel(mapViewModel); // We don't use data binding anywhere though
}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:18,代码来源:MapActivity.java

示例2: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(final GoogleMap map) {
	gmaps = map;
	checkPerms();
	map.getUiSettings(). setMyLocationButtonEnabled(false);
	map.setPadding(20, 0, 20, 10);
	map.moveCamera(CameraUpdateFactory.newLatLngZoom(home, 16f));
	// camera move listener
	map.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener(){
			@Override
			public void onCameraMove() {
				// atur centerMarker samar saat maps digerakan
				centerMarker.setAlpha(0.5f);
				// hanya saat maps digerakan menggunakan tangan (buka programatically)
				if (mMapIsTouched) {
					// one shot action
					/*if (sbOnceMove) { // remove hideable searchBar
						// animasi sembunyi pada searchbar
						searchareaAnimate.setStartDelay(0);
						searchareaAnimate.setDuration(500);
						searchareaAnimate.translationY(-searchbarHeight);
						searchareaAnimate.start();
						UIUtil.hideKeyboard(MainActivity.this);
					}*/
					sbOnceMove = false;
				}
			}
		});
	// camera idle (diam) listener
	// di trigger saat pertama maps dijalankan dan saat selesai dari move (menggeser maps)
	map.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener(){
			@Override
			public void onCameraIdle() {
				// atur centerMarker ke solid (bukan samar lagi)
				centerMarker.setAlpha(1.0f);
				// animasi tampil pada searchbar
				//searchareaAnimate.setStartDelay(1500).setDuration(800).translationY(0).start();
				sbOnceMove = true;
			}
		});
	// saat menekan tombol GPS (my location)
	tariff.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener(){
			@Override
			public boolean onMyLocationButtonClick() {
				// cek apakah GPS aktif
				// jika tidak maka jalankan GPSrequest()
				final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
				if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
					GPSrequest();
				} else {
					// jika GPS aktif, tampikan waiting indikator dan cari lokasi pengguna
					if(tprog.isShowing()){
						tprog.cancel();
						setTitle(""+System.currentTimeMillis());
						return false;
					}
					movetomylocation = true;
					gmaps.getMyLocation();
					tprog.show("Waiting for location...", Gravity.CENTER, (1000*60)*2);
					tprog.setOnTimedOutListener(new ToastProgress.onTimedOutListener(){
							@Override
							public void onTimedOut() {
								Toast.makeText(MainActivity.this, "Timed Out",0).show();
							}
						});
				}
				return false;
			}
		});
	// di trigger saat lokasi pengguna terdeteksi atau terjadi perubahan lokasi
	map.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener(){
			@Override
			public void onMyLocationChange(Location loc) {
				if (movetomylocation) {
					tprog.cancel();
					gmaps.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(loc.getLatitude(), loc.getLongitude()), 15f), 1500, null);
				}
				movetomylocation = false;
			}
		});
}
 
开发者ID:agusibrahim,项目名称:go-jay,代码行数:82,代码来源:MainActivity.java

示例3: MapsManager

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
MapsManager(Activity context, GoogleMap map) {
    mContext = context;

    // 地圖
    mMaps.add(MAP_CODE_MAIN, map);
    mMapTiles.add(MAP_CODE_MAIN, null);

    mZoomNumber = (TextView) context.findViewById(R.id.zoom_number);

    // 顯示準心座標
    mCrossCoor = (TextView) context.findViewById(R.id.tvCoord);
    mCrossCoor.setOnClickListener((MapsActivity) mContext);

    // 加入比例尺
    RelativeLayout container = (RelativeLayout) context.findViewById(R.id.layout_container);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(800, 800);
    mScaleBar = new ScaleBar(mContext, getMap(MAP_CODE_MAIN));
    mScaleBar.setLayoutParams(params);
    container.addView(mScaleBar);

    // 註冊畫面縮放的監聽
    map.setOnCameraMoveListener(this);

    // Set the Listener
    map.setOnMapClickListener(this);
    map.setOnMapLongClickListener(this);
    map.setOnInfoWindowClickListener(this);
    map.setOnMarkerDragListener(this);
    map.setOnCameraIdleListener(this);

    // 在Activity和Map物件註冊ClusterManager
    mClusterManagers.add(MAP_CODE_MAIN, new ClusterManager<CustomMarker>(mContext, map));
    // The Rule about Cluster Managing
    mClusterManagers.get(MAP_CODE_MAIN).setRenderer(
            new CustomRenderer(mContext, map, mClusterManagers.get(MAP_CODE_MAIN)));
    mClusterManagers.get(MAP_CODE_MAIN).setOnClusterClickListener(
            (CustomRenderer) mClusterManagers.get(MAP_CODE_MAIN).getRenderer());
    // Click on marker to open infoWindow
    map.setOnMarkerClickListener(mClusterManagers.get(MAP_CODE_MAIN));
    // POI in Google map
    map.setOnPoiClickListener(this);

    // Test for new info window
    map.setInfoWindowAdapter(new CustomAdapter(mContext));
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:46,代码来源:MapsManager.java


注:本文中的com.google.android.gms.maps.GoogleMap.setOnCameraMoveListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。