本文整理汇总了C#中GeoCoordinate类的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinate类的具体用法?C# GeoCoordinate怎么用?C# GeoCoordinate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeoCoordinate类属于命名空间,在下文中一共展示了GeoCoordinate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
bikePaths = new BikePaths();
trees = Tree.ParseCsv();
map = new Map();
map.CredentialsProvider = new ApplicationIdCredentialsProvider("Atvj6eBBbDS6-dL7shp9KmzY-0v0NL2ETYCFoHIDzQwK8_9bJ2ZdRgeMAj0sDs_F");
// Set the center coordinate and zoom level
GeoCoordinate mapCenter = new GeoCoordinate(45.504693, -73.576494);
int zoom = 14;
// Create a pushpin to put at the center of the view
Pushpin pin1 = new Pushpin();
pin1.Location = mapCenter;
pin1.Content = "McGill University";
map.Children.Add(pin1);
bikePaths.AddPathsToMap(map);
// Set the map style to Aerial
map.Mode = new Microsoft.Phone.Controls.Maps.AerialMode();
// Set the view and put the map on the page
map.SetView(mapCenter, zoom);
ContentPanel.Children.Add(map);
}
示例2: VehicleTracker
public VehicleTracker(GeoCoordinate[] waypoints, double minSpeed, double maxSpeed,
int lowSpeedDelayInSecs,
int midSpeedDelayInSecs,
int highSpeedDelayInSecs,
double speedBetweenPosTolerance
)
{
if (waypoints.Length < 2)
{
throw new ArgumentException("Waypoints must be a GeoCoordinate array of at least 2");
}
else if (minSpeed < 0 || minSpeed >= maxSpeed)
{
throw new ArgumentException("minSpeed must be positive and less than maxSpeed");
}
else if (speedBetweenPosTolerance <= 0)
{
throw new ArgumentException("Speed tolerance must be greater than zero");
}
else if (lowSpeedDelayInSecs <= 0 || midSpeedDelayInSecs <= 0 || highSpeedDelayInSecs <= 0)
{
throw new ArgumentException("Time delays must be positive");
}
_waypoints = waypoints;
_minSpeed = minSpeed;
_maxSpeed = maxSpeed;
_lowSpeedDelayInSeconds = lowSpeedDelayInSecs;
_midSpeedDelayInSeconds = midSpeedDelayInSecs;
_highSpeedDelayInSeconds = highSpeedDelayInSecs;
_speedBetweenPosTolerance = speedBetweenPosTolerance;
_random = new Random();
_speedInMph = _random.NextDouble(_minSpeed, _maxSpeed);
}
示例3: CreateWaypoint
//from http://stackoverflow.com/a/17545955
public static GeoCoordinate CreateWaypoint(GeoCoordinate sourceLocation, double distanceInMeters, double bearingDegrees, double altitude)
{
var distanceKm = distanceInMeters / 1000.0;
var distanceRadians = distanceKm / 6371; //6371 = Earth's radius in km
var bearingRadians = ToRad(bearingDegrees);
var sourceLatitudeRadians = ToRad(sourceLocation.Latitude);
var sourceLongitudeRadians = ToRad(sourceLocation.Longitude);
var targetLatitudeRadians = Math.Asin(Math.Sin(sourceLatitudeRadians) * Math.Cos(distanceRadians)
+
Math.Cos(sourceLatitudeRadians) * Math.Sin(distanceRadians) *
Math.Cos(bearingRadians));
var targetLongitudeRadians = sourceLongitudeRadians + Math.Atan2(Math.Sin(bearingRadians)
* Math.Sin(distanceRadians) *
Math.Cos(sourceLatitudeRadians),
Math.Cos(distanceRadians)
- Math.Sin(sourceLatitudeRadians) * Math.Sin(targetLatitudeRadians));
// adjust toLonRadians to be in the range -180 to +180...
targetLongitudeRadians = (targetLongitudeRadians + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
return new GeoCoordinate(ToDegrees(targetLatitudeRadians), ToDegrees(targetLongitudeRadians), altitude);
}
示例4: ToARunData
public ARunData ToARunData()
{
ARunData data = new ARunData();
for (int i = 0; i < longitude.Count(); i++)
{
GeoCoordinate geoCord = new GeoCoordinate();
geoCord.Longitude = longitude[i];
geoCord.Latitude = latitude[i];
data.geoCollection.Add(geoCord);
}
//data.datetime = JsonConvert.DeserializeObject<DateTime>(datetime, new JavaScriptDateTimeConverter());
try
{
data.datetime = TimeZoneInfo.ConvertTime(datetime, TimeZoneInfo.Local);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "The time will be set to default");
data.datetime = DateTime.MinValue;
}
int dem = (int)IsolatedStorageSettings.ApplicationSettings["RunCount"];
dem++;
IsolatedStorageSettings.ApplicationSettings.Save();
data.BurnedCalories = BurnedCalories;
data.Duration = Duration;
data.AvgSpeed = AvgSpeed;
data.AvgPace = AvgPace;
data.Distance = Distance;
data.No = dem;
data.IsSynced = true;
return data;
}
示例5: AddPoint
private void AddPoint(Map controlMap, GeoCoordinate geo)
{
// With the new Map control:
// Map -> MapLayer -> MapOverlay -> UIElements
// - Add a MapLayer to the Map
// - Add an MapOverlay to that layer
// - We can add a single UIElement to that MapOverlay.Content
MapLayer ml = new MapLayer();
MapOverlay mo = new MapOverlay();
// Add an Ellipse UI
Ellipse r = new Ellipse();
r.Fill = new SolidColorBrush(Color.FromArgb(255, 240, 5, 5));
// the item is placed on the map at the top left corner so
// in order to center it, we change the margin to a negative
// margin equal to half the width and height
r.Width = r.Height = 12;
r.Margin = new Thickness(-6, -6, 0, 0);
// Add the Ellipse to the Content
mo.Content = r;
// Set the GeoCoordinate of that content
mo.GeoCoordinate = geo;
// Add the MapOverlay to the MapLayer
ml.Add(mo);
// Add the MapLayer to the Map
controlMap.Layers.Add(ml);
}
示例6: GetCurrentLocation
private async void GetCurrentLocation()
{
try
{
geolocator.DesiredAccuracyInMeters = 50;
// If the cached location is over 30 minutes old, get a new one
TimeSpan maximumAge = new TimeSpan(0, 30, 0);
// If we're trying for more than 5 seconds, abandon the operation
TimeSpan timeout = new TimeSpan(0, 0, 5);
Geoposition myLocation = await geolocator.GetGeopositionAsync(maximumAge, timeout);
GeoCoordinate geoCord = new GeoCoordinate(myLocation.Coordinate.Latitude, myLocation.Coordinate.Longitude);
waypoints = new List<GeoCoordinate>();
waypoints.Add(geoCord);
MyMapControl.Center = geoCord;
MyMapControl.ZoomLevel = 12;
AddPoint(MyMapControl, geoCord);
geolocator.PositionChanged += newPosition;
}
catch (Exception exception)
{
//if this is an UnauthorizedAccessException:
// 1) you haven’t included ID_CAP_LOCATION in your app manifest
// or
// 2) user has disabled location in the phone Settings
// if this is a TimeoutExceeded exception:
// the device couldn't get a location in the allotted time
}
}
示例7: GetEnterprisesCloseToMyLocation
public JsonResult GetEnterprisesCloseToMyLocation(string latitude, string longitude)
{
var enterprises = Db.Enterprises.GetNearbyEnterprises(latitude, longitude);
var searchViewModel = new MainSearchViewModel
{
Enterprises = new List<LightEnterprise>()
};
foreach (var enterpriseViewModel in enterprises.Select(enterprise => new LightEnterprise
{
Key = EnterpriseHelper.GetKey(enterprise.Id),
Name = enterprise.Name,
LocationInfo = EnterpriseHelper.FormatDisplayStreet(enterprise),
DistanceFromMyLocation = string.Empty,
Categories = EnterpriseHelper.GetDisplayLabelsCategories(enterprise.Categories),
Coordinates = enterprise.Coordinates,
}))
{
searchViewModel.Enterprises.Add(enterpriseViewModel);
}
var myCoord = new GeoCoordinate(double.Parse(latitude, CultureInfo.InvariantCulture), double.Parse(longitude, CultureInfo.InvariantCulture));
foreach (var enterprise in searchViewModel.Enterprises)
{
var enterpriseCoord = new GeoCoordinate(enterprise.Coordinates.Lat, enterprise.Coordinates.Lng);
var distance = myCoord.GetDistanceTo(enterpriseCoord);
enterprise.DistanceFromMyLocation = string.Format("{0}km", Math.Round((distance / 1000), 1));
}
return Json(searchViewModel);
}
示例8: AddPinOnMap
private void AddPinOnMap()
{
geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].longitude));
geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].longitude));
Image pinIMG = new Image();
pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_green.png", UriKind.Relative));
pinIMG.Width = 50;
pinIMG.Height = 50;
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = pinIMG;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geo1;
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
mapJourney.Layers.Add(myLocationLayer);
myLocationLayer = null;
myLocationOverlay = null;
pinIMG = null;
pinIMG = new Image();
pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_red.png", UriKind.Relative));
pinIMG.Width = 50;
pinIMG.Height = 50;
myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = pinIMG;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geo2;
myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
mapJourney.Layers.Add(myLocationLayer);
myLocationLayer = null;
myLocationOverlay = null;
pinIMG = null;
mapJourney.ZoomLevel = ZoomLevel;
mapJourney.Center = geo2;
}
示例9: Init
public void Init()
{
current = new GeoCoordinate(30.623665, -96.334171);
destination = new GeoCoordinate(30.62505, -96.335362);
navApp = new DroneControllerApp.AutoNavPage();
navApp.connectToDrone();
}
示例10: Seanslar_getCompleted
void Seanslar_getCompleted(seanslar sender)
{
loader.IsIndeterminate = false;
PanoramaRoot.Title = sender.SalonBilgisi.name;
pItem1.DataContext = sender.SalonBilgisi;
listFilmler.ItemsSource = sender.SalonBilgisi.movies;
if (sender.SalonBilgisi.latitude.ToString() != "false")
{
SalonCoordinate = new GeoCoordinate(double.Parse(sender.SalonBilgisi.latitude), double.Parse(sender.SalonBilgisi.longitude));
myMap.SetView(SalonCoordinate, 17);
pinpoint_salon newPin = new pinpoint_salon();
MapOverlay newOverlay = new MapOverlay();
newOverlay.Content = newPin;
newOverlay.GeoCoordinate = SalonCoordinate;
newOverlay.PositionOrigin = new Point(0, 0);
MapLayer MyLayer = new MapLayer();
MyLayer.Add(newOverlay);
myMap.Layers.Add(MyLayer);
}
else
{
myMap.Visibility = Visibility.Collapsed;
recMap.Visibility = System.Windows.Visibility.Collapsed;
}
}
示例11: LocationForAddressEventArgs
public LocationForAddressEventArgs(List<LocationForQuery> locations, string query, GeoCoordinate searchNearLocation, Exception error, object state)
: base(error, state)
{
this.query = query;
this.locations = locations;
this.searchNearLocation = searchNearLocation;
}
示例12: CalculateDistances
public void CalculateDistances(GeoCoordinate clientCoordinate)
{
foreach (var server in Servers)
{
server.Distance = clientCoordinate.GetDistanceTo(server.GeoCoordinate);
}
}
示例13: Show
/// <summary>
/// Shows the Bing Maps application centered on the specified location.
/// </summary>
/// <param name="center">The location that will be used as the center point for the map.</param>
/// <exception cref="InvalidOperationException">Center and SearchTerm cannot both be empty.</exception>
public void Show(GeoCoordinate center)
{
new BingMapsTask()
{
Center = center,
}.Show();
}
示例14: ElementText
/// <summary>
/// Creates a new dot element.
/// </summary>
/// <param name="color"></param>
public ElementText(int color, Font font, GeoCoordinate center, string text)
{
_color = color;
_font = font;
_center = center;
_text = text;
}
示例15: LocationForAddress
public void LocationForAddress(string addressString, GeoCoordinate searchNearLocation, object callerState)
{
GeocodeRequest request = new GeocodeRequest();
request.Credentials = new dev.virtualearth.net.webservices.v1.common.Credentials()
{
ApplicationId = bingMapsApiKey
};
request.Query = addressString;
request.UserProfile = new UserProfile()
{
CurrentLocation = new UserLocation()
{
Latitude = searchNearLocation.Latitude,
Longitude = searchNearLocation.Longitude
},
DistanceUnit = DistanceUnit.Mile,
DeviceType = DeviceType.Mobile,
ScreenSize = new SizeOfint()
{
Width = 480,
Height = 700
}
};
GeocodeState state = new GeocodeState()
{
Query = addressString,
SearchNearLocation = searchNearLocation,
CallerState = callerState
};
geocodeService.GeocodeAsync(request, state);
}