In the Android 2D Map SDK V2.2.0, there is a bug when Getcamerapositon (). Zoom gets the value is 3.0, if in the application has to use this version of 2D map, and must get this value (if not must not recommend ha), here is a not very traditional way to get, by adding a tileoverlay on the map, this overlay, do not load any new layers or data, just To get the latest level levels:
The code is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
mAmap = mMapView.getMap();
// tileoverlay,只用于取level不加任何数据
TileProvider tileprovider =
new UrlTileProvider(
256
,
256
) {
@Override
public URL getTileUrl(
int x,
int y,
int level) {
// 拿到当前的级别
if (mLevel != level) {
mLevel = level;
// 这里是子线程,不能直接操作ui,
// ps:mLevel的获取不要通过OncameraChangeListener进行处理
// 因为线程的先后关系,在快速缩放时,取到的mLevel有可能不是最新的
handler.sendEmptyMessage(
0
);
}
// 这里不加载新的图层所以为null
return null
;
}
};
TileOverlayOptions tileOverlayOptions =
new TileOverlayOptions();
tileOverlayOptions.tileProvider(tileprovider);
// 将tileovelay加到地图
mAmap.addTileOverlay(tileOverlayOptions);
|
The effect is as follows:
Specific code (replace key) and apk see attachment