本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.setOnCameraIdleListener方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleMap.setOnCameraIdleListener方法的具体用法?Java GoogleMap.setOnCameraIdleListener怎么用?Java GoogleMap.setOnCameraIdleListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.GoogleMap
的用法示例。
在下文中一共展示了GoogleMap.setOnCameraIdleListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClusterer
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void setUpClusterer(@NonNull CivifyMap map) {
GoogleMap googleMap = map.getGoogleMap();
setRenderer(new IssueMarkerClusterRenderer(map, this));
setOnClusterItemClickListener(this);
googleMap.setOnMarkerClickListener(this);
googleMap.setOnCameraIdleListener(this);
}
示例2: enableSubMap
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public void enableSubMap(GoogleMap subMap) {
mMaps.add(MAP_CODE_SUB, subMap);
mMapTiles.add(MAP_CODE_SUB, null);
subMap.setMapType(MAP_TYPE_HYBRID);
subMap.moveCamera(CameraUpdateFactory.newCameraPosition(mMaps.get(MAP_CODE_MAIN).getCameraPosition()));
onCameraMove();
// 在Activity和Map物件註冊ClusterManager
mClusterManagers.add(MAP_CODE_SUB, new ClusterManager<CustomMarker>(mContext, subMap));
// The Rule about Cluster Managing
mClusterManagers.get(MAP_CODE_SUB).setRenderer(
new CustomRenderer(mContext, subMap, mClusterManagers.get(MAP_CODE_SUB)));
mClusterManagers.get(MAP_CODE_SUB).setOnClusterClickListener(
(CustomRenderer) mClusterManagers.get(MAP_CODE_SUB).getRenderer());
// Click on marker to open infoWindow
subMap.setOnMarkerClickListener(mClusterManagers.get(MAP_CODE_SUB));
// Click on Cluster to zoom to Markers
subMap.setOnCameraIdleListener(this);
// Test for new info window
subMap.setInfoWindowAdapter(new CustomAdapter(mContext));
}
示例3: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(NETHERLANDS, 0));
}
});
ClusterManager<SampleClusterItem> clusterManager = new ClusterManager<>(this, googleMap);
clusterManager.setCallbacks(new ClusterManager.Callbacks<SampleClusterItem>() {
@Override
public boolean onClusterClick(@NonNull Cluster<SampleClusterItem> cluster) {
Log.d(TAG, "onClusterClick");
return false;
}
@Override
public boolean onClusterItemClick(@NonNull SampleClusterItem clusterItem) {
Log.d(TAG, "onClusterItemClick");
return false;
}
});
googleMap.setOnCameraIdleListener(clusterManager);
List<SampleClusterItem> clusterItems = new ArrayList<>();
for (int i = 0; i < 20000; i++) {
clusterItems.add(new SampleClusterItem(
RandomLocationGenerator.generate(NETHERLANDS)));
}
clusterManager.setItems(clusterItems);
}
示例4: 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;
}
});
}
示例5: 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));
}