[英]Get street name on windows phone 7 map control with google map layer
我開發了一個簡單的地圖控件,該控件使用google服務而不是bing。 這是Windows Phone 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);
}
嘗試使用地理編碼Google API
http://maps.googleapis.com/maps/api/geocode/json?latlng=19.333332,{1}&sensor=true
更多信息在這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.