本文整理汇总了C#中CLLocation类的典型用法代码示例。如果您正苦于以下问题:C# CLLocation类的具体用法?C# CLLocation怎么用?C# CLLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CLLocation类属于命名空间,在下文中一共展示了CLLocation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UpdateLocation
public static void UpdateLocation(GPSLocate ms, CLLocation newLocation)
{
ms.LblAltitude.Text = newLocation.Altitude.ToString () + " meters";
ms.LblLongitude.Text = newLocation.Coordinate.Longitude.ToString () + "º";
ms.LblLatitude.Text = newLocation.Coordinate.Latitude.ToString () + "º";
ms.LblCourse.Text = newLocation.Course.ToString () + "º";
ms.LblSpeed.Text = newLocation.Speed.ToString () + " meters/s";
// get the distance from here to paris
ms.LblDistanceToParis.Text = (newLocation.DistanceFrom(new CLLocation(48.857, 2.351)) / 1000).ToString() + " km";
var x1 =Convert.ToDouble( "40.023408");
var y1 =Convert.ToDouble( "40.643127");
var x2 =Convert.ToDouble( "30.753657");
var y2 = Convert.ToDouble("30.038635");
var longdute =newLocation.Coordinate.Longitude;
var latidute = newLocation.Coordinate.Latitude;
ms.checkIt.Clicked+= (sender, e) => {
if (longdute > x2 && longdute < x1 && latidute > y2 && latidute < y1)
new UIAlertView("Ankara Dışındasın", "Konum : " + longdute + " " + latidute, null, "OK", null).Show();
else
new UIAlertView("Ankara İçerisindesin", "Konum : " + longdute + " " + latidute, null, "OK", null).Show();
};
}
开发者ID:hhempel,项目名称:StoryboardTables,代码行数:27,代码来源:GPSLocate.cs
示例2: UpdatedLocation
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
_helper.Locations.Add (newLocation);
if (_helper.LocationAdded != null)
_helper.LocationAdded (_helper, new LocationEventArgs (newLocation));
}
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:7,代码来源:LocationHelper.cs
示例3: LocationsUpdated
public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations)
{
Task.Run (async () => {await AppDelegate.FlicService.RefreshPendingConnections();});
foreach(var loc in locations) {
Console.WriteLine(loc);
}
}
开发者ID:bytedreamer,项目名称:BusyBot-iOS,代码行数:7,代码来源:MainTabBarController.cs
示例4: FinishedLaunching
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
var what = new EntryElement ("What ?", "e.g. pizza", String.Empty);
var where = new EntryElement ("Where ?", "here", String.Empty);
var section = new Section ();
if (CLLocationManager.LocationServicesEnabled) {
lm = new CLLocationManager ();
lm.LocationsUpdated += delegate (object sender, CLLocationsUpdatedEventArgs e) {
lm.StopUpdatingLocation ();
here = e.Locations [e.Locations.Length - 1];
var coord = here.Coordinate;
where.Value = String.Format ("{0:F4}, {1:F4}", coord.Longitude, coord.Latitude);
};
section.Add (new StringElement ("Get Current Location", delegate {
lm.StartUpdatingLocation ();
}));
}
section.Add (new StringElement ("Search...", async delegate {
await SearchAsync (what.Value, where.Value);
}));
var root = new RootElement ("MapKit Search Sample") {
new Section ("MapKit Search Sample") { what, where },
section
};
window.RootViewController = new UINavigationController (new DialogViewController (root, true));
window.MakeKeyAndVisible ();
return true;
}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:33,代码来源:AppDelegate.cs
示例5: GetPoiInformation
public static JsonArray GetPoiInformation(CLLocation userLocation, int numberOfPlaces)
{
if (userLocation == null)
return null;
var pois = new List<JsonObject> ();
for (int i = 0; i < numberOfPlaces; i++)
{
var loc = GetRandomLatLonNearby (userLocation.Coordinate.Latitude, userLocation.Coordinate.Longitude);
var p = new Dictionary<string, JsonValue>(){
{ "id", i.ToString() },
{ "name", "POI#" + i.ToString() },
{ "description", "This is the description of POI#" + i.ToString() },
{ "latitude", loc[0] },
{ "longitude", loc[1] },
{ "altitude", 100f }
};
pois.Add (new JsonObject (p.ToList()));
}
var vals = from p in pois select (JsonValue)p;
return new JsonArray (vals);
}
开发者ID:ancchaimongkon,项目名称:wikitude-xamarin,代码行数:27,代码来源:GeoUtils.cs
示例6: LocationManagerDidUpdateToLocationFromLocation
public void LocationManagerDidUpdateToLocationFromLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
// Ignore updates where nothing we care about changed
if (oldLocation != null &&
newLocation.Coordinate.longitude == oldLocation.Coordinate.longitude &&
newLocation.Coordinate.latitude == oldLocation.Coordinate.latitude &&
newLocation.HorizontalAccuracy == oldLocation.HorizontalAccuracy)
{
return;
}
// Load the HTML for displaying the Google map from a file and replace the
// format placeholders with our location data
NSError error;
NSString htmlString = NSString.StringWithFormat(
NSString.StringWithContentsOfFileEncodingError(
NSBundle.MainBundle.PathForResourceOfType("HTMLFormatString", @"html"),
NSStringEncoding.NSUTF8StringEncoding,out error),
newLocation.Coordinate.latitude,
newLocation.Coordinate.longitude,
LatitudeRangeForLocation(newLocation),
LongitudeRangeForLocation(newLocation));
// Load the HTML in the WebView and set the labels
this.webView.MainFrame.LoadHTMLStringBaseURL(htmlString, null);
this.locationLabel.StringValue = NSString.StringWithFormat("%f, %f",
newLocation.Coordinate.latitude, newLocation.Coordinate.longitude);
this.accuracyLabel.StringValue = NSString.StringWithFormat("%f",
newLocation.HorizontalAccuracy);
}
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:30,代码来源:WhereIsMyMacAppDelegate.cs
示例7: Geoposition
// constructor from CoreLocation location
internal Geoposition(CLLocation location)
{
Coordinate = new Geocoordinate();
if (location != null)
{
Coordinate.Point = new Geopoint(new BasicGeoposition() { Latitude = location.Coordinate.Latitude, Longitude = location.Coordinate.Longitude, Altitude = location.Altitude });
Coordinate.Accuracy = location.HorizontalAccuracy;
if (!double.IsNaN(location.VerticalAccuracy))
{
Coordinate.AltitudeAccuracy = location.VerticalAccuracy;
}
#if __IOS__ || __MAC__
if (!double.IsNaN(location.Course) && location.Course != -1)
{
Coordinate.Heading = location.Course;
}
if (!double.IsNaN(location.Speed) && location.Speed != -1)
{
Coordinate.Speed = location.Speed;
}
#endif
Coordinate.Timestamp = InTheHand.DateTimeOffsetHelper.FromNSDate(location.Timestamp);
}
}
开发者ID:inthehand,项目名称:Charming,代码行数:28,代码来源:Geoposition.cs
示例8: QueryForRecords
public void QueryForRecords (CLLocation location, Action<List<CKRecord>> completionHandler)
{
var radiusInKilometers = NSNumber.FromFloat (5f);
var predicate = NSPredicate.FromFormat ("distanceToLocation:fromLocation:(location, %@) < %f",
new NSObject[] { location, radiusInKilometers });
var query = new CKQuery (ItemRecordType, predicate) {
SortDescriptors = new [] { new NSSortDescriptor ("creationDate", false) }
};
var queryOperation = new CKQueryOperation (query) {
DesiredKeys = new [] { NameField }
};
var results = new List<CKRecord> ();
queryOperation.RecordFetched = (record) => results.Add (record);
queryOperation.Completed = (cursor, error) => {
if (error != null) {
Console.WriteLine ("An error occured: {0}", error.Description);
return;
}
DispatchQueue.MainQueue.DispatchAsync (() => completionHandler (results));
};
publicDatabase.AddOperation (queryOperation);
}
开发者ID:GouriKumari,项目名称:SubmissionSamples,代码行数:29,代码来源:CloudManager.cs
示例9: LatitudeRangeForLocation
public static double LatitudeRangeForLocation(CLLocation aLocation)
{
const double M = 6367000.0;
const double metersToLatitude = 1.0/((Math.PI/180.0d)*M);
const double accuracyToWindowScale = 2.0;
return aLocation.HorizontalAccuracy*metersToLatitude*accuracyToWindowScale;
}
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:7,代码来源:WhereIsMyMacAppDelegate.cs
示例10: FindNearestRestaurantAsync
/// <summary>
/// Finds the nearest restaurant.
/// </summary>
/// <returns>The nearest restaurant.</returns>
/// <param name="location">Location.</param>
public async static Task<string> FindNearestRestaurantAsync(CLLocation location)
{
// Search for restaurants near our location.
string restaurant = string.Empty;
try
{
var searchRequest = new MKLocalSearchRequest
{
NaturalLanguageQuery = "food",
Region = new MKCoordinateRegion(new CLLocationCoordinate2D(location.Coordinate.Latitude, location.Coordinate.Longitude), new MKCoordinateSpan(0.3f, 0.3f))
};
var localSearch = new MKLocalSearch(searchRequest);
var localSearchResponse = await localSearch.StartAsync();
if(localSearchResponse.MapItems != null && localSearchResponse.MapItems.Length > 0)
{
var mapItem = localSearchResponse.MapItems[0];
restaurant = mapItem.Name;
}
}
catch(Exception ex)
{
//Console.WriteLine("Error searching restaurants: " + ex);
}
return restaurant;
}
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:32,代码来源:Helpers.cs
示例11: ViewDidAppear
public override void ViewDidAppear (bool animated)
{
base.ViewDidAppear (animated);
viewIsDisplayed = true;
var region = LocationTriggerCreator.TargetRegion;
if (region != null) {
var centerLocation = new CLLocation (region.Center.Latitude, region.Center.Longitude);
geocoder.ReverseGeocodeLocation (centerLocation, (placemarks, error) => {
// The geocoder took too long, we're not on this view any more.
if (!viewIsDisplayed)
return;
if (error != null) {
DisplayError (error);
return;
}
if (placemarks != null) {
var mostLikelyPlacemark = placemarks.FirstOrDefault ();
if (mostLikelyPlacemark != null) {
CNMutablePostalAddress address = CreatePostalAddress (mostLikelyPlacemark);
var addressFormatter = new CNPostalAddressFormatter ();
string addressString = addressFormatter.GetStringFromPostalAddress (address);
localizedAddress = addressString.Replace ("\n", ", ");
var section = NSIndexSet.FromIndex (2);
TableView.ReloadSections (section, UITableViewRowAnimation.Automatic);
}
}
});
}
TableView.ReloadData ();
}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:33,代码来源:LocationTriggerViewController.cs
示例12: SaveRecord
async partial void SaveRecord (MonoTouch.UIKit.UIButton sender)
{
if (nameTextField.Text.Length < 1) {
nameTextField.ResignFirstResponder ();
return;
}
var saveLocation = new CLLocation (pin.Coordinate.Latitude, pin.Coordinate.Longitude);
var record = await CloudManager.AddRecordAsync (nameTextField.Text, saveLocation);
if (record == null) {
Console.WriteLine ("Error: null returned on save");
return;
}
nameTextField.Text = string.Empty;
nameTextField.ResignFirstResponder ();
var alert = UIAlertController.Create ("CloudKitAtlas", "Saved record", UIAlertControllerStyle.Alert);
alert.AddAction (UIAlertAction.Create ("OK", UIAlertActionStyle.Default, (act) => {
DismissViewController (true, null);
}));
PresentViewController (alert, true, null);
}
开发者ID:RangoJT,项目名称:monotouch-samples,代码行数:25,代码来源:CKRecordViewController.cs
示例13: AddRecordAsync
public async Task<CKRecord> AddRecordAsync (string name, CLLocation location)
{
var newRecord = new CKRecord (ItemRecordType);
newRecord [NameField] = (NSString)name;
newRecord [LocationField] = location;
return await publicDatabase.SaveRecordAsync (newRecord);
}
开发者ID:GouriKumari,项目名称:SubmissionSamples,代码行数:8,代码来源:CloudManager.cs
示例14: latitudeRangeForLocation
double latitudeRangeForLocation(CLLocation location)
{
const double M = 6367000.0; // approximate average meridional radius of curvature of earth
const double metersToLatitude = 1.0 / ((Math.PI / 180.0) * M);
const double accuracyToWindowScale = 2.0;
return location.HorizontalAccuracy * metersToLatitude * accuracyToWindowScale;
}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:8,代码来源:MainWindowController.cs
示例15: QueryRecords
partial void QueryRecords (UIBarButtonItem sender)
{
var queryLocation = new CLLocation (pin.Coordinate.Latitude, pin.Coordinate.Longitude);
CloudManager.QueryForRecords (queryLocation, records => {
results = records;
TableView.ReloadData ();
});
}
开发者ID:b-theile,项目名称:monotouch-samples,代码行数:9,代码来源:LocationQueryViewController.cs
示例16: UpdatedLocation
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
Console.WriteLine ("New location data = {0}", newLocation.Description ());
_helper.Locations.Add (newLocation);
if (_helper.LocationAdded != null)
_helper.LocationAdded (_helper, new EventArgs ());
}
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:9,代码来源:LocationHelper.cs
示例17: LocationsUpdated
// called for iOS6 and later
public override void LocationsUpdated (CLLocationManager manager, CLLocation[] locations)
{
CLLocation currentLocation = locations [0];
MApplication.getInstance ().latitude = currentLocation.Coordinate.Latitude;
MApplication.getInstance ().longitude = currentLocation.Coordinate.Longitude;
#if DEBUG
Console.Out.WriteLine ("LocationsUpdated : ( {0} , {1})", MApplication.getInstance ().latitude,MApplication.getInstance ().longitude);
#endif
}
开发者ID:borain89vn,项目名称:demo2,代码行数:11,代码来源:TCLocationManager.cs
示例18: UpdatedLocation
public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
Console.WriteLine("{0},{1}", newLocation.Coordinate.Latitude, newLocation.Coordinate.Longitude);
if ((DateTime.Now - ((DateTime)newLocation.Timestamp)) > TimeSpan.FromMinutes(3)) {
return;
}
reallyFoundLocation(newLocation);
}
开发者ID:paulcbetts,项目名称:BigNerdIOS-MonoDevelop,代码行数:10,代码来源:WhereamiViewController.cs
示例19: UpdateLocation
static public void UpdateLocation (CLLocation newLocation, CLLocationManager locManager, GetLocationActions locActions, UITextField textField)
{
Console.WriteLine(newLocation.Coordinate.Longitude.ToString () + "º");
Console.WriteLine(newLocation.Coordinate.Latitude.ToString () + "º");
//FireEvent
OnLocationChanged (textField, locActions, newLocation.Coordinate.Latitude.ToString (), newLocation.Coordinate.Longitude.ToString ());
if (CLLocationManager.LocationServicesEnabled)
locManager.StopUpdatingLocation ();
if (CLLocationManager.HeadingAvailable)
locManager.StopUpdatingHeading ();
}
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:13,代码来源:TrafficDialogViewController.cs
示例20: getAllBusStops
//Caution: If radius is too large results will be HUGE!
//radius in meters
public IEnumerable<BusStop> getAllBusStops(CLLocation aboutLoc, double radius)
{
List<BusStop> stops = new List<BusStop>(30);
using (LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(getReader("stops.txt"),true)) {
while (csv.ReadNextRecord()){
CLLocation loc = new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"]));
if (loc.DistanceFrom(aboutLoc)<=radius)
stops.Add(new BusStop(csv["stop_name"],int.Parse(csv["stop_id"]), loc));
loc.Dispose();
}
return stops;
}
}
开发者ID:jboolean,项目名称:RIT-Bus,代码行数:15,代码来源:BusDB_GTFS.cs
注:本文中的CLLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论