2015-12-22 87 views
0

我是新的Windows Phone開發8.1,我想創建一個文本框,可以執行地方自動完成城市名稱(印度)。 我試圖安裝包gmaps-api-net 0.13.4它給了我一個錯誤。Windows手機的地方自動完成城市名稱

錯誤的是:您嘗試的目標是'Windows Phone,Version = 8.1,但該軟件包不包含任何與該框架兼容的程序集引用或內容文件。

謝謝&關心, Kaushik。

回答

0

我不這麼認爲這個包會的工作,爲你必須創建谷歌瀏覽器的控制檯鍵,調出像下面

string Entrypoint = String.Format("https://maps.googleapis.com/maps/api/place/autocomplete/json?input={0}&types=geocode&sensor=false&key={1}", txtCityName.Text.Trim(), Constant.GOOGLE_KEY); 
+0

嗨Kushal,你能否提供我詳細的代碼?我是Windows Phone Development中的新手,這是我的第一個應用程序。 –

0

首先,你需要創建如下圖所示的一類,

public static async Task GetResponse(string url) { try {0} {0} {CustomLogger.printMsgOnConsole(「Url in GetResponse =>」+ url); //創建客戶端 HttpClient client = new HttpClient(); //CustomLogger.printMsgOnConsole("HttpClient obj created「+ client);

  //Define URL. Replace current URL with your URL 
      var uri = new Uri(url); 
     // CustomLogger.printMsgOnConsole("Create uri" + uri.ToString()); 
      //Call. Get response by Async 
      var Response = await client.GetAsync(uri); 
      // CustomLogger.printMsgOnConsole("Calling get async"); 
      //Result & Code 
      var statusCode = Response.StatusCode; 
      // CustomLogger.printMsgOnConsole("status code " + statusCode); 
      //If Response is not Http 200 
      //then EnsureSuccessStatusCode will throw an exception 
      Response.EnsureSuccessStatusCode(); 

      //Read the content of the response. 
      //In here expected response is a string. 
      //Accroding to Response you can change the Reading method. 
      //like ReadAsStreamAsync etc.. 
      var ResponseText = await Response.Content.ReadAsStringAsync(); 

      // CustomLogger.printMsgOnConsole("Reponse in GetResponse =>" + ResponseText); 

      return ResponseText; 

     } 

現在你需要給下面所示的電話,

串myhttp = 「https://maps.googleapis.com/maps/api/place/autocomplete/json?input=」 + txtCityName.Text.Trim()+ 「&類型=地理編碼&傳感器=假&關鍵=」 +我的鑰匙;

請注意 1]。 txtCityName是文本框的名稱。 2]。 mykey是由Google Api(網頁)生成的密鑰。

這將返回一個json響應。

謝謝, Kaushik。

相關問題