Category: C #, Android; Date: 2016-02-04
3.2 Example 2--basic map function One, introduction
1. Map
Map shows: General maps (2D,3D), satellite maps, and real-time traffic maps.
Map operation: Through the interface or gesture control to achieve the map click, double-click, long-Press, zoom, pan, rotate, change the perspective and other operations.
2. Map type
Baidu Maps Android SDK 3.6.1 provides two types of map resources (normal vector map and satellite map, see DEMO04), if you do not specify a map type, the default is normal vector map.
This example demonstrates only the basic usage of normal vector diagrams.
3. This example features a description
This example shows how to build a basic map page and shows how to display a map of Baidu centered on a custom latitude and longitude coordinate.
Summary: Create a map of Baidu and manage the life cycle of the map.
Detailed:
(1) Create one of the simplest Baidu maps;
(2) Manage the life cycle of the map, see the relevant comments in the Code section for details;
(3) Can monitor the map loading complete event;
4. This example runs
The effect of running in the x86 simulator is as follows:
Second, the design steps
1. Add Demo02BaseMap.cs File
Add a Srcsdkdemos folder to your project, and then add the file under that folder.
usingAndroid.app;usingAndroid.Content.PM;usingAndroid.os;usingCom.Baidu.Mapapi.Map;namespacebdmapv371demos.srcsdkdemos{[Activity (Label="@string/demo_name_basemap", Configurationchanges= Configchanges.orientation |Configchanges.keyboardhidden, Screenorientation=screenorientation.sensor)] Public classdemo02basemap:activity {PrivateTexturemapview Mmapview; protected Override voidOnCreate (Bundle savedinstancestate) {Base. OnCreate (savedinstancestate); Mmapview=NewTexturemapview ( This, NewBaidumapoptions (). Mapstatus (NewMapstatus.builder (). Target (mainactivity.henanuniversity). Build ())); Setcontentview (Mmapview); } protected Override voidOnPause () {Base. OnPause (); Mmapview.onpause (); } protected Override voidOnresume () {Base. Onresume (); Mmapview.onresume (); } protected Override voidOnDestroy () {Base. OnDestroy (); Mmapview.ondestroy (); } }}
2. Modify the MainActivity.cs file
Add the following code in the Demos field definition of the MainActivity.cs file.
Private Static ReadOnly Demoinfo<activity>[] Demos = { ... // example of basic map function New Demoinfo<activity>(Resource.String.demo_title_basemap, Resource.String.demo_desc_basemap, New Demo01basemap ()), }
Run, click "Example 1" in the main interface to observe the results.
The 3rd chapter in C # to write Baidu map Android mobile app (2nd speaking)