我正在使用新的 Windows Phone 8 地图和地图工具包。在每个PositionChanged
事件中,我将 设置UserLocationMarker
为新位置。如果用户点击UserLocationMarker
,我将通过显示地图位置ReverseGeocodeQuery
并将用户位置图钉设置为可见。为了快速做到这一点,我ReverseGeocodeQuery
在PositionChanged
事件中执行。
我的问题是,如果用户位置变化很快,它会执行很多ReverseGeocodeQuery
s。这是性能问题吗?
private void InitializeGeolocator()
{
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.MovementThreshold = 5;
geolocator.StatusChanged += geolocator_StatusChanged;
geolocator.PositionChanged += geolocator_PositionChanged;
}
private void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
Geoposition geoposition = args.Position;
this.UserLocationMarker.GeoCoordinate = geoposition.Coordinate.ToGeoCoordinate();
this.UserLocationMarker.Visibility = System.Windows.Visibility.Visible;
// execute ReverseGeocodeQuery...
// set Pushpin
});
}
private void userLocationMarker_tap(object sender, GestureEventArgs e)
{
// show user location pushpin...
UserLocationPushpin.Visibility = Visibility.Visible;
}