/
AMapNaviViewRenderer.cs
44 lines (39 loc) · 1.25 KB
/
AMapNaviViewRenderer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Amap.Api.Navi;
using Com.Amap.Api.Navi.Enums;
using Com.Amap.Api.Navi.Model;
using SampleApp.Controls;
using SampleApp.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(XAMapNaviView), typeof(AMapNaviViewRenderer))]
namespace SampleApp.Droid.Renderers
{
public class AMapNaviViewRenderer:ViewRenderer<XAMapNaviView, Android.Widget.RelativeLayout>
{
public AMapNaviViewRenderer(Context context):base(context)
{
}
private Android.Widget.RelativeLayout mRelativeLayout;
protected override void OnElementChanged(ElementChangedEventArgs<XAMapNaviView> e)
{
mRelativeLayout = (Context as MainActivity).naviRelativeLayout;
(Context as MainActivity).navi.StartNavi(NaviType.Emulator);
SetNativeControl(mRelativeLayout);
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
mRelativeLayout.RemoveFromParent();
}
}
}