zoukankan      html  css  js  c++  java
  • 关于地图初始化的一些尝试与疑问

      MapView类提供了许多初始化地图的方法,这里我关注的是初始化的时候设置地图的缩放级别、比例尺、中心点(加载进地图容器的地图会以这个点为中心)。

      centerAndZoom(double lat, double lon, float levelOrFactor)    以经纬度和缩放级别设置地图,经纬度设置中心有效果,缩放级别无效果,此处为我遇到的问题,求大家解惑

      If the MapView is initialized, centers the map at the given latitude and longitude and zoom the map based on the given factor. 
      centerAt(double lat, double lon, boolean animated)  以经纬度点设置地图 有效
      If the MapView is initialized, centers the map at the given latitude and longitude; optionally, the change is animated.
      centerAt(Point centerPt, boolean animated)  以投影坐标系的点设置地图 有效
      If the MapView is initialized, centers the map at the given point; optionally, the change is animated.
      zoomTo(Point centerPt, float factor) 以投影坐标系的点、缩放级别设置地图,有效
      If the MapView is initialized, zooms the map by a factor to the given center point.
      zoomToScale(Point centerPt, double scale) 以投影坐标系的点和比例尺设置地图 有效
      Centers the map on the given point and zoom into the given scale level.
      setScale(double scale) 以比例尺设置地图 有效
      Sets the map scale.
      
      If the MapView is initialized,假如mapview被初始化成果,上述对地图的设置只有在mapview初始化完毕之后才会进行,所以放在onCreate方法中执行是无效的,因为mapview还未来得及初始化完毕,所以可以放在onStatusChangedListener中,如下代码
      
            mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
                
                @Override
                public void onStatusChanged(Object arg0, STATUS status) {
                    // TODO Auto-generated method stub
                    if(status.equals(STATUS.INITIALIZATION_FAILED)){
                        Toast.makeText(getApplicationContext(), "初始化失败", Toast.LENGTH_SHORT).show();        
                    }
                    if(status.equals(STATUS.INITIALIZED)){
                        Toast.makeText(getApplicationContext(), "初始化完成", Toast.LENGTH_SHORT).show();
                        mapView.zoomTo(centenPoint, 5);//根据平面坐标与缩放级别来设置地图,有效果
    //                    mapView.zoomToScale(centenPoint, 10000000);//根据平面坐标与比例尺设置地图,有效果
    //                    mapView.setScale(100000000);//根据比例尺设置地图,有效果
    //                    mapView.centerAndZoom(39.8, 116.38, 15);//根据经纬度,缩放级别设置地图,经纬度有效果,级别无效果
    //                    mapView.centerAt(80, 150, false);//根据经纬度设置地图,有效果
    //                    mapView.centerAt(centenPoint,false);//根据平面坐标设置地图,有效果
                        
                        
                    }
                    if(status.equals(STATUS.LAYER_LOADED)){
                        Toast.makeText(getApplicationContext(), "图层加载完成", Toast.LENGTH_SHORT).show();
                        //mapView.centerAndZoom(39.8, 116.38, 3);
                    }
                    if(status.equals(STATUS.LAYER_LOADING_FAILED)){
                        Toast.makeText(getApplicationContext(), "图层加载失败", Toast.LENGTH_SHORT).show();
                    }
                }
            });
  • 相关阅读:
    性能问题分析-OOM内存溢出
    JVM介绍及参数配置
    性能问题分析-CPU偏高
    性能测试常见术语浅析
    性能测试中TPS上不去的几种原因浅析
    MyBatis拦截器:给参数对象属性赋值
    springboot读取配置文件的顺序
    ElasticSearch中文分词
    springboot和ELK搭建配置详情
    java命令行介绍
  • 原文地址:https://www.cnblogs.com/cnugis/p/5299686.html
Copyright © 2011-2022 走看看