-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapDelegate.cs
81 lines (67 loc) · 2.62 KB
/
MapDelegate.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using CoreGraphics;
using CoreLocation;
using Foundation;
using MapKit;
using UIKit;
namespace CProjectMapIos
{
public class MapDelegate: MKMapViewDelegate
{
static string annotationId = "UserAnnotation";
UIImageView venueView;
//UIImage venueImage;
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation mkAnnotation)
{
MKAnnotationView annotationView = null;
if (mkAnnotation is MKUserLocation)
return null;
if (mkAnnotation is UserAnnotation)
{
// show conference annotation
annotationView = mapView.DequeueReusableAnnotation (annotationId);
if (annotationView == null)
annotationView = new MKAnnotationView (mkAnnotation, annotationId);
// annotationView.Image = UIImage.FromFile ("images/conference.png");
annotationView.CanShowCallout = true;
annotationView.Draggable = true;
}
return annotationView;
}
public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
{
if (view.Annotation is UserAnnotation)
{
venueView = new UIImageView ();
venueView.ContentMode = UIViewContentMode.ScaleAspectFit;
//venueImage = UIImage.FromFile ("image/venue.png");
// venueView.Image = venueImage;
view.AddSubview (venueView);
UIView.Animate (0.4, () => {
venueView.Frame = new CGRect (-75, -75, 200, 200); });
}
}
public override void DidDeselectAnnotationView(MKMapView mapView, MKAnnotationView view)
{
if (view.Annotation is UserAnnotation)
{
venueView.RemoveFromSuperview ();
venueView.Dispose ();
venueView = null;
}
}
public override MKOverlayView GetViewForOverlay(MKMapView mapView, IMKOverlay overlay)
{
// var polygon = overlay as MKPolygon;
// var polygonView = new MKPolygonView (polygon);
// polygonView.FillColor = UIColor.Blue;
// polygonView.StrokeColor = UIColor.Red;
// return polygonView;
var circleOverlay = overlay as MKCircle;
var circleView = new MKCircleView (circleOverlay);
circleView.FillColor = UIColor.Blue;
circleView.Alpha = (nfloat) 0.1;
return circleView;
}
}
}