高德API 地址编码,转为经纬度

请求该接口需要申请一个key,可以去高德地图开放平台免费申请哈;

  using (var httpClient = new HttpClient())
  {
      var key = "高德地图key";
      var address = "地址";

    //str是获取地址经纬度的接口
      var str = string.Format("https://restapi.amap.com/v3/geocode/geo?key={0}&address={1}&batch=false", key, address);
      var url = new Uri(str);
      var response = httpClient.GetAsync(url).Result;
      var data = response.Content.ReadAsStringAsync().Result;

      dynamic jsonData = JsonConvert.DeserializeObject(data);//转为json
      var geocodes = jsonData.geocodes; //定位
      var status = jsonData.status.Value;//状态
      var count = jsonData.count.Value;//数量
      var location = geocodes[0].location;//金纬度
   }

 

posted on 2020-04-29 18:40  阿里正正  阅读(413)  评论(0编辑  收藏  举报

导航