當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。