2017-08-03 95 views
0

我试图建立在我的Android项目地图路线线xamarin形式,这里OnElementChanged是我的代码:有毛病我在xamarin.forms

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 neoFly_Montana; 
using neoFly_Montana.Droid; 
using Xamarin.Forms; 
using Xamarin.Forms.Maps.Android; 
using Android.Gms.Maps; 
using Xamarin.Forms.Maps; 

[assembly: ExportRenderer(typeof(CustomMap), typeof(CustomMapRenderer))] 
namespace neoFly_Montana.Droid 
{ 
public class CustomMapRenderer : MapRenderer, IOnMapReadyCallback 
{ 
    GoogleMap map; 
    List<Position> routeCoordinates; 

    protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<View> e) 
    { 
     base.OnElementChanged(e); 

     if (e.OldElement != null) 
     { 
      // Unsubscribe 
     } 

     if (e.NewElement != null) 
     { 
      var formsMap = (CustomMap)e.NewElement; 
      routeCoordinates = formsMap.RouteCoordinates; 

      ((MapView)Control).GetMapAsync(this); 
     } 
    } 


} 
} 

出现此错误:

没有shuitable方法找到重写

enter image description here

确实有人知道发生了什么? 这是我在应用程序中的第一张地图。

回答

2

它看起来像你的OnElementChanged方法中的类型是错误的。

试试这个:

protected override void OnElementChanged(ElementChangedEventArgs<Map> e) 

即视图更改为地图

+0

即可。我现在正在尝试 –