Chapter 2 use C # To compile the Baidu map Android mobile app (Lecture 1 ),

Source: Internet
Author: User

Chapter 2 use C # To compile the Baidu map Android mobile app (Lecture 1 ),

Category: C #, Android; date:

3.5 Example 5 -- Multi-map presentation I. Introduction

Map controls start with v2.3.5 and support multiple instances. That is, developers can create multiple map objects on a single page and operate on these objects without interfering with each other.

File Name: Demo04MultiMapView. cs

Introduction: describes the use of multiple mapviews.

Details: create four TextureMapView controls at the same time in one interface;

Ii. Example

1. Run

The Running Effect in the x86 simulator is as follows:

 

Based on the previous example, you only need to add the following steps.

2. Add the demo05_multimap.axml file.

Add the file in the layout folder and change it to the following code:

 

<?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.TextureMapFragment" />        <fragment            android:id="@+id/map2"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:layout_weight="1"            class="com.baidu.mapapi.map.TextureMapFragment" />    </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.TextureMapFragment" />        <fragment            android:id="@+id/map4"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:layout_weight="1"            class="com.baidu.mapapi.map.TextureMapFragment" />    </LinearLayout></LinearLayout>

 

3. Add the Demo05MultiMapView. cs file.

Add the file in the SdkDemos folder and change its content to the following code:

 

Using Android. app; using Android. content. PM; using Android. OS; using Com. baidu. mapapi. map; using Com. baidu. mapapi. model; namespace BdMapV371Demos. srcSdkDemos {// <summary> /// display multiple maps in an Activity /// </summary> [Activity (Label = "@ string/demo_name_multimap ", configurationChanges = ConfigChanges. orientation | ConfigChanges. keyboardHidden, ScreenOrientation = ScreenOrientation. sensor)] public class Demo05MutiMapView: Activity {private readonly LatLng Geo_BeiJing = new LatLng (39.945, 116.404); private readonly LatLng Geo_ShangHai = new LatLng (31.227, 121.481 ); private readonly LatLng Geo_GuangZhou = new LatLng (23.155, 113.264); private readonly LatLng Geo_ShenZhen = new LatLng (22.560, 114.064); protected override void OnCreate (Bundle savedInstanceState) {base. onCreate (savedInstanceState); SetContentView (Resource. layout. demo05_multimap); InitMap () ;}/// <summary >/// initialize Map /// </summary> private void InitMap () {MapStatusUpdate u1 = MapStatusUpdateFactory. newLatLng (Geo_BeiJing); TextureMapFragment map1 = FragmentManager. findFragmentById <TextureMapFragment> (Resource. id. map1); map1.BaiduMap. setMapStatus (u1); MapStatusUpdate u2 = MapStatusUpdateFactory. newLatLng (Geo_ShangHai); TextureMapFragment map2 = FragmentManager. findFragmentById <TextureMapFragment> (Resource. id. map2); map2.BaiduMap. setMapStatus (u2); MapStatusUpdate u3 = MapStatusUpdateFactory. newLatLng (Geo_GuangZhou); TextureMapFragment map3 = FragmentManager. findFragmentById <TextureMapFragment> (Resource. id. map3); map3.BaiduMap. setMapStatus (u3); MapStatusUpdate u4 = MapStatusUpdateFactory. newLatLng (Geo_ShenZhen); TextureMapFragment map4 = FragmentManager. findFragmentById <TextureMapFragment> (Resource. id. map4); map4.BaiduMap. setMapStatus (u4 );}}}

 

4. Modify the MainActivity. cs File

Add the following code to the demos field definition in the MainActivity. cs file.

// Example 5 -- Multi-Map Display new DemoInfo <Activity> (Resource. String. demo_title_multimap, Resource. String. demo_desc_multimap, new Demo05MutiMapView ()),

Run the observation results.

Related Article

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.