我是Windows Phone开发8.1的新手,我想创建一个文本框,可以使用城市名称(印度)执行自动填写。 我试着安装-pack gmaps-api-net 0.13.4它给了我一个错误。
错误是:您正在尝试定位' Windows Phone,版本= 8.1但该程序包不包含与该框架兼容的任何程序集引用或内容文件。
谢谢&问候, 考希克。
答案 0 :(得分:0)
我认为这个套餐无法正常运行,因为您必须从Google控制台创建浏览器密钥,并按以下方式调用
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);
答案 1 :(得分:0)
首先,你需要创建一个如下所示的类,
public static async Task GetResponse(string url) { 尝试 { // CustomLogger.printMsgOnConsole(" GetResponse中的Url =>" + 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;
}
现在您需要拨打下面的电话,
string myhttp =" https://maps.googleapis.com/maps/api/place/autocomplete/json?input=" + txtCityName.Text.Trim()+"& types = geocode& sensor = false& key =" + mykey;
请注意 1]。 txtCityName是文本框名称。 2]。 mykey是Google Api(网页)生成的密钥。
这将返回json响应。
谢谢, 考希克。