我正在使用xamarin.forms.maps并成功获取折线,但我想在here上获得一些图案并且无法实现它。
任何人都可以帮我解决这个问题,我的代码如下:
formsMap.DrawPolyLine =()=>
{
if(nativeMaps == null)
{
nativeMaps =控制为MKMapView;
}
nativeMaps.OverlayRenderer = GetOverlayRenderer;
CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[IOSMapViewModel.DeviceTrackData.Count];
int index = 0;
foreach (var position in IOSMapViewModel.DeviceTrackData)
{
coords[index] = new CLLocationCoordinate2D(position.Latitude, position.Longitude);
index++;
}
routeOverlay = MKGeodesicPolyline.FromCoordinates(coords);
if (nativeMap.Overlays != null)
nativeMaps.RemoveOverlays(nativeMap.Overlays);
IMKOverlay overlay = routeOverlay;
nativeMaps.AddOverlay(routeOverlay, MKOverlayLevel.AboveLabels);
};
nativeMap.GetViewForAnnotation = GetViewForAnnotation;
nativeMap.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped;
}
}
MKOverlayRenderer GetOverlayRenderer(MKMapView mapView, IMKOverlay overlayWrapper)
{
if (polylineRenderer == null && !Equals(overlayWrapper, null))
{
var overlay = Runtime.GetNSObject(overlayWrapper.Handle) as IMKOverlay;
Foundation.NSNumber[] dashValues = { 3, 6 };
polylineRenderer = new MKPolylineRenderer(overlay as MKGeodesicPolyline)
{
FillColor = UIColor.Orange,
StrokeColor = UIColor.Orange,
LineWidth = 3,
Alpha = 1f,
LineDashPattern = dashValues
};
//polylineRenderer.CreatePath();
}
return polylineRenderer;
}