【问题标题】:Google Map Api to Find Only Address Name And Postal Code Of all Shops in CityGoogle Map Api 仅查找市内所有商店的地址名称和邮政编码
【发布时间】:2016-12-26 07:09:46
【问题描述】:

我正在尝试获取特定城市(例如阿姆斯特丹)中所有商店的地址名称和邮政编码信息。
我想在这个网站上做同样的事情。
https://www.openingstijden.nl/Noord-Holland/Amsterdam/Drukkerijen/
但我正在创建一个桌面应用程序。
我正在尝试这个 Url
https://maps.googleapis.com/maps/api/js?sensor=false&language=nl&key=MY_API_KEY&callback=gmap_draw 来获取,但我对 javascript 的了解并不深。 如果这是正确的方法,任何人都可以建议我如何以 xml 格式获取相同的结果,如果不是,那么获取与本网站上可用的相同结果的正确方法是什么?

提前致谢

【问题讨论】:

  • 阅读 c# 案例的文档。在 c# 中显示相关代码,否则在本论坛中显示它的题外话。

标签: c# google-maps google-maps-api-3 xml-parsing


【解决方案1】:

您提供的 URL 是调用 API 的 JS 参考。

string urlParameters = "";
        //Your code goes here
        HttpClient client = new HttpClient();
        client.BaseAddress = new Uri("https://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA");

        // Add an Accept header for XML format.
        client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/xml"); //Keeps returning false
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));

        // List data response.
        HttpResponseMessage response = client.GetAsync(urlParameters).Result;
        //Console.WriteLine(response);
         if (response.IsSuccessStatusCode)
            {
               // output xml
               string output = response.Content.ReadAsStringAsync().Result;
             //response.Content.ReadAsStringAsync();
             Console.WriteLine(output);
            }

您可以编辑 URI 构造函数以包含地址/组件、键等参数。在此处输入代码 请参阅文档以获取更多信息。 https://developers.google.com/maps/documentation/geocoding/intro

【讨论】:

  • 好吧,我想我不能在桌面应用程序中调用它我已经提到我正在使用 c# 使用桌面应用程序
猜你喜欢
  • 2018-08-22
  • 2015-06-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-04
  • 2011-01-19
  • 2022-01-08
相关资源
最近更新 更多