分類:C#、Android、VS201五、百度地圖應用; 建立日期:2016-02-04node
一、展現全景圖的方式git
有如下展現全景圖的辦法:json
(1)利用地理座標展現全景圖。api
(2)利用全景圖ID展現全景圖。ide
(3)利用墨卡託座標展現全景圖。函數
(4)利用地圖POI ID展現全景圖。工具
經過以上方式,就可使用百度提供的全景圖展現服務了。佈局
二、座標轉換測試
爲了更方便的獲取全景圖,SDK還提供了座標轉化工具,利用CoordinateConverter 工具中的方法能夠很方便進行座標轉換。ui
三、全景圖控制
用戶能夠利用手勢或者接口對全景圖實現豐富的操做。手勢操做包括:雙指縮放、單指拖動、點擊鄰接街景箭頭。
接口操做包括:改變當前全景圖的俯仰角,偏航角以及縮放級別,設置是否顯示鄰接箭頭(若是有鄰接街景的狀況)。
四、全景圖覆蓋物
百度SDK支持在全景圖內繪製開發者自定義的標註,同時針對所繪製的標註,還支持相應的點擊事件響應。目前支持圖片和文本兩種覆蓋物。
2.0.0版本支持設置覆蓋物的高度,經過SetPitchHeight(float height)設置覆蓋物距離地面的高度(單位m)。
五、內景相冊
2.2版本將內景相冊的實現封裝爲內景相冊插件,如需植入內景,只需導入內景相冊插件包(IndoorscapeAlbumPlugin.jar),並經過以下一行代碼便可快速完成顯示內景相冊。
本示例的運行截圖以下:
一、添加布局文件
須要在layout文件夾下添加的佈局文件有(代碼太多,再也不粘貼到此處):
demo20_panodemo.xml
demo20_panodemo_coordinate.xml
demo20_panodemo_list_item.xml
demo20_panodemo_main.xml
二、添加Demo20PanoActivity.cs文件
在SrcSdkDemos文件夾下添加該文件,而後將其內容改成下面的代碼:
using Android.App; using Android.Content; using Android.OS; using Android.Views; using Android.Widget; namespace BdMapV371Demos.SrcSdkDemos { [Activity(Label = "@string/demo_name_panorama")] public class Demo20PanoActivity : Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.demo20_panodemo); ListView mListView = FindViewById<ListView>(Resource.Id.panodemo_list); mListView.Adapter = new DemoListAdapter(this); mListView.ItemClick += (s, e) => { Intent intent = new Intent(this, panoDemos[e.Position].demoClass.GetType()); intent.PutExtra("type", (int)panoDemos[e.Position].type); StartActivity(intent); }; } private static readonly DemoInfo<Activity>[] panoDemos = { new DemoInfo<Activity>(PanoDemoType.PID, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama0, new Demo20PanoMain()), new DemoInfo<Activity>(PanoDemoType.Geo, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama1, new Demo20PanoMain()), new DemoInfo<Activity>(PanoDemoType.Mercator, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama2, new Demo20PanoMain()), new DemoInfo<Activity>(PanoDemoType.UIDStreet, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama3, new Demo20PanoMain()), new DemoInfo<Activity>(PanoDemoType.UIDInterior, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama4, new Demo20PanoMain()), new DemoInfo<Activity>(PanoDemoType.Marker, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama5, new Demo20PanoMain()), new DemoInfo<Activity>(PanoDemoType.CoordinateConverter, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama6, new Demo20PanoCoordinate()), new DemoInfo<Activity>(PanoDemoType.Other, Resource.String.demo_title_panorama, Resource.String.demo_desc_panorama7, new Demo20PanoMain()) }; private class DemoListAdapter : BaseAdapter { Demo20PanoActivity demo20; public DemoListAdapter(Demo20PanoActivity demo20) : base() { this.demo20 = demo20; } public override View GetView(int index, View convertView, ViewGroup parent) { convertView = View.Inflate(demo20, Resource.Layout.demo20_panodemo_list_item, null); TextView title = convertView.FindViewById<TextView>(Resource.Id.item_title); TextView desc = convertView.FindViewById<TextView>(Resource.Id.item_desc); title.SetText(panoDemos[index].title); desc.SetText(panoDemos[index].desc); return convertView; } public override int Count { get { return panoDemos.Length; } } public override Java.Lang.Object GetItem(int index) { return panoDemos[index]; } public override long GetItemId(int id) { return id; } } private class DemoInfo<T> : Java.Lang.Object where T : Activity { public readonly int title; public readonly int desc; public readonly PanoDemoType type; public readonly T demoClass; public DemoInfo(PanoDemoType type, int title, int desc, T demoClass) { this.type = type; this.title = title; this.desc = desc; this.demoClass = demoClass; } } } public enum PanoDemoType { /// <summary>PID方式</summary> PID = 0, /// <summary>經緯度方式</summary> Geo, /// <summary>墨卡託方式</summary> Mercator, /// <summary>UID方式展現外景</summary> UIDStreet, /// <summary>UID方式展現內景</summary> UIDInterior, /// <summary>標註</summary> Marker, /// <summary>座標轉換測試</summary> CoordinateConverter, /// <summary>其餘測試</summary> Other } }
三、Demo20PanoMain.cs文件
在SrcSdkDemos文件夾下添加該文件,而後將其內容改成下面的代碼:
using Android.App; using Android.Content.PM; using Android.OS; using Android.Widget; using Com.Baidu.Lbsapi.Panoramaview; using Com.Baidu.Lbsapi; using Android.Views; using Android.Util; using System.Threading.Tasks; using Com.Baidu.Lbsapi.Model; using Com.Baidu.Lbsapi.Tools; using Android.Content; namespace BdMapV371Demos.SrcSdkDemos { /// <summary> /// 全景Demo主Activity /// </summary> [Activity(Label = "@string/demo_name_panorama", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden, ScreenOrientation = ScreenOrientation.Sensor)] public class Demo20PanoMain : Activity, IMKGeneralListener { private BMapManager mBMapManager; private PanoramaView mPanoView; private TextView textTitle; private Button btnImageMarker, btnTextMarker;// 添加移除marker測試 private Button btnIsShowArrow, btnArrowStyle01, btnArrowStyle02;// 全景其餘功能測試 private Button btnIsShowInoorAblum; private View seekPitchLayout, seekHeadingLayout, seekLevelLayout; private SeekBar seekPitch, seekHeading, seekLevel;// 俯仰角,偏航角,全景圖縮放測試 private bool isAddImageMarker = false; private bool isAddTextMarker = false; private bool isShowArrow = false; private bool isShowAblum = true; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mBMapManager = new BMapManager(ApplicationContext); mBMapManager.Init(this); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.demo20_panodemo_main); InitView(); TestPanoByType(Intent.GetIntExtra("type", -1)); } private void InitView() { textTitle = FindViewById<TextView>(Resource.Id.panodemo_main_title); mPanoView = FindViewById<PanoramaView>(Resource.Id.panorama); btnImageMarker = FindViewById<Button>(Resource.Id.panodemo_main_btn_imagemarker); btnTextMarker = FindViewById<Button>(Resource.Id.panodemo_main_btn_textmarker); btnIsShowArrow = FindViewById<Button>(Resource.Id.panodemo_main_btn_showarrow); btnArrowStyle01 = FindViewById<Button>(Resource.Id.panodemo_main_btn_arrowstyle_01); btnArrowStyle02 = FindViewById<Button>(Resource.Id.panodemo_main_btn_arrowstyle_02); btnIsShowInoorAblum = FindViewById<Button>(Resource.Id.panodemo_main_btn_indoor_album); btnImageMarker.Click += delegate { if (!isAddImageMarker) { AddImageMarker(); btnImageMarker.Text = "刪除圖片標註"; } else { RemoveImageMarker(); btnImageMarker.Text = "添加圖片標註"; } isAddImageMarker = !isAddImageMarker; }; btnTextMarker.Click += delegate { if (!isAddTextMarker) { AddTextMarker(); btnTextMarker.Text = "刪除文字標註"; } else { RemoveTextMarker(); btnTextMarker.Text = "添加文字標註"; } isAddTextMarker = !isAddTextMarker; }; seekPitchLayout = FindViewById(Resource.Id.seekpitch_ly); seekHeadingLayout = FindViewById(Resource.Id.seekheading_ly); seekLevelLayout = FindViewById(Resource.Id.seeklevel_ly); seekPitch = FindViewById<SeekBar>(Resource.Id.seekpitch); seekLevel = FindViewById<SeekBar>(Resource.Id.seeklevel); seekHeading = FindViewById<SeekBar>(Resource.Id.seekheading); //seekPitch.StopTrackingTouch += (s, e) =>{ }; //seekPitch.StartTrackingTouch += (s, e) => { }; seekPitch.ProgressChanged += (s, e) => { mPanoView.PanoramaPitch = e.Progress - 90; }; //seekHeading.StopTrackingTouch += (s, e) => { }; //seekHeading.StartTrackingTouch += (s, e) => { }; seekHeading.ProgressChanged += (s, e) => { mPanoView.PanoramaHeading = e.Progress; }; //seekLevel.StopTrackingTouch += (s, e) => { }; //seekLevel.StartTrackingTouch += (s, e) => { }; seekLevel.ProgressChanged += (s, e) => { mPanoView.SetPanoramaZoomLevel(e.Progress + 1); }; } private void TestPanoByType(int type) { mPanoView.SetShowTopoLink(true); HideMarkerButton(); HideSeekLayout(); HideOtherLayout(); HideIndoorAblumLayout(); // 測試回調函數,須要注意的是回調函數要在setPanorama()以前調用,不然回調函數可能執行異常 mPanoView.LoadPanoramaBegin += (s, e) => { Log.Debug("Demo20PanoMain", "onLoadPanoramaStart..."); }; mPanoView.LoadPanoramaEnd += (s, e) => { var json = e.P0; Log.Debug("Demo20PanoMain", "onLoadPanoramaEnd : " + json); }; mPanoView.LoadPanoramaError += (s, e) => { var error = e.P0; Log.Debug("Demo20PanoMain", "onLoadPanoramaError : " + error); }; switch (type) { case (int)PanoDemoType.PID: { textTitle.SetText(Resource.String.demo_desc_panorama0); mPanoView.SetPanoramaImageLevel(PanoramaView.ImageDefinition.ImageDefinitionHigh); string pid = "0900220000141205144547300IN"; mPanoView.SetPanorama(pid); } break; case (int)PanoDemoType.Geo: { textTitle.SetText(Resource.String.demo_desc_panorama1); double lat = 39.945; double lon = 116.404; mPanoView.SetPanorama(lon, lat); } break; case (int)PanoDemoType.Mercator: { textTitle.SetText(Resource.String.demo_desc_panorama2); mPanoView.SetPanoramaImageLevel(PanoramaView.ImageDefinition.ImageDefinitionHigh); int mcX = 12971348; int mcY = 4826239; mPanoView.SetPanorama(mcX, mcY); } break; case (int)PanoDemoType.UIDStreet: { textTitle.SetText(Resource.String.demo_desc_panorama3); mPanoView.SetPanoramaZoomLevel(5); mPanoView.SetArrowTextureByUrl("http://d.lanrentuku.com/down/png/0907/system-cd-disk/arrow-up.png"); mPanoView.SetPanoramaImageLevel(PanoramaView.ImageDefinition.ImageDefinitionMiddle); string uid = "bff8fa7deabc06b9c9213da4"; mPanoView.SetPanoramaByUid(uid, PanoramaView.PanotypeStreet); } break; case (int)PanoDemoType.UIDInterior: { textTitle.SetText(Resource.String.demo_desc_panorama4); ShowIndoorAblumLayout(); mPanoView.SetPanoramaByUid("7c5e480b109e67adacb22aae", PanoramaView.PanotypeInterior); btnIsShowInoorAblum.Click += delegate { if (!isShowAblum) { btnIsShowInoorAblum.Text = "隱藏內景相冊"; mPanoView.SetIndoorAlbumVisible(); } else { btnIsShowInoorAblum.Text = "顯示內景相冊"; mPanoView.SetIndoorAlbumGone(); } isShowAblum = !isShowAblum; }; } break; case (int)PanoDemoType.Marker: { textTitle.SetText(Resource.String.demo_desc_panorama5); showMarkerButton(); mPanoView.SetPanorama("0900220001150514054806738T5"); mPanoView.SetShowTopoLink(false); } break; case (int)PanoDemoType.Other: { textTitle.SetText(Resource.String.demo_desc_panorama7); ShowSeekLayout(); ShowOtherLayout(); mPanoView.SetPanoramaImageLevel(PanoramaView.ImageDefinition.ImageDefinitionHigh); string pid = "0900220001150514054806738T5"; mPanoView.SetPanorama(pid); // 測試獲取內景的相冊描述信息和服務推薦描述信息 TestPanoramaRequest(); btnIsShowArrow.Click += delegate { if (!isShowArrow) { mPanoView.SetShowTopoLink(false); btnIsShowArrow.Text = "顯示全景箭頭"; } else { mPanoView.SetShowTopoLink(true); btnIsShowArrow.Text = "隱藏全景箭頭"; } isShowArrow = !isShowArrow; }; btnArrowStyle01.Click += delegate { mPanoView.SetArrowTextureByUrl("http://d.lanrentuku.com/down/png/0907/system-cd-disk/arrow-up.png"); }; btnArrowStyle02.Click += delegate { Android.Graphics.Bitmap bitmap = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.street_arrow); mPanoView.SetArrowTextureByBitmap(bitmap); }; } break; }//end switch } private void TestPanoramaRequest() { string LTAG = "Demo20PanoMain"; Task.Run(() => { PanoramaRequest panoramaRequest = PanoramaRequest.GetInstance(this); string pid = "01002200001307201550572285B"; Log.Error(LTAG, "PanoramaRecommendInfo"); Log.Info(LTAG, panoramaRequest.GetPanoramaRecommendInfo(pid)); string iid = "978602fdf6c5856bddee8b62"; Log.Error(LTAG, "PanoramaByIIdWithJson"); Log.Info(LTAG, panoramaRequest.GetPanoramaByIIdWithJson(iid)); // 經過百度經緯度座標獲取當前位置相關全景信息,包括是否有外景,外景PID,外景名稱等 double lat = 40.029233; double lon = 116.32085; BaiduPanoData mPanoDataWithLatLon = panoramaRequest.GetPanoramaInfoByLatLon(lon, lat); Log.Error(LTAG, "PanoDataWithLatLon"); Log.Info(LTAG, mPanoDataWithLatLon.Description); // 經過百度墨卡託座標獲取當前位置相關全景信息,包括是否有外景,外景PID,外景名稱等 int x = 12948920; int y = 4842480; BaiduPanoData mPanoDataWithXy = panoramaRequest.GetPanoramaInfoByMercator(x, y); Log.Error(LTAG, "PanoDataWithXy"); Log.Info(LTAG, mPanoDataWithXy.Description); // 經過百度地圖uid獲取該poi下的全景描述信息,以此來判斷此UID下是否有內景及外景 string uid = "bff8fa7deabc06b9c9213da4"; BaiduPoiPanoData poiPanoData = panoramaRequest.GetPanoramaInfoByUid(uid); Log.Error(LTAG, "poiPanoData"); Log.Info(LTAG, poiPanoData.Description); }); } // 隱藏添加刪除標註按鈕 private void HideMarkerButton() { btnImageMarker.Visibility = ViewStates.Gone; btnTextMarker.Visibility = ViewStates.Gone; } // 顯示添加刪除標註按鈕 private void showMarkerButton() { btnImageMarker.Visibility = ViewStates.Visible; btnTextMarker.Visibility = ViewStates.Visible; } // 隱藏設置俯仰角偏航角SeekBar private void HideSeekLayout() { seekPitchLayout.Visibility = ViewStates.Gone; seekHeadingLayout.Visibility = ViewStates.Gone; seekLevelLayout.Visibility = ViewStates.Gone; } // 顯示設置俯仰角偏航角SeekBar private void ShowSeekLayout() { seekPitchLayout.Visibility = ViewStates.Visible; seekHeadingLayout.Visibility = ViewStates.Visible; seekLevelLayout.Visibility = ViewStates.Visible; } // 隱藏其餘功能測試 private void HideOtherLayout() { btnIsShowArrow.Visibility = ViewStates.Gone; btnArrowStyle01.Visibility = ViewStates.Gone; btnArrowStyle02.Visibility = ViewStates.Gone; } // 顯示其餘功能測試 private void ShowOtherLayout() { btnIsShowArrow.Visibility = ViewStates.Visible; btnArrowStyle01.Visibility = ViewStates.Visible; btnArrowStyle02.Visibility = ViewStates.Visible; } // 隱藏內景相冊測試 private void HideIndoorAblumLayout() { btnIsShowInoorAblum.Visibility = ViewStates.Gone; } // 顯示內景相冊測試 private void ShowIndoorAblumLayout() { btnIsShowInoorAblum.Visibility = ViewStates.Visible; } private ImageMarker marker1; private ImageMarker marker2; /// <summary> /// 添加圖片標註 /// </summary> private void AddImageMarker() { // 天安門西南方向 marker1 = new ImageMarker(); marker1.SetMarkerPosition(new Point(116.356329, 39.890534)); marker1.SetMarkerHeight(2.3f); marker1.SetMarker(Resources.GetDrawable(Resource.Drawable.icon_marka)); marker1.TabMark += (s, e) => { Toast.MakeText(this, "圖片MarkerA標註已被點擊", ToastLength.Short).Show(); }; // 天安門東北方向 marker2 = new ImageMarker(); marker2.SetMarkerPosition(new Point(116.427116, 39.929718)); marker2.SetMarker(Resources.GetDrawable(Resource.Drawable.icon_markb)); marker2.SetMarkerHeight(7); marker2.TabMark += (s, e) => { Toast.MakeText(this, "圖片MarkerB標註已被點擊", ToastLength.Short).Show(); }; mPanoView.AddMarker(marker1); mPanoView.AddMarker(marker2); } /// <summary> /// 刪除圖片標註 /// </summary> private void RemoveImageMarker() { mPanoView.RemoveMarker(marker1); mPanoView.RemoveMarker(marker2); } private TextMarker textMark1; private TextMarker textMark2; /// <summary> /// 添加文本標註 /// </summary> private void AddTextMarker() { // 天安門西北方向 textMark1 = new TextMarker(); textMark1.SetMarkerPosition(new Point(116.399562, 39.916789)); textMark1.SetFontColor(Android.Graphics.Color.ParseColor("#FFFF0000").ToArgb()); textMark1.SetText("百度全景百度全景\nmap pano\n你好marker"); textMark1.SetFontSize(12); textMark1.SetBgColor(Android.Graphics.Color.ParseColor("#FFFFFFFF").ToArgb()); textMark1.SetPadding(10, 20, 15, 25); textMark1.SetMarkerHeight(20.3f); textMark1.TabMark += (s, e) => { Toast.MakeText(this, "textMark1標註已被點擊", ToastLength.Short).Show(); }; // 天安門東南方向 textMark2 = new TextMarker(); textMark2.SetMarkerPosition(new Point(116.409766, 39.911808)); textMark2.SetFontColor(Android.Graphics.Color.Red.ToArgb()); textMark2.SetText("你好marker"); textMark2.SetFontSize(12); textMark2.SetBgColor(Android.Graphics.Color.Blue.ToArgb()); textMark2.SetPadding(10, 20, 15, 25); textMark2.SetMarkerHeight(10); textMark2.TabMark += (s, e) => { Toast.MakeText(this, "textMark2標註已被點擊", ToastLength.Short).Show(); }; mPanoView.AddMarker(textMark1); mPanoView.AddMarker(textMark2); } /// <summary> /// 刪除文本標註 /// </summary> private void RemoveTextMarker() { mPanoView.RemoveMarker(textMark1); mPanoView.RemoveMarker(textMark2); } protected override void OnPause() { mPanoView.OnPause(); base.OnPause(); } protected override void OnResume() { mPanoView.OnResume(); base.OnResume(); } protected override void OnDestroy() { mPanoView.Destroy(); mBMapManager.Dispose(); base.OnDestroy(); } public void OnGetPermissionState(int p0) { //因爲MainActivity已經驗證過key,因此此處不須要添加任何代碼 } } }
四、Demo20PanoCoordinate.cs文件
在SrcSdkDemos文件夾下添加該文件,而後將其內容改成下面的代碼:
using Android.App; using Android.OS; using Android.Views; using Android.Widget; using Com.Baidu.Lbsapi.Tools; namespace BdMapV371Demos.SrcSdkDemos { /// <summary> /// 座標轉換 /// </summary> [Activity(Label = "@string/demo_desc_panorama6")] public class Demo20PanoCoordinate : Activity { private RadioGroup radioGroup; private Button btn, btn_ll2mc, btn_mc2ll; private TextView baiduResult, mcResult, llResult; private EditText inputLat, inputLont; // 百度經緯度座標 Point resultPointLL = null; // 百度墨卡託座標 Point resultPointMC = null; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.demo20_panodemo_coordinate); radioGroup = FindViewById<RadioGroup>(Resource.Id.panodemo_coordinate_rgroup); btn = FindViewById<Button>(Resource.Id.panodemo_coordinate_btn); btn_ll2mc = FindViewById<Button>(Resource.Id.panodemo_ll2mc_btn); btn_mc2ll = FindViewById<Button>(Resource.Id.panodemo_mc2ll_btn); baiduResult = FindViewById<TextView>(Resource.Id.panodemo_coordinate_result); mcResult = FindViewById<TextView>(Resource.Id.panodemo_ll2mc_result); llResult = FindViewById<TextView>(Resource.Id.panodemo_mc2ll_result); inputLat = FindViewById<EditText>(Resource.Id.panodemo_coordinate_input_lat); inputLont = FindViewById<EditText>(Resource.Id.panodemo_coordinate_input_lont); // 測試高德經緯度 inputLat.Text = "39.907687"; inputLont.Text = "116.397539"; // 測試騰訊經緯度 // inputLat.Text="39.907741"); // inputLont.Text="116.397577"); // 測試Google經緯度 // inputLat.Text="39.907723"); // inputLont.Text="116.397543"); // 測試原始GPS經緯度 // inputLat.Text="40.040286"); // inputLont.Text="116.30085"); btn.Click += delegate { if (string.IsNullOrEmpty(inputLat.Text) || string.IsNullOrEmpty(inputLont.Text)) { Toast.MakeText(this, "請輸入經緯度", ToastLength.Short).Show(); return; } // 原始點經緯度 Point sourcePoint = new Com.Baidu.Lbsapi.Tools.Point( double.Parse(inputLont.Text), double.Parse(inputLat.Text)); switch (radioGroup.CheckedRadioButtonId) { case Resource.Id.panodemo_coordinate_rgaode: resultPointLL = CoordinateConverter.Converter(CoordinateConverter.COOR_TYPE.CoorTypeGcj02, sourcePoint); break; case Resource.Id.panodemo_coordinate_rtencent: resultPointLL = CoordinateConverter.Converter(CoordinateConverter.COOR_TYPE.CoorTypeGcj02, sourcePoint); break; case Resource.Id.panodemo_coordinate_rgoogle: resultPointLL = CoordinateConverter.Converter(CoordinateConverter.COOR_TYPE.CoorTypeGcj02, sourcePoint); break; case Resource.Id.panodemo_coordinate_rgps: resultPointLL = CoordinateConverter.Converter(CoordinateConverter.COOR_TYPE.CoorTypeWgs84, sourcePoint); break; default: break; } if (resultPointLL != null) { baiduResult.Text = "百度經緯度座標:\nLatitude: " + resultPointLL.Y + "\nLongitude: " + resultPointLL.X; btn_ll2mc.Visibility = ViewStates.Visible; } }; btn_ll2mc.Click += delegate { resultPointMC = CoordinateConverter.LLConverter2MC(resultPointLL.X, resultPointLL.Y); int mercatorX = (int)resultPointMC.X; int mercatorY = (int)resultPointMC.Y; mcResult.Text = "百度墨卡託座標:\nx: " + mercatorX + "\ny: " + mercatorY; btn_mc2ll.Visibility = ViewStates.Visible; }; btn_mc2ll.Click += delegate { Point llPoint = CoordinateConverter.MCConverter2LL(resultPointMC.X, resultPointMC.Y); llResult.Text = "百度經緯度座標:\nLatitude: " + llPoint.Y + "\nLongitude: " + llPoint.X; }; } } }
五、修改MainActivity.cs文件
在MainActivity.cs文件的demos字段定義中,去掉【示例20】下面的註釋。
運行觀察效果。