关于地图初始化的一些尝试与疑问
2016-03-20 21:17
211 查看
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中,如下代码
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(); } } });
相关文章推荐
- 猎豹MFC--MiNiMS管理系统2增加修改数据库
- 程序员对产品的思考暨项目总结:一品茶香
- 寻找第k小的数字
- No.4小白的HTML+CSS心得篇
- 2.0-创建快照
- css实现垂直水平居中
- HttpHandler与HttpModule的用处与区别
- HTTP 错误 404.17 - Not Found
- Spark生态系统项目
- Silicon Lab Ember zigbee学习杂谈---zcl frame解析
- poj2823线段树
- 47. Permutations II | Java最短代码实现
- 汇编学习1
- 类指针
- spring学习笔记(8)AOP增强(advice)配置与应用
- [c++]链表实现--持续更。
- selenium在Eclipse中打开fireFox浏览器是报报错connect to host 127.0.0.1 on port 7055
- 重学STM32----(一)
- BZOJ_P1857 [SCOI2010]传送带(三分套三分)
- 1.9-kvm克隆