本文整理汇总了C#中Geopoint类的典型用法代码示例。如果您正苦于以下问题:C# Geopoint类的具体用法?C# Geopoint怎么用?C# Geopoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Geopoint类属于命名空间,在下文中一共展示了Geopoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnLoaded
// TODO: test data
private async void OnLoaded(object sender, RoutedEventArgs e)
{
var locator=new Geolocator();
var geoposition = await locator.GetGeopositionAsync();
UserLocation = new Geopoint(new BasicGeoposition
{
Latitude = geoposition.Coordinate.Latitude,
Longitude = geoposition.Coordinate.Longitude
});
var file = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\service-icon.png");
var geolocator = new Geolocator();
var myPosition = await geolocator.GetGeopositionAsync();
Recipients = new[]
{
new Recipient
{
Name = "Recipient",
Birthday = DateTime.Now.AddYears(-20),
Latitude = myPosition.Coordinate.Latitude,
Longitude = myPosition.Coordinate.Longitude,
Description = "I'm so depressed...",
IsActive = true,
MainPhoto = await ConvertionExtensions.ReadFile(file)
}
};
}
示例2: GetNearMapItems
public async Task GetNearMapItems(Geopoint currentGeopoint)
{
if (_currentElements == null)
{
_currentElements = await _cicloStationService.GetCicloStationsAsync();
}
var result = _currentElements.Select(pre => new MapItem()
{
Id = pre.id,
Geopoint = new Geopoint(new BasicGeoposition()
{
Latitude = pre.location.Lat,
Longitude = pre.location.Lon
}),
ItemType = ItemType.EcobiciStation,
Name = pre.name
});
result = result
.OrderBy(pre => pre.Geopoint.CalculateDistance(currentGeopoint))
.Where(pre => pre.Geopoint.CalculateDistance(currentGeopoint) <= 1)
.Take(5);
GetNearMapItemsCompleted?.Invoke(this, new NearMapItemEventArgs(result));
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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();
}
}
示例6: RequestImage
//string imagerySet = MapType.Aerial.ToString();
public async Task<WriteableBitmap> RequestImage(Geopoint point)
{
if (geo == null)
{
geo = new Geolocator();
}
Geoposition pos = await geo.GetGeopositionAsync();
//Geopoint point = pos.Coordinate.Point;
myMap.Center = new Location(point.Position.Latitude, point.Position.Longitude);
myMap.ZoomLevel = 2;
myMap.Width = 100;
this.myMap.Height = 100;
string url = String.Format("http://dev.virtualearth.net/REST/v1/Imagery/Map/{0}/{1},{2}/{3}" +
"?mapSize={4},{5}&key={6}",
//imagerySet,
this.myMap.Center.Latitude,
this.myMap.Center.Longitude,
Math.Floor(this.myMap.ZoomLevel),
this.myMap.Width,
this.myMap.Height,
apiKey);
var backgroundDownloader = new BackgroundDownloader();
var file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("tempmapimage.jpg",
CreationCollisionOption.ReplaceExisting);
var downloadOperation = backgroundDownloader.CreateDownload(new Uri(url), file);
await downloadOperation.StartAsync();
return await BitmapFactory.New(1, 1).FromStream(await file.OpenReadAsync(),
Windows.Graphics.Imaging.BitmapPixelFormat.Unknown);
}
示例7: 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();
}
}
示例8: button_Click
async private void button_Click(object sender, RoutedEventArgs e)
{
LocationProvider providerLocation = new LocationProvider();
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case GeolocationAccessStatus.Allowed:
// If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy.Default is used.
Geolocator geolocator = new Geolocator { DesiredAccuracyInMeters = 2000 };
// Carry out the operation.
Geoposition pos = await geolocator.GetGeopositionAsync();
Geopoint geo = new Geopoint(new BasicGeoposition { Latitude = pos.Coordinate.Point.Position.Latitude, Longitude = pos.Coordinate.Point.Position.Longitude });
providerLocation.AddLocation(geo, 1);
this.Frame.Navigate(typeof(Friends), pos);
break;
case GeolocationAccessStatus.Denied:
break;
case GeolocationAccessStatus.Unspecified:
break;
}
}
示例9: 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;
}
示例10: OnNavigatedTo
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
Geopoint myPoint;
if (e.Parameter == null)
{
//Add
isViewing = false;
var locator = new Geolocator();
locator.DesiredAccuracyInMeters = 50;
// MUST ENABLE THE LOCATION CAPABILITY!!
var position = await locator.GetGeopositionAsync();
myPoint = position.Coordinate.Point;
}
else
{
//View or Delete
isViewing = true;
lifeThread = (LifeThread)e.Parameter;
titleTextBox.Text = lifeThread.Title;
noteTextBox.Text = lifeThread.Thread;
addButton.Content = "Delete";
var myPosition = new Windows.Devices.Geolocation.BasicGeoposition();
myPosition.Latitude = lifeThread.Latitude;
myPosition.Longitude = lifeThread.Longitude;
myPoint = new Geopoint(myPosition);
}
await MyMap.TrySetViewAsync(myPoint, 16d);
}
示例11: Contains
public static bool Contains(List<Geopoint> polyPoints, Geopoint point)
{
bool inside = false;
Geopoint p1, p2;
//iterate each side of the polygon
Geopoint oldPoint = polyPoints[polyPoints.Count - 1];
foreach (Geopoint newPoint in polyPoints)
{
//order points so p1.lat <= p2.lat;
if (newPoint.Position.Latitude > oldPoint.Position.Latitude)
{
p1 = oldPoint;
p2 = newPoint;
}
else
{
p1 = newPoint;
p2 = oldPoint;
}
//test if the line is crossed and if so invert the inside flag.
if ((newPoint.Position.Latitude < point.Position.Latitude) == (point.Position.Latitude <= oldPoint.Position.Latitude)
&& (point.Position.Longitude - p1.Position.Longitude) * (p2.Position.Latitude - p1.Position.Latitude)
< (p2.Position.Longitude - p1.Position.Longitude) * (point.Position.Latitude - p1.Position.Latitude))
{
inside = !inside;
}
oldPoint = newPoint;
}
return inside;
}
示例12: MapView
public MapView()
{
mapControl = new MapControl();
mapControl.ZoomInteractionMode = MapInteractionMode.GestureAndControl;
mapControl.TiltInteractionMode = MapInteractionMode.GestureAndControl;
mapControl.MapServiceToken = "ift37edNFjWtwMkOrquL~7gzuj1f0EWpVbWWsBaVKtA~Amh-DIg5R0ZPETQo7V-k2m785NG8XugPBOh52EElcvxaioPYSYWXf96wL6E_0W1g";
// Specify a known location
BasicGeoposition cityPosition;
Geopoint cityCenter;
cityPosition = new BasicGeoposition() { Latitude = 2.4448143, Longitude = -76.6147395 };
cityCenter = new Geopoint(cityPosition);
// Set map location
mapControl.Center = cityCenter;
mapControl.ZoomLevel = 13.0f;
mapControl.LandmarksVisible = true;
AddIcons();
this.Children.Add(mapControl);
//this.Children.Add(_map);
}
示例13: addPinsToMap
public void addPinsToMap(MapControl mapControl, Action<MapPin> tappedCallback = null)
{
removePinsFromMap(mapControl);
m_mapPins = new List<MapPin>();
int i = 1;
DB_station prevStation = null;
foreach (List<DB_station> route in m_routes)
{
foreach(DB_station station in route)
{
if (station == prevStation || (station.latitude == 0f && station.longitude == 0f))
continue;
// Title for station.
string title = "Przystanek " + (i++) + "\n" + station.post_id + " " + station.post_name + "\n" + station.street;
// Add pin into map.
var location = new Geopoint(new BasicGeoposition()
{
Latitude = station.latitude,
Longitude = station.longitude
});
MapPin pin = new MapPin(title, station, MapPin.PinType.RegularPin, MapPin.PinSize.Small, tappedCallback);
pin.addToMap(mapControl, location);
m_mapPins.Add(pin);
prevStation = station;
}
}
}
示例14: 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 });
}
}
示例15: 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);
}