本文整理汇总了C#中BasicGeoposition类的典型用法代码示例。如果您正苦于以下问题:C# BasicGeoposition类的具体用法?C# BasicGeoposition怎么用?C# BasicGeoposition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicGeoposition类属于命名空间,在下文中一共展示了BasicGeoposition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateCircle
public static List<BasicGeoposition> CalculateCircle(BasicGeoposition center, int radius)
{
List<BasicGeoposition> geoPositions = new List<BasicGeoposition>();
double earthRadius = 6371000D;
double circunference = 2D * Math.PI * earthRadius;
for (int i = 0; i <= 360; i++)
{
double bearing = ToRad(i);
double circunferenceLatitudeCorrected = 2D * Math.PI * Math.Cos(ToRad(center.Latitude)) * earthRadius;
double lat1 = circunference / 360D * center.Latitude;
double lon1 = circunferenceLatitudeCorrected / 360D * center.Longitude;
double lat2 = lat1 + Math.Sin(bearing) * radius;
double lon2 = lon1 + Math.Cos(bearing) * radius;
BasicGeoposition newBasicPosition = new BasicGeoposition();
newBasicPosition.Latitude = lat2 / (circunference / 360D);
newBasicPosition.Longitude = lon2 / (circunferenceLatitudeCorrected / 360D);
geoPositions.Add(newBasicPosition);
}
return geoPositions;
}
示例2: GetPositionFromAddressAsync
public async Task<MapLocation> GetPositionFromAddressAsync(string address)
{
var locator = new Geolocator();
locator.DesiredAccuracyInMeters = 50;
TimeSpan maxAge = new TimeSpan(0, 0, 1);
TimeSpan timeout = new TimeSpan(0, 0, 15);
// var position = await locator.GetGeopositionAsync();
var basicGeoposition = new BasicGeoposition();
var point = new Geopoint(basicGeoposition);
var mapLocationFinderResult = await MapLocationFinder.FindLocationsAsync(address, point, 2);
if (mapLocationFinderResult.Status == MapLocationFinderStatus.Success)
{
try
{
return mapLocationFinderResult.Locations[0];
}
catch (Exception e)
{
return null;
}
}
return default(MapLocation);
}
示例3: AddPushpin
public void AddPushpin(BasicGeoposition location, string text)
{
var pin = new Grid
{
Width = 200,
Height = 100,
Margin = new Thickness(-12),
HorizontalAlignment = HorizontalAlignment.Left
};
var pinImage = new Image { Source = new BitmapImage(new Uri("ms-appx:///Assets/my-position.png")), Width = 60, Height = 60};
pin.Children.Add(pinImage);
pin.Children.Add(new TextBlock
{
TextTrimming = TextTrimming.CharacterEllipsis,
Text = text,
FontSize = 14,
FontWeight = FontWeights.Bold,
Foreground = new SolidColorBrush(Colors.Black),
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top
});
MapControl.SetLocation(pin, new Geopoint(location));
Map.Children.Add(pin);
}
示例4: LocationData
public LocationData(string name, string street, string streetNumber, string zipcode, string city, string country, int rating,
double longitude, double latitude, List<string> openTimes, List<string> closeTimes, List<string> happyhourFrom, List<string> happyhourTo)
{
id = -1;
this.name = name;
this.street = street;
this.streetNumber = streetNumber;
this.zipcode = zipcode;
this.city = city;
this.country = country;
this.rating = rating;
this.longitude = longitude;
this.latitude = latitude;
position = new BasicGeoposition();
position.Longitude = longitude;
position.Latitude = latitude;
pubdays = new List<PubDay>();
for (int i = 0; i < 7; i++)
{
pubdays.Add(new PubDay(i));
}
//getOpenAndClosingTime(openTimes, closeTimes, happyhourFrom, happyhourTo);
}
示例5: handleResults
private async void handleResults(PhotoCollection results, ObservableCollection<ThumbnailImage> List)
{
foreach (var res in results)
{
Geopoint point = null;
if (res.Longitude != 0 && res.Latitude != 0)
{
var position = new BasicGeoposition()
{
Latitude = res.Latitude,
Longitude = res.Longitude
};
point = new Geopoint(position);
}
else if (res.Tags.Contains("cars"))
{
var position = new BasicGeoposition()
{
Longitude = 13.416350,
Latitude = 52.526105
};
point = new Geopoint(position);
}
List.Add(new ThumbnailImage() { ImagePath = new Uri(res.ThumbnailUrl), ImageTitle = res.Title, BigImage = new Uri(res.LargeUrl), GeoLocation = point });
}
}
示例6: AddPushpin
public void AddPushpin(BasicGeoposition location, string text, string id)
{
var pin = new Grid()
{
Width = 50,
Height = 50,
Margin = new Windows.UI.Xaml.Thickness(-12)
};
pin.Children.Add(new Image()
{
Source = new BitmapImage(new Uri("ms-appx:///Assets/pinPoint.png", UriKind.RelativeOrAbsolute)),
Width = 50,
Height = 50
});
pin.Children.Add(new TextBlock()
{
Text = text,
FontSize = 12,
Foreground = new SolidColorBrush(Colors.Yellow),
HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center
});
pin.Tag = id;
pin.Tapped += pin_Tapped;
MapControl.SetLocation(pin, new Geopoint(location));
myMapControl.Children.Add(pin);
}
示例7: BoundedImage
public BoundedImage(MapView map, Uri imageUri, BasicGeoposition northWest, BasicGeoposition southEast)
{
_map = map;
_northWest = northWest;
_southEast = southEast;
_img = new Image();
_img.Stretch = Stretch.Fill;
_img.Source = new BitmapImage(imageUri);
this.Children.Add(_img);
_map.ViewChanged += (center, zoom, heading) =>
{
UpdatePosition();
};
_map.SizeChanged += (s, a) =>
{
this.Width = _map.ActualWidth;
this.Height = _map.ActualHeight;
UpdatePosition();
};
UpdatePosition();
}
示例8: AddMapa
public AddMapa()
{
this.InitializeComponent();
rootFrame = Window.Current.Content as Frame;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility
= AppViewBackButtonVisibility.Visible;
SystemNavigationManager.GetForCurrentView().BackRequested += AddMapa_BackRequested;
mapControl.ZoomInteractionMode = MapInteractionMode.GestureAndControl;
mapControl.TiltInteractionMode = MapInteractionMode.GestureAndControl;
mapControl.MapServiceToken = "ift37edNFjWtwMkOrquL~7gzuj1f0EWpVbWWsBaVKtA~Amh-DIg5R0ZPETQo7V-k2m785NG8XugPBOh52EElcvxaioPYSYWXf96wL6E_0W1g";
// Specify a known location
BasicGeoposition posicion = new BasicGeoposition() { Latitude = 2.4448143, Longitude = -76.6147395 };
Geopoint point = new Geopoint(posicion);
// Set map location
mapControl.Center = point;
mapControl.ZoomLevel = 13.0f;
mapControl.LandmarksVisible = true;
AddIcons();
//GridMapa.Children.Add(mapControl);
}
示例9: ExecuteQuery
// http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631249.aspx
public async Task<List<Portable.Model.GeocodeResult>> ExecuteQuery(string query)
{
throw new NotImplementedException("Not yet fully implemented, testing only");
try
{
// TODO: center for Austria (lat, lon), hint Austria in search string
BasicGeoposition queryHint = new BasicGeoposition();
queryHint.Latitude = 47.643;
queryHint.Longitude = -122.131;
Geopoint hintPoint = new Geopoint(queryHint);
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(query, hintPoint);
if (result.Status == MapLocationFinderStatus.Success)
{
return result.Locations.Select(l => new Portable.Model.GeocodeResult()
{
Latitude = l.Point.Position.Latitude,
Longitude = l.Point.Position.Longitude,
Name = l.DisplayName,
}).ToList();
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
return new List<GeocodeResult>();
}
示例10: getAddressBtn_Click
private async void getAddressBtn_Click(object sender, RoutedEventArgs e)
{
try
{
//Request permission to get location
//Pop up will occur if your app doesnot have permission to access location service of device
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case GeolocationAccessStatus.Allowed:
// The location to reverse geocode.
//For now i am getting my current location
Geolocator geolocator = new Geolocator { DesiredAccuracyInMeters = 50, DesiredAccuracy = PositionAccuracy.High }; //Set the desired accuracy that you want in meters
Geoposition pos = await geolocator.GetGeopositionAsync();
BasicGeoposition location = new BasicGeoposition();
location.Latitude = pos.Coordinate.Point.Position.Latitude;
location.Longitude = pos.Coordinate.Point.Position.Longitude;
Geopoint pointToReverseGeocode = new Geopoint(location);
// Reverse geocode the specified geographic location.
MapLocationFinderResult result =
await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);
// If the query returns results, display the name of the town
// contained in the address of the first result.
if (result.Status == MapLocationFinderStatus.Success)
{
continent.Text = result.Locations[0].Address.Continent;
countryName.Text = result.Locations[0].Address.Country;
countryCode.Text = result.Locations[0].Address.CountryCode;
region.Text = result.Locations[0].Address.Region;
town.Text = result.Locations[0].Address.Town;
street.Text = result.Locations[0].Address.Street;
}
else
{
await new MessageDialog("Something went wrong. Could not get finish current operation. Error: " + result.Status).ShowAsync();
}
break;
case GeolocationAccessStatus.Denied:
//Unable to get data
LoadPositionData(null);
break;
case GeolocationAccessStatus.Unspecified:
//Unable to get data
LoadPositionData(null);
break;
}
}
catch (Exception ex)
{
await new MessageDialog("Something went wrong. Could not get finish current operation.").ShowAsync();
}
}
示例11: button_Click
private async void button_Click(object sender, RoutedEventArgs e)
{
if (MapControl1.IsStreetsideSupported)
{
BasicGeoposition cityPosition = new BasicGeoposition() { Latitude = 48.858, Longitude = 2.295 };
Geopoint cityCenter = new Geopoint(cityPosition);
StreetsidePanorama panoramaNearCity = await StreetsidePanorama.FindNearbyAsync(cityCenter);
if (panoramaNearCity != null)
{
StreetsideExperience ssView = new StreetsideExperience(panoramaNearCity);
ssView.OverviewMapVisible = true;
MapControl1.CustomExperience = ssView;
}
}
else
{
ContentDialog viewNotSupportedDialog = new ContentDialog()
{
Title = "Streetside is not supported",
Content = "\nStreetside views are not supported on this device.",
PrimaryButtonText = "OK"
};
await viewNotSupportedDialog.ShowAsync();
}
}
示例12: button1_Click
private async void button1_Click(object sender, RoutedEventArgs e)
{
if (MapControl1.Is3DSupported)
{
MapControl1.Style = MapStyle.Aerial3D;
BasicGeoposition hwGeoposition = new BasicGeoposition() { Latitude = 48.858, Longitude = 2.295 };
Geopoint hwPoint = new Geopoint(hwGeoposition);
MapScene hwScene = MapScene.CreateFromLocationAndRadius(hwPoint, 80, 0, 60);
await MapControl1.TrySetSceneAsync(hwScene, MapAnimationKind.Bow);
}
else
{
ContentDialog viewNotSupportedDialog = new ContentDialog()
{
Title = "3D is not supported",
Content = "\n3D views are not supported on this device.",
PrimaryButtonText = "OK"
};
await viewNotSupportedDialog.ShowAsync();
}
}
示例13: GetRandomPoints
public static IEnumerable<PointList> GetRandomPoints(Geopoint point1, Geopoint point2, int nrOfPoints)
{
var result = new List<PointList>();
var p1 = new BasicGeoposition
{
Latitude = Math.Min(point1.Position.Latitude, point2.Position.Latitude),
Longitude = Math.Min(point1.Position.Longitude, point2.Position.Longitude)
};
var p2 = new BasicGeoposition
{
Latitude = Math.Max(point1.Position.Latitude, point2.Position.Latitude),
Longitude = Math.Max(point1.Position.Longitude, point2.Position.Longitude)
};
var dLat = p2.Latitude - p1.Latitude;
var dLon = p2.Longitude - p1.Longitude;
var r = new Random(DateTime.Now.Millisecond);
for (var i = 0; i < nrOfPoints; i++)
{
var item = new PointList { Name = "Point " + i };
item.Points.Add(new Geopoint(
new BasicGeoposition
{
Latitude = p1.Latitude + (r.NextDouble() * dLat),
Longitude = p1.Longitude + (r.NextDouble() * dLon)
}));
result.Add(item);
}
return result;
}
示例14: GetAtDistanceBearing
private BasicGeoposition GetAtDistanceBearing(BasicGeoposition point, double distance, double bearing)
{
double degreesToRadian = Math.PI / 180.0;
double radianToDegrees = 180.0 / Math.PI;
double earthRadius = 6378137.0;
double latA = point.Latitude * degreesToRadian;
double lonA = point.Longitude * degreesToRadian;
double angularDistance = distance / earthRadius;
double trueCourse = bearing * degreesToRadian;
double lat = Math.Asin(
Math.Sin(latA) * Math.Cos(angularDistance) +
Math.Cos(latA) * Math.Sin(angularDistance) * Math.Cos(trueCourse));
double dlon = Math.Atan2(
Math.Sin(trueCourse) * Math.Sin(angularDistance) * Math.Cos(latA),
Math.Cos(angularDistance) - Math.Sin(latA) * Math.Sin(lat));
double lon = ((lonA + dlon + Math.PI) % (Math.PI * 2)) - Math.PI;
BasicGeoposition result = new BasicGeoposition { Latitude = lat * radianToDegrees, Longitude = lon * radianToDegrees };
return result;
}
示例15: showSpaceNeedleButton_Click
private async void showSpaceNeedleButton_Click(object sender, RoutedEventArgs e)
{
if (myMap.Is3DSupported)
{
this.myMap.Style = MapStyle.Aerial3DWithRoads;
BasicGeoposition spaceNeedlePosition = new BasicGeoposition();
spaceNeedlePosition.Latitude = 47.6204;
spaceNeedlePosition.Longitude = -122.3491;
Geopoint spaceNeedlePoint = new Geopoint(spaceNeedlePosition);
MapScene spaceNeedleScene = MapScene.CreateFromLocationAndRadius(spaceNeedlePoint,
400, /* show this many meters around */
135, /* looking at it to the south east*/
60 /* degrees pitch */);
await myMap.TrySetSceneAsync(spaceNeedleScene);
}
else
{
string status = "3D views are not supported on this device.";
rootPage.NotifyUser(status, NotifyType.ErrorMessage);
}
}