高德地图api接口
最近在学习高德地图api接口调用,需要获取场景的一些信息,最重要的是获取轮廓图
需要的接口基本都有 轮廓图的接口没有
获取基本信息
https://lbs.amap.com/api/webservice/summary/
查找到自己需要的接口
并调用
public static string GetDataByWhere(string city,string type,int offset,int page, string keywords="",int timeout = 10000)
{
string url = "https://restapi.amap.com/v3/place/text?key={0}&keywords={1}&types={2}&city={3}&children=1&offset={4}&page={5}&extensions=all";
url = string.format(url, key, keywords, type, city, offset, page);
return GetLocationByURL(url, timeout);
}
/// <summary>
/// 根据URL获取地址
/// </summary>
/// <param name="url">Get方法的URL</param>
/// <param name="timeout">超时时间默认10秒</param>
/// <returns></returns>
private static string GetLocationByURL(string url, int timeout = 10000)
{
string strResult = "";
try
{
HttpWebrequest req = WebRequest.Create(url) as HttpWebRequest;
req.contentType = "multipart/form-data";
req.Accept = "*/*";
//req.useragent = "Mozilla/4.0 (compatible; MSIE 6.0; windows NT 5.1; SV1; .NET CLR 2.0.50727)";
req.UserAgent = "";
req.Timeout = timeout;
req.Method = "GET";
req.KeepAlive = true;
HttpWebresponse response = req.GetResponse() as HttpWebResponse;
using (streamreader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
strResult = sr.ReadToEnd();
}
}
catch (Exception ex)
{
strResult = "";
}
return strResult;
}
就这样
轮廓接口
https://gaode.com/service/poiInfo?query_type=IDQ&pagesize=20&pagenum=1&qii=true&cluster_state=5&need_utd=true&utd_sceneid=1000&p=PC1000&addr_poi_merge=true&is_classify=true&zoom=11&id=B000A88EBH
public static string GetLuokuoData(string poiid, string querytype = "IDQ", int timeout = 10000)
{
// https://www.amap.com/service/poiInfo?query_type=TQUERY&pagesize=20&pagenum=1&qii=true&cluster_state=5&need_utd=true&utd_sceneid=1000&p=PC1000&addr_poi_merge=true&is_classify=true&zoom=18&city=530100&geoobj=102.786068%7C25.053343%7C102.792128%7C25.054913&keywords=%E8%8A%B1%E4%B9%8B%E5%9F%8E
// string url = "https://gaode.com/service/poiInfo?query_type=IDQ&pagesize=20&pagenum=1&qii=true&cluster_state=5&need_utd=true&utd_sceneid=1000&p=PC1000&addr_poi_merge=true&is_classify=true&zoom=11&id=B000A88EBH";
string url = "https://gaode.com/service/poiInfo?query_type={0}&pagesize=5000&pagenum=1&qii=true&cluster_state=5&need_utd=true&utd_sceneid=1000&p=PC1000&addr_poi_merge=true&is_classify=true&zoom=11&id={1}";
url = string.Format(url, querytype, poiid);
return GetLocationByURL(url, timeout);
}
综上即可获取一个场景下面的信息和轮廓数组之后解析
解析
/// <summary>
/// 获取当前的数据
/// </summary>
/// <param name="pricent">省份</param>
/// <param name="type">类型</param>
/// <param name="keywork">关键字</param>
public void GetData(string cityname,string type,string keywork)
{
string json = "";
json = AmapUtil.GetDataByWhere(cityname, type, 50,1, keywork);
JObject o = JObject.Parse(json);
IList<JObject> allDrives = o["pois"].Select(t => (JObject)t).ToList();
foreach (JObject j in allDrives)
{
// object a = j;
string id = j["id"].ToString();
string name = j["name"].ToString();
string types = j["type"].ToString();
string address = j["address"].ToString();
string location = j["location"].ToString();
string pcode = j["pcode"].ToString();
string pname = j["pname"].ToString();
string cityID = j["citycode"].ToString();
string citynames = j["cityname"].ToString();
string adcode = j["adcode"].ToString();
string adname = j["adname"].ToString();
console.WriteLine(j.ToString());
string[] local = location.Split(',');
string json1 = AmapUtil.GetLuokuoData(id);
JObject o1 = JObject.Parse(json1);
string dd1 = o1["data"].ToString();
JObject od1 = JObject.Parse(dd1);
IList<JToken> s1 = od1["poi_list"].ToList();
foreach (JToken jtt in s1)
{
string df = jtt["domain_list"].ToString();
IList<JToken> s2 = jtt["domain_list"].ToList();
foreach (JToken jt in s2)
{
string names = jt["name"].ToString();
if (names == "aoi")
{
string value = jt["value"].ToString();
string[] a = value.Split('_');
string truevalue = "";
for (int i = 0; i < a.Length; i++)
{
truevalue += "[" + a[i] + "],";
}
if (!string.IsNullOrempty(truevalue))
{
truevalue = truevalue.substring(0, truevalue.Length - 1);
}
truevalue = "[[" + truevalue + "]]";
}
}
}
}
}
相关阅读
简介: 1. 查询hscode的基本商品信息。 站点数据仅供参考。具体请查询海关总署:http://www.customs.gov.cn/customs/302427/302442
百度地图默认显示的地图类型是BMAP_NORMAL_MAP(普通类型)想要默认显示卫星地图(二选一即可):代码1:var map = new BMap.Map("allm
协处理器 过滤器减少服务器端通过网络返回到客户端 的数据量 协处理器(coprocessor):HBase把部分计算移到数据的存放端 协处理器简介
作者:兔四链接:https://zhuanlan.zhihu.com/p/26965602来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出
Detected problems with API 弹窗 屏蔽解决方案 andro
最近项目测试MM反馈每次进入app,会提示一个弹窗。 调查测试发现是android9.0系统上产生的,综合网上各位前被采坑的资料分享。先把