Android Baidu Map Application layer display _android

Source: Internet
Author: User

First, Introduction
1. Map type
The Google Maps Android SDK 3.7.1 provides two types of map resources (general vector maps and satellite maps), and developers can use the Maptype attribute (C #) in Baidumap to set the map type. The C # core code is as follows:

Mmapview = findviewbyid<texturemapview> (Resource.Id.bmapView);
Mbaidumap = Mmapview.map;
Set the bottom chart display mode: Ordinary map
mbaidumap.maptype = baidumap.maptypenormal;
Set the bottom chart Display mode: satellite map
mbaidumap.maptype = baidumap.maptypesatellite; 

2. Real-time traffic map
At present, Nationwide has supported a number of urban real-time road traffic inquiries, and will be opened in other cities.
Which cities currently have real-time traffic maps?
At present (2016-01-27), 31 cities have been opened, respectively, Nanjing, Guangzhou, Chongqing, Dongguan, Changchun, Taizhou, Fuzhou, Jinhua, Beijing, Changzhou, Hangzhou, Wenzhou, Dalian, Nanchang, Ningbo, Shenyang, Zhongshan, Zhuhai, Foshan, Quanzhou, Shijiazhuang, Chengdu, Qingdao, Shenzhen, Wuhan, Urumqi, Changsha , Shanghai, Tianjin, Wuxi, Xiamen. After that, other cities will be opened.
The C # core code to open live traffic on the map is as follows:

Mmapview = findviewbyid<texturemapview> (Resource.Id.bmapView);
Mbaidumap = Mmapview.map;
Open Traffic Map

3, Baidu City Heat to try
Baidu Map SDK for the vast number of developers open the hot attempt to draw local ability, once again open Baidu's own data of the city thermal force, to help developers build more diverse forms of mobile applications.
Baidu City Thermal force of the nature and use and real-time traffic map similar, just need to simple interface call, you can show on the map of the rich style of Baidu City thermal map.
The C # core code on the map that opens the Baidu City thermal attempt is as follows:

Mmapview = findviewbyid<texturemapview> (Resource.Id.bmapView);
Mbaidumap = Mmapview.map;
Open Traffic map
mbaidumap.baiduheatmapenabled = true;


On the basis of the example in the previous section, you only need to add the following steps.
1. Add Demo04_layers.axml File

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android= "http://schemas.android.com/apk/res/" Android "Android:layout_width=" Fill_parent "android:layout_height=" fill_parent "android:orientation=" vertical " > <linearlayout android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android:orien
      tation= "Horizontal" > <radiogroup android:id= "@+id/radiogroup" android:layout_width= "Wrap_content"

      android:layout_height= "Wrap_content" android:layout_weight= "2" android:orientation= "Horizontal" > <radiobutton android:id= "@+id/normal" android:layout_width= "Wrap_content" android:layout_he

      ight= "Wrap_content" android:layout_weight= "1" android:checked= "true" android:text= "normal map"/> <radiobutton android:id= "@+id/statellite" android:layout_width= "Wrap_content" android:layout _height= "Wrap_content" Android: layout_weight= "1" android:text= "satellite map"/> </RadioGroup> <checkbox android:id= "@+id/traff"
      Ice "android:layout_width=" Wrap_content "android:layout_height=" Wrap_content "android:layout_weight=" 1 "
      Android:checked= "false" android:text= "traffic map"/> <checkbox android:id= "@+id/baiduheatmap"
      Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_weight= "1" Android:checked= "false" android:text= "Baidu City Hot Try"/> </LinearLayout> <com.baidu.mapapi.map.texturemap View android:id= "@+id/bmapview" android:layout_width= "fill_parent" android:layout_height= "Fill_parent" and

 Roid:clickable= "true"/> </LinearLayout>

2. Add Demo04Layers.cs file
Add the file under the Srcsdkdemos folder.

Using Android.app;
Using Android.Content.PM;
Using Android.os;
Using Android.widget;

Using Com.Baidu.Mapapi.Map; namespace Bdmapv371demos.srcsdkdemos {///<summary>///demo Map Layer Display control method///</summary> [Activity (Label = "@string/demo_name_layers", configurationchanges = Configchanges.orientation |
  Configchanges.keyboardhidden, screenorientation = screenorientation.sensor)] public class demo04layers:activity
    {//texturemapview is the main map control private Texturemapview Mmapview;

    Private Baidumap Mbaidumap; protected override void OnCreate (Bundle savedinstancestate) {base.
      OnCreate (savedinstancestate);

      Setcontentview (Resource.Layout.demo04_layers);
      Mmapview = findviewbyid<texturemapview> (Resource.Id.bmapView);
      Mbaidumap = Mmapview.map;

      Mbaidumap.setmapstatus (MAPSTATUSUPDATEFACTORY.NEWLATLNG (mainactivity.henanuniversity)); Set Bottom Chart Display mode: normal figure var normal = findviewbyid<radiobutton> (Resource.Id.normaL); Normal.
      Click + = delegate {mbaidumap.maptype = Baidumap.maptypenormal;

      };
      Set the bottom chart Display mode: satellite map var statellite = findviewbyid<radiobutton> (Resource.Id.statellite); Statellite.
      Click + = delegate {mbaidumap.maptype = Baidumap.maptypesatellite;

      };
      Whether to show traffic map var traffice = findviewbyid<checkbox> (Resource.Id.traffice); Traffice.
      Checkedchange + = (s, e) => {mbaidumap.trafficenabled = e.ischecked;

      };
      Whether to show the thermodynamic diagram var baiduheatmap = findviewbyid<checkbox> (RESOURCE.ID.BAIDUHEATMAP); Traffice.
      Checkedchange + = (s, e) => {mbaidumap.baiduheatmapenabled = e.ischecked;
    };
      } protected override void OnPause () {mmapview.onpause (); Base.
    OnPause ();
      } protected override void Onresume () {mmapview.onresume (); Base.
    Onresume (); } protected override void OnDestroy () {Mmapview.ondesTroy (); Base.
    OnDestroy ();

 }
  }
}

4. Modify MainActivity.cs File
Add the following code to the Demos field definition of the MainActivity.cs file.

     Example 4--layer shows
      the new demoinfo<activity> (Resource.String.demo_title_layers,
        Resource.String.demo_desc_ Layers,
        new demo04layers ()),

Run.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.