OGeek|极客世界-中国程序员成长平台

标题: c# - MonoTouch Multiple Mapkit CLLocationCoordinate2D 与自定义 PIN 图像 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:19
标题: c# - MonoTouch Multiple Mapkit CLLocationCoordinate2D 与自定义 PIN 图像

您好,我的主要问题是如何使用 MKAnnotationView 为我的所有坐标点设置自定义图钉图像。

作为引用,我已经继续硬编码了我通常会从 json webservice 调用中调用的值。 下面是硬编码路径的示例:

CLLocationCoordinate2D[] trail1 = new CLLocationCoordinate2D[]{
new CLLocationCoordinate2D(10.74812, -97.330277),
new CLLocationCoordinate2D(10.74501, -97.350277),
new CLLocationCoordinate2D(10.74912, -97.340277),
};

CLLocationCoordinate2D[] trail2 = new CLLocationCoordinate2D[]{
new CLLocationCoordinate2D(10.84812, -97.331277),
new CLLocationCoordinate2D(10.94501, -97.352277),
new CLLocationCoordinate2D(10.14912, -97.343277),
new CLLocationCoordinate2D(10.12912, -97.313277),    
};

mapview.AddAnnotation (new SampleMapAnnotation (trail1));

现在我正在使用 MKAnnotation,但意识到我需要使用 MKAnnotationView 来自定义图像引脚。

public class SampleMapAnnotation : MKAnnotation 
{
string _title;

public SampleMapAnnotation (CLLocationCoordinate2D coordinate)
{
Coordinate = coordinate;
_title = "Sample";
}

public override CLLocationCoordinate2D Coordinate { get; set; }

public override string Title
        {
            get {
                return _title;
        }
    }
}



Best Answer-推荐答案


看看MapCallout sample来自 Xamarin。这是来自 Objective-C sample 的 C# 端口由苹果。它将向您展示如何创建基于图像的注释并将它们显示在 map 上。

关于c# - MonoTouch Multiple Mapkit CLLocationCoordinate2D 与自定义 PIN 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9893211/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4