问题描述
我有我的MapController和MapView,我启用了内置的缩放控件使用:
mapView.setBuiltInZoomControls(true);
现在我想在用户实际放大地图时收到一个事件,我该怎么走关于那个?我可以找到没有这样的事件或任何一般的事件,我可以检测到缩放级别的变化。
更新
。并且文档建议改用mapView.setBuiltInZoomControls(bool)。这是可以的,但我根本无法弄清楚如何对内置的缩放控件中的事件进行处理。
Maps Android API v2可以使用如下所示:
mMap.setOnCameraChangeListener(new OnCameraChangeListener(){
private float currentZoom = -1;
@Override
public void onCameraChange(CameraPosition pos){
if(pos.zoom!= currentZoom){
currentZoom = pos.zoom;
//你在这里行动
}
}
});
We're building an application which is using the google maps api for android.
I have my MapController and MapView, and I enable the built-in zoom controls using:
mapView.setBuiltInZoomControls(true);
I would now like to get an event when the user actually zooms on the map, how do I go about that? I can find no such event or any general event where I could detect a change in zoom level.
Update
The mapView.getZoomControls() is deprecated. And the documentation suggests using mapView.setBuiltInZoomControls(bool) instead. This is okay, but I simply cannot figure out how to act on events from the built in zoom controls.
With the Google Maps Android API v2 you can use a GoogleMap.OnCameraChangeListener like this:
mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
private float currentZoom = -1;
@Override
public void onCameraChange(CameraPosition pos) {
if (pos.zoom != currentZoom){
currentZoom = pos.zoom;
// do you action here
}
}
});
这篇关于在Android上的谷歌地图缩放事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!