0
에서 MainPage.xamlUniversal Windows 응용 프로그램 (UWP)을 사용하여지도에서 사용자를 어떻게 추적합니까?
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0 0 0 0">
<Button x:Name="TrackLocationButton" Margin="120 20 0 0" Content="track location" Click="TrackLocationButton_Click"/>
</StackPanel>
<Maps:MapControl x:Name="MapControl1" HorizontalAlignment="Left" Height="500" Margin="30 100 0 0" Width="300" VerticalAlignment="Top"/>
Mainpage.cs
public double lat;
public double lon;
public int Accurancy;
// Proides access to location data
private Geolocator _geolocator = null;
private void UpdateLocationData(Geoposition position)
{
if (position == null)
{
lat = 0;
lon = 0;
Accurancy = 0;
}
else
{
lat = position.Coordinate.Point.Position.Latitude;
lon = position.Coordinate.Point.Position.Longitude;
Accurancy = Convert.ToInt32(position.Coordinate.Accuracy);
AddLocation(lat, lon);
}
}
private void AddLocation(double s,double s2)
{
BasicGeoposition location = new BasicGeoposition();
location.Latitude = s;
location.Longitude = s2;
MapIcon mapIcon;
mapIcon = new MapIcon();
if (mapIcon != null)
{
MapControl1.MapElements.Remove(mapIcon);
}
mapIcon.Location = new Geopoint(location);
mapIcon.Title = "Azar";
MapControl1.MapElements.Add(mapIcon);
MapControl1.Center = new Geopoint(location);
}
private async void TrackLocationButton_Click(object sender, RoutedEventArgs e)
{
// Request permission to access location
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case GeolocationAccessStatus.Allowed;
_geolocator = new Geolocator { ReportInterval = 2000 };
_geolocator.PositionChanged += OnPositionChanged;
_geolocator.StatusChanged += OnStatusChanged;
}
}
private async void OnStatusChanged(Geolocator sender, StatusChangedEventArgs e)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
{
switch (e.Status)
{
case PositionStatus.Ready:
// message
break;
case PositionStatus.Initializing:
// message
break;
case PositionStatus.NoData:
// message
break;
case PositionStatus.Disabled:
// message
break;
case PositionStatus.NotInitialized:
// message
break;
case PositionStatus.NotAvailable:
// message
break;
default:
// message
break;
}
});
}
private async void OnPositionChanged(Geolocator sender, PositionChangedEventArgs e)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
{
UpdateLocationData(e.Position);
});
}
나는 사용자를 추적하고, 그 다음 내가 때 경우 경로를 여행 사용자가 원하는지도 제어의 시작과 대상 포인트의 경로를 핀 시도 사용자가 경로를 변경하면 알림이 표시됩니까? 그래서 어떻게해야합니까?
미안하지만, 나는 당신이 무엇을 요구하고 있는지 정말로 이해하지 못합니다. [http://stackoverflow.com/help/how-to-ask](http://stackoverflow.com/help/how-to-ask)를 읽고 질문의 문구를 바꾸어보십시오. –
사용자가 경로를 변경 한 후 사용자가 응용 프로그램에서 알림을받을 때지도에서 사용자 위치를 추적하고 싶습니다. – Azarudeen