本文整理汇总了C#中CLLocationCoordinate2D类的典型用法代码示例。如果您正苦于以下问题:C# CLLocationCoordinate2D类的具体用法?C# CLLocationCoordinate2D怎么用?C# CLLocationCoordinate2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CLLocationCoordinate2D类属于命名空间,在下文中一共展示了CLLocationCoordinate2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicPinAnnotation
public BasicPinAnnotation (CLLocationCoordinate2D coordinate, string title, string subtitle, string imageAdress)
{
this.Coords = coordinate;
this.title = title;
this.subtitle = subtitle;
this.imageAdress = imageAdress;
}
示例2: FieldMapAnnotation
public FieldMapAnnotation(Field field)
{
coordinate = new CLLocationCoordinate2D(GeoHelper.CalculateCenter(field.BoundingCoordinates).Latitude, GeoHelper.CalculateCenter(field.BoundingCoordinates).Longitude);
Field = field;
title = field.Name;
subtitle = string.Format("Number of blocks: {0}", field.Blocks.Count);
}
示例3: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "MapView";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//mapView.MapType = MKMapType.Standard; // this is the default
//mapView.MapType = MKMapType.Satellite;
//mapView.MapType = MKMapType.Hybrid;
View.AddSubview(mapView);
// create our location and zoom
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(40.77, -73.98); // new york
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(33.93, -118.40); // los angeles
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(51.509, -0.1); // london
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(48.857, 2.351); // paris
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
// set the coords and zoom on the map
mapView.Region = new MKCoordinateRegion(coords, span);
}
示例4: ConferenceAnnotation
/// <summary>
/// custom constructor
/// </summary>
public ConferenceAnnotation(CLLocationCoordinate2D coord, string t, string s)
: base()
{
_coordinate=coord;
_title=t;
_subtitle=s;
}
示例5: ExtendedMapAnnotation
public ExtendedMapAnnotation(CLLocationCoordinate2D coordinate, string title, string subtitle, string pinIcon)
{
_coordinate = coordinate;
_title = title;
_subtitle = subtitle;
_pinIcon = pinIcon;
}
示例6: LoadMarkers
public void LoadMarkers()
{
CLLocationCoordinate2D coord;
string[] coordList = ReadGPSCoords ();
foreach (string s in coordList) {
if (string.IsNullOrEmpty (s) == false) {
string[] coordPair = s.Split(',');
if (coordPair.Length > 0) {
var longitude = coordPair [0];
var lat = coordPair [1];
coord = new CLLocationCoordinate2D ( Convert.ToDouble(lat), Convert.ToDouble(longitude));
var marker = Marker.FromPosition (coord);
marker.Map = mapView;
}
}
}
}
示例7: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
//change map type and show user location
//mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid;
mapView.ShowsUserLocation = true;
//set map center and region
double lat = 45.8149;
double lon = 15.9785;
var mapCenter = new CLLocationCoordinate2D (lat,lon);
var mapRegion = MKCoordinateRegion.FromDistance (mapCenter, 2000, 2000);
mapView.CenterCoordinate = mapCenter;
mapView.Region = mapRegion;
//set the map delegate -> callback
//mapView will call this when something needs to be done (extras ...)
MapViewDelegate mvd = new MapViewDelegate();
mapView.Delegate = mvd;
//It's important that the map delegate is created before annotations!!
//add an annotation MKPointAnnotation -> basic class
mapView.AddAnnotation (new MKPointAnnotation (){Title="MyAnnotation",Coordinate = new CLLocationCoordinate2D(45.8100,15.9760)});
//add an annotation MyCustomAnnotation -> custom class
mapView.AddAnnotation (new MyCustomAnnotation("HolisticWare","www.holisticware.com",new CLLocationCoordinate2D(45.8090,15.9710)));
//add an overlay
var circleOverlay = MKCircle.Circle (mapCenter, 1000);
mapView.AddOverlay (circleOverlay);
}
示例8: RestaurantAnnotation
public RestaurantAnnotation (string title, string subtitle, CLLocationCoordinate2D coordinate, RestaurantKind kind)
{
_title = title;
_subtitle = subtitle;
_coordinate = coordinate;
_kind = kind;
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
Console.WriteLine("Map to load");
base.ViewDidLoad ();
Title = "MapView";
//mapView = new MKMapView(View.Bounds);
this.DDZMapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//this.DDZMapView.MapType = MKMapType.Standard; // this is the default
//this.DDZMapView.MapType = MKMapType.Satellite;
//this.DDZMapView.MapType = MKMapType.Hybrid;
View.AddSubview(this.DDZMapView);
// create our location and zoom
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(38.9686111, -77.3413889); // Reston
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(2), MilesToLongitudeDegrees(2, coords.Latitude));
// set the coords and zoom on the map
this.DDZMapView.Region = new MKCoordinateRegion(coords, span);
circleOverlay = MKCircle.Circle (coords, 200);
this.DDZMapView.AddOverlay (circleOverlay);
this.DDZMapView.GetViewForOverlay = (m, o) => {
if(circleView == null)
{
circleView = new MKCircleView(o as MKCircle);
circleView.FillColor = UIColor.Purple;
circleView.Alpha = 0.5f;
}
return circleView;
};
}
示例10: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// change map type and show user location
map.MapType = MKMapType.Hybrid;
map.ShowsUserLocation = true;
// set map center and region
double lat = 42.374260;
double lon = -71.120824;
var mapCenter = new CLLocationCoordinate2D (lat, lon);
var mapRegion = MKCoordinateRegion.FromDistance (mapCenter, 2000, 2000);
map.CenterCoordinate = mapCenter;
map.Region = mapRegion;
// add an annotation
map.AddAnnotation (new MKPointAnnotation (){Title="MyAnnotation", Coordinate = new CLLocationCoordinate2D (42.364260, -71.120824)});
// set the map delegate
mapDel = new MyMapDelegate ();
map.Delegate = mapDel;
// add a custom annotation
map.AddAnnotation (new MonkeyAnnotation ("Xamarin", mapCenter));
// add an overlay
var circleOverlay = MKCircle.Circle (mapCenter, 1000);
map.AddOverlay (circleOverlay);
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "Highland Park, Los Angeles";
// create our location and zoom for los angeles
CLLocationCoordinate2D coords = new CLLocationCoordinate2D (34.120, -118.188);
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees (20), MilesToLongitudeDegrees (20, coords.Latitude));
// set the coords and zoom on the map
mapMain.Region = new MKCoordinateRegion (coords, span);
// set our delegate. we don't actually need a delegate if we want to just drop a pin
// on there, but if we want to specify anything custom, we do
mapMain.Delegate = new MapDelegate();
// add a basic annotation
mapMain.AddAnnotation (new BasicMapAnnotation (new CLLocationCoordinate2D (34.120, -118.188), "Los Angeles", "City of Demons"));
// can use this as well.
// mapMain.AddAnnotationObject(
// new BasicMapAnnotationProto() { Coordinate = new CLLocationCoordinate2D(34.120, -118.188), Title = "Los Angeles", Subtitle = "City of Demons" }
// );
}
示例12: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged (e);
if (e.OldElement != null) {
var nativeMap = Control as MKMapView;
nativeMap.OverlayRenderer = null;
}
if (e.NewElement != null) {
var formsMap = (CustomMap)e.NewElement;
var nativeMap = Control as MKMapView;
nativeMap.OverlayRenderer = GetOverlayRenderer;
CLLocationCoordinate2D[] coords = new CLLocationCoordinate2D[formsMap.ShapeCoordinates.Count];
int index = 0;
foreach (var position in formsMap.ShapeCoordinates) {
coords [index] = new CLLocationCoordinate2D (position.Latitude, position.Longitude);
index++;
}
var blockOverlay = MKPolygon.FromCoordinates (coords);
nativeMap.AddOverlay (blockOverlay);
}
}
示例13: HouseMapAnnotation
public HouseMapAnnotation (CLLocationCoordinate2D coordinate, string title, House house, string rank) {
this.coordinate = coordinate;
this.title = title;
this.House = house;
this.subtitle = string.Format ("({0}) Likes",house.Likes);
this.Rank = rank;
}
示例14: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.Title = "Pyramids of Giza";
// create our location and zoom for the pyramids.
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(29.976111, 31.132778);
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(.75), MilesToLongitudeDegrees(.75, coords.Latitude));
// set the coords and zoom on the map
this.mapMain.Region = new MKCoordinateRegion(coords, span);
// show the sat view.
this.mapMain.MapType = MKMapType.Satellite;
// add an overlay with the coords
this._circleOverlay = MKCircle.Circle(coords, 200);
this.mapMain.AddOverlay(this._circleOverlay);
// set our delegate.
//this.mapMain.Delegate = new MapDelegate();
//-- OR --
//- override the GetVIewForOverlay directly, in which case we don't need a delegate
this.mapMain.GetViewForOverlay += (m, o) => {
if(this._circleView == null)
{
this._circleView = new MKCircleView(this._circleOverlay);
this._circleView.FillColor = UIColor.Blue;
this._circleView.Alpha = 0.5f;
}
return this._circleView;
};
}
示例15: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "Mi Ubicacion";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//mapView.MapType = MKMapType.Standard; // this is the default
//mapView.MapType = MKMapType.Satellite;
mapView.MapType = MKMapType.Hybrid;
mapView.ZoomEnabled = true;
View.AddSubview(mapView);
// this is all that's required to show the blue dot indicating user-location
mapView.ShowsUserLocation = true;
Console.WriteLine ("initial loc:"+mapView.UserLocation.Coordinate.Latitude + "," + mapView.UserLocation.Coordinate.Longitude);
mapView.DidUpdateUserLocation += (sender, e) => {
if (mapView.UserLocation != null) {
Console.WriteLine ("userloc:"+mapView.UserLocation.Coordinate.Latitude + "," + mapView.UserLocation.Coordinate.Longitude);
CLLocationCoordinate2D coords = mapView.UserLocation.Coordinate;
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(1), MilesToLongitudeDegrees(1, coords.Latitude));
mapView.Region = new MKCoordinateRegion(coords, span);
}
};
if (!mapView.UserLocationVisible) {
// user denied permission, or device doesn't have GPS/location ability
Console.WriteLine ("userloc not visible, show cupertino");
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(37.33233141,-122.0312186); // cupertino
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
mapView.Region = new MKCoordinateRegion(coords, span);
}
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new RectangleF((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Mapa", 0, false);
mapTypes.InsertSegment("Satelite", 1, false);
mapTypes.InsertSegment("Hibrido", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
}