search
Homephp教程php手册[Android] Chapter 3 (5) Layer display

[Android] Chapter 3 (5) Layer display

Jul 06, 2016 pm 01:30 PM
androidvsClassificationLayersexhibit

Category: C#, Android, VS2015, Baidu map application; Creation date: 2016-02-04 3.4 Example 4--Layer display 1. Introduction 1. Map type Baidu Map Android SDK 3.7.1 provides two types For map resources (ordinary vector maps and satellite maps), developers can use the MapType attribute (C#) in BaiduMap to set the map type. C

Category: C#, Android, VS2015, Baidu map application; Creation date: 2016-02-04

3.4 Example 4--Layer display

1. Introduction

1. Map type

Baidu Map Android SDK 3.7.1 provides two types of map resources (ordinary vector maps and satellite maps). Developers can use the MapType attribute (C#) in BaiduMap to set the map type. The C# core code is as follows:

mMapView = FindViewById<texturemapview><span style="color: #000000;">(Resource.Id.bmapView);
mBaiduMap </span>=<span style="color: #000000;"> mMapView.Map;
</span><span style="color: #008000;">//</span><span style="color: #008000;">设置底图显示模式:普通地图</span>
mBaiduMap.MapType =<span style="color: #000000;"> BaiduMap.MapTypeNormal;
</span><span style="color: #008000;">//</span><span style="color: #008000;">设置底图显示模式:卫星地图</span>
mBaiduMap.MapType = BaiduMap.MapTypeSatellite;</texturemapview>

2. Real-time traffic map

Currently, real-time traffic query is supported in many cities across the country, and will be launched in other cities gradually.

Which cities currently have real-time traffic maps?

Currently (2016-01-27) 31 cities have been opened, namely 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. Other cities will be opened in the future.

The C# core code to open real-time traffic conditions on the map is as follows:

mMapView = FindViewById<texturemapview><span style="color: #000000;">(Resource.Id.bmapView);
mBaiduMap </span>=<span style="color: #000000;"> mMapView.Map;
</span><span style="color: #008000;">//</span><span style="color: #008000;">开启交通图</span>
mBaiduMap.TrafficEnabled = <span style="color: #0000ff;">true</span>;</texturemapview>

3. Baidu city heat map

After opening up the local drawing capabilities of heat maps to developers, Baidu Map SDK once again further opens up the city heat map layer of Baidu's own data to help developers build more diverse mobile applications.

The nature and use of Baidu City Heat Map is similar to that of real-time traffic map. It only requires simple interface calls to display Baidu City Heat Map with rich styles on the map.

The C# core code to open Baidu city heat map on the map is as follows:

mMapView = FindViewById<texturemapview><span style="color: #000000;">(Resource.Id.bmapView);
mBaiduMap </span>=<span style="color: #000000;"> mMapView.Map;
</span><span style="color: #008000;">//</span><span style="color: #008000;">开启交通图</span>
mBaiduMap.BaiduHeatMapEnabled = <span style="color: #0000ff;">true</span>;</texturemapview>

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

2. Add demo04_layers.axml file

<?xml version=<span style="color: #800000;">"<span style="color: #800000;">1.0</span><span style="color: #800000;">"</span> encoding=<span style="color: #800000;">"</span><span style="color: #800000;">utf-8</span><span style="color: #800000;">"</span>?>
<linearlayout xmlns:android="<span" style="color: #800000;">"<span style="color: #800000;">http://schemas.android.com/apk/res/android</span><span style="color: #800000;">"</span><span style="color: #000000;">
    android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">fill_parent</span><span style="color: #800000;">"</span><span style="color: #000000;">
    android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">fill_parent</span><span style="color: #800000;">"</span><span style="color: #000000;">
    android:orientation</span>=<span style="color: #800000;">"</span><span style="color: #800000;">vertical</span><span style="color: #800000;">"</span> >

    LinearLayout
        android:layout_width=<span style="color: #800000;">"</span><span style="color: #800000;">fill_parent</span><span style="color: #800000;">"</span><span style="color: #000000;">
        android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
        android:orientation</span>=<span style="color: #800000;">"</span><span style="color: #800000;">horizontal</span><span style="color: #800000;">"</span> >

        RadioGroup
            android:id=<span style="color: #800000;">"</span><span style="color: #800000;">@+id/RadioGroup</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_weight</span>=<span style="color: #800000;">"</span><span style="color: #800000;">2</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:orientation</span>=<span style="color: #800000;">"</span><span style="color: #800000;">horizontal</span><span style="color: #800000;">"</span> >

            RadioButton
                android:id=<span style="color: #800000;">"</span><span style="color: #800000;">@+id/normal</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:layout_weight</span>=<span style="color: #800000;">"</span><span style="color: #800000;">1</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:</span><span style="color: #0000ff;">checked</span>=<span style="color: #800000;">"</span><span style="color: #800000;">true</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:text</span>=<span style="color: #800000;">"</span><span style="color: #800000;">普通图</span><span style="color: #800000;">"</span> />

            RadioButton
                android:id=<span style="color: #800000;">"</span><span style="color: #800000;">@+id/statellite</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:layout_weight</span>=<span style="color: #800000;">"</span><span style="color: #800000;">1</span><span style="color: #800000;">"</span><span style="color: #000000;">
                android:text</span>=<span style="color: #800000;">"</span><span style="color: #800000;">卫星图</span><span style="color: #800000;">"</span> />
        

        CheckBox
            android:id=<span style="color: #800000;">"</span><span style="color: #800000;">@+id/traffice</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_weight</span>=<span style="color: #800000;">"</span><span style="color: #800000;">1</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:</span><span style="color: #0000ff;">checked</span>=<span style="color: #800000;">"</span><span style="color: #800000;">false</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:text</span>=<span style="color: #800000;">"</span><span style="color: #800000;">交通图</span><span style="color: #800000;">"</span> />
         
         CheckBox
            android:id=<span style="color: #800000;">"</span><span style="color: #800000;">@+id/baiduHeatMap</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">wrap_content</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:layout_weight</span>=<span style="color: #800000;">"</span><span style="color: #800000;">1</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:</span><span style="color: #0000ff;">checked</span>=<span style="color: #800000;">"</span><span style="color: #800000;">false</span><span style="color: #800000;">"</span><span style="color: #000000;">
            android:text</span>=<span style="color: #800000;">"</span><span style="color: #800000;">百度城市热力图</span><span style="color: #800000;">"</span> />
    </linearlayout>

    com.baidu.mapapi.map.TextureMapView
        android:id=<span style="color: #800000;">"</span><span style="color: #800000;">@+id/bmapView</span><span style="color: #800000;">"</span><span style="color: #000000;">
        android:layout_width</span>=<span style="color: #800000;">"</span><span style="color: #800000;">fill_parent</span><span style="color: #800000;">"</span><span style="color: #000000;">
        android:layout_height</span>=<span style="color: #800000;">"</span><span style="color: #800000;">fill_parent</span><span style="color: #800000;">"</span><span style="color: #000000;">
        android:clickable</span>=<span style="color: #800000;">"</span><span style="color: #800000;">true</span><span style="color: #800000;">"</span> />

2. Add the Demo04Layers.cs file

Add this file under the SrcSdkDemos folder.

<span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.App;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Content.PM;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.OS;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Android.Widget;
</span><span style="color: #0000ff;">using</span><span style="color: #000000;"> Com.Baidu.Mapapi.Map;

</span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> BdMapV371Demos.SrcSdkDemos
{
    </span><span style="color: #808080;">///</span> <span style="color: #808080;"><summary></summary></span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 演示地图图层显示的控制方法
    </span><span style="color: #808080;">///</span> <span style="color: #808080;"></span>
    [Activity(Label = <span style="color: #800000;">"</span><span style="color: #800000;">@string/demo_name_layers</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        ConfigurationChanges </span>= ConfigChanges.Orientation |<span style="color: #000000;"> ConfigChanges.KeyboardHidden,
        ScreenOrientation </span>=<span style="color: #000000;"> ScreenOrientation.Sensor)]
    </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> Demo04Layers : Activity
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">TextureMapView 是地图主控件</span>
        <span style="color: #0000ff;">PRivate</span><span style="color: #000000;"> TextureMapView mMapView;
        </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> BaiduMap mBaiduMap;

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnCreate(Bundle savedInstanceState)
        {
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.demo04_layers);

            mMapView </span>= FindViewById<texturemapview><span style="color: #000000;">(Resource.Id.bmapView);
            mBaiduMap </span>=<span style="color: #000000;"> mMapView.Map;
            mBaiduMap.SetMapStatus(MapStatusUpdateFactory.NewLatLng(MainActivity.HeNanUniversity));

            </span><span style="color: #008000;">//</span><span style="color: #008000;">设置底图显示模式:普通图</span>
            <span style="color: #0000ff;">var</span> normal = FindViewById<radiobutton><span style="color: #000000;">(Resource.Id.normal);
            normal.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                mBaiduMap.MapType </span>=<span style="color: #000000;"> BaiduMap.MapTypeNormal;
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">设置底图显示模式:卫星图</span>
            <span style="color: #0000ff;">var</span> statellite = FindViewById<radiobutton><span style="color: #000000;">(Resource.Id.statellite);
            statellite.Click </span>+= <span style="color: #0000ff;">delegate</span><span style="color: #000000;">
            {
                mBaiduMap.MapType </span>=<span style="color: #000000;"> BaiduMap.MapTypeSatellite;
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">是否显示交通图</span>
            <span style="color: #0000ff;">var</span> traffice = FindViewById<checkbox><span style="color: #000000;">(Resource.Id.traffice);
            traffice.CheckedChange </span>+= (s, e) =><span style="color: #000000;">
            {
                mBaiduMap.TrafficEnabled </span>=<span style="color: #000000;"> e.IsChecked;
            };

            </span><span style="color: #008000;">//</span><span style="color: #008000;">是否显示热力图</span>
            <span style="color: #0000ff;">var</span> baiduHeatMap = FindViewById<checkbox><span style="color: #000000;">(Resource.Id.baiduHeatMap);
            traffice.CheckedChange </span>+= (s, e) =><span style="color: #000000;">
            {
                mBaiduMap.BaiduHeatMapEnabled </span>=<span style="color: #000000;"> e.IsChecked;
            };
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnPause()
        {
            mMapView.OnPause();
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnPause();
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnResume()
        {
            mMapView.OnResume();
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnResume();
        }

        </span><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> OnDestroy()
        {
            mMapView.OnDestroy();
            </span><span style="color: #0000ff;">base</span><span style="color: #000000;">.OnDestroy();
        }
    }
}</span></checkbox></checkbox></radiobutton></radiobutton></texturemapview>

4. Modify the MainActivity.cs file

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

<span style="color: #008000;">          //</span><span style="color: #008000;">示例4--图层展示</span>
            <span style="color: #0000ff;">new</span> DemoInfo<activity><span style="color: #000000;">(Resource.String.demo_title_layers,
                Resource.String.demo_desc_layers,
                </span><span style="color: #0000ff;">new</span> Demo04Layers()),</activity>

Run.


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software