BaiduMap---百度地图官方Demo之多地图展示(在一个Activity中创建多个地图展示)
2015-07-01 17:20
441 查看
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="5dp" android:layout_weight="1" android:orientation="horizontal" > <fragment android:id="@+id/map1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginRight="5dp" android:layout_weight="1" class="com.baidu.mapapi.map.SupportMapFragment" /> <fragment android:id="@+id/map2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" class="com.baidu.mapapi.map.SupportMapFragment" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" > <fragment android:id="@+id/map3" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginRight="5dp" android:layout_weight="1" class="com.baidu.mapapi.map.SupportMapFragment" /> <fragment android:id="@+id/map4" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" class="com.baidu.mapapi.map.SupportMapFragment" /> </LinearLayout> </LinearLayout>
/** * 在一个Activity中创建多个地图展示 */ public class MultiMapViewDemo extends FragmentActivity { private static final LatLng GEO_BEIJING = new LatLng(39.945, 116.404); private static final LatLng GEO_SHANGHAI = new LatLng(31.227, 121.481); private static final LatLng GEO_GUANGZHOU = new LatLng(23.155, 113.264); private static final LatLng GEO_SHENGZHENG = new LatLng(22.560, 114.064); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_multimap); initMap(); } /** * 初始化Map */ private void initMap() { /** * MapStatusUpdate:描述地图状态将要发生的变化 * newLatLng(LatLng latLng):设置地图新中心点 * */ MapStatusUpdate u1 = MapStatusUpdateFactory.newLatLng(GEO_BEIJING); SupportMapFragment map1 = (SupportMapFragment) (getSupportFragmentManager() .findFragmentById(R.id.map1)); /** * getBaiduMap():获取百度地图控制器,当执行完 onCreateView函数之后调用,否则返回 null. * BaiduMap.setMapStatus(MapStatusUpdate update):改变地图状态 * */ map1.getBaiduMap().setMapStatus(u1); MapStatusUpdate u2 = MapStatusUpdateFactory.newLatLng(GEO_SHANGHAI); SupportMapFragment map2 = (SupportMapFragment) (getSupportFragmentManager() .findFragmentById(R.id.map2)); map2.getBaiduMap().setMapStatus(u2); MapStatusUpdate u3 = MapStatusUpdateFactory.newLatLng(GEO_GUANGZHOU); SupportMapFragment map3 = (SupportMapFragment) (getSupportFragmentManager() .findFragmentById(R.id.map3)); map3.getBaiduMap().setMapStatus(u3); MapStatusUpdate u4 = MapStatusUpdateFactory.newLatLng(GEO_SHENGZHENG); SupportMapFragment map4 = (SupportMapFragment) (getSupportFragmentManager() .findFragmentById(R.id.map4)); map4.getBaiduMap().setMapStatus(u4); } }
相关文章推荐
- BaiduMap---百度地图官方Demo之MapFragment使用(创建一个基于Fragment的地图框架)
- BaiduMap---百度地图官方Demo之基本地图功能(创建一张百度地图并管理地图的生命周期)
- Rails应用开发点滴
- SAP BW – Implementing Delta Updates in the Financial Domain
- BaiduMap---百度地图官方Demo
- leetcode Submission Details
- Obtain Diesel engine Designer watches can be bought in the many most up-to-date styles and designs
- svn:cleanup failed previous operation has not finished; run cleanup if it was interrupted
- svn:cleanup failed previous operation has not finished; run cleanup if it was interrupted
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误 [转]
- xcode6错误提醒:Failed to code sign "某某Tests".
- svn cleanup failed-previous operation has not finished; run cleanup if it was interrupted
- Matrix-chain product 矩阵链乘积
- main函数总结
- 扎克伯格:我们为何要研究人工智能和虚拟现实
- 扎克伯格:我们为什么要研究人工智能与虚拟现实?
- 03-树3. Tree Traversals Again (25)
- Leetcode_num13_Climbing Stairs
- centos7解决django.db.utils.OperationalError: FATAL: Peer authentication failed for user "postgres"
- lucene报错Lock obtain timed out: