需要先引用:http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex
後臺代碼:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; using GSPGetCity.GeocodeService; namespace GSPGetCity { public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { GeocodeServiceClient client = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); client.ReverseGeocodeCompleted += new EventHandler<ReverseGeocodeCompletedEventArgs>(OnReverseGeocodeCompleted); ReverseGeocodeRequest request = new ReverseGeocodeRequest(); request.Credentials = new Credentials(); request.Credentials.ApplicationId = "AjjGZGtCVs7lEuRn860kGigumg5hhJ8LqKXOIxpk1zwuxxQUgcrFDRWmrYfYCtFg"; Location loc = new Location(); loc.Latitude = 37.736025; loc.Longitude = 115.66153; request.Location = loc; client.ReverseGeocodeAsync(request); } private void OnReverseGeocodeCompleted(object sender, ReverseGeocodeCompletedEventArgs e) { if (e.Error == null) { if (e.Result.Results.Count > 0) { GeocodeResponse response = e.Result; this.textBlock1.Text = response.Results[0].DisplayName; System.Collections.ObjectModel.ObservableCollection<GeocodeResult> list = response.Results; string allName = ""; foreach (GeocodeResult i in list) { allName += i.DisplayName + " "; } this.textBlock2.Text = allName; } else MessageBox.Show("沒有檢索到該地理位置所對應的地點"); } } } }
在中國的座標只能到省, 不夠具體. 我設置的是河北衡水的座標, 得到的地址只能是china hebei, 不知道WP7在中國發布以後會不會好些.
Windows Phone 7 - Image加上Zoom in/out功能 最近不小心迷上用手機看漫畫這件事,所以想說寫一個自己的漫畫程式,這樣可以選擇自己覺得 取得圖像資料比較快且穩定的網站。不過在撰寫過程裡,對於Image的處理
之前用的方法是強制拋出一個錯誤使程序崩潰,下面這種的解決辦法好像更好一些. private void PhoneApplicationPage_BackKeyPress(object sender, System.Compone
登陸網址https://dev.windowsphone.com/zh-cn