German Android SDK 2d map Zoomlevel bug a solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.