我开发了一个简单的地图控件,它使用谷歌服务而不是bing。这是Windows手机7.1。我需要通过查找我的位置获取文本块上的街道名称,然后将其街道名称女巫显示在文本块上。帮助我们:(。下面的代码显示了获取设备位置的所有方法。
public void StartLocationService(GeoPositionAccuracy accuracy)
{
Watcher = new GeoCoordinateWatcher(accuracy);
Watcher.MovementThreshold = 10;
Watcher.StatusChanged += Watcher_StatusChanged;
Watcher.PositionChanged += Watcher_PositionChanged;
Watcher.Start();
}
void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => MyPositionChanged(e));
}
void Watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => MyStatusChanged(e));
}
void MyStatusChanged(GeoPositionStatusChangedEventArgs e)
{
switch (e.Status)
{
case GeoPositionStatus.Disabled:
MessageBox.Show("Location is unsupported on this device", "Error", MessageBoxButton.OK);
break;
case GeoPositionStatus.Ready:
break;
}
}
void MyPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Pushpin p = new Pushpin();
p.Background = new SolidColorBrush(Colors.Black);
p.Foreground = new SolidColorBrush(Colors.White);
p.Location = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude);
p.Content = "I'm Here";
p.Tag = "pintag";
if (MapControl1.Children.Contains(p))
{
var pushpin=MapControl1.Children.First(x => (x.GetType() == typeof(Pushpin) && ((Pushpin)x).Tag == "pintag"));
MapControl1.Children.Remove(pushpin);
MapControl1.Children.Add(p);
}
else
{
MapControl1.Children.Add(p);
}
MapControl1.SetView(new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude, 200), 18);
}
答案 0 :(得分:0)
尝试使用地理编码谷歌API
http://maps.googleapis.com/maps/api/geocode/json?latlng=19.333332,{1}&sensor=true
更多信息Here