c# - MonoTouch Multiple Mapkit CLLocationCoordinate2D 与自定义 PIN 图像
<p><p>您好,我的主要问题是如何使用 <code>MKAnnotationView</code> 为我的所有坐标点设置自定义图钉图像。 </p>
<p>作为引用,我已经继续硬编码了我通常会从 json webservice 调用中调用的值。
下面是硬编码路径的示例:</p>
<pre><code>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));
</code></pre>
<p>现在我正在使用 <code>MKAnnotation</code>,但意识到我需要使用 <code>MKAnnotationView</code> 来自定义图像引脚。</p>
<pre><code>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;
}
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>看看<a href="https://github.com/xamarin/monotouch-samples/tree/master/MapCallouts" rel="noreferrer noopener nofollow">MapCallout sample</a>来自 Xamarin。这是来自 Objective-C <a href="http://developer.apple.com/library/ios/#samplecode/MapCallouts/Introduction/Intro.html" rel="noreferrer noopener nofollow">sample</a> 的 C# 端口由苹果。它将向您展示如何创建基于图像的注释并将它们显示在 map 上。</p></p>
<p style="font-size: 20px;">关于c# - MonoTouch Multiple Mapkit CLLocationCoordinate2D 与自定义 PIN 图像,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/9893211/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/9893211/
</a>
</p>
页:
[1]