|
需要对具体的经纬度做地址逆解析,参考官方文档:
[url=]请求URL[/url]该请求为GET请求 http://apis.map.qq.com/ws/geocoder/v1/?location=
在浏览器里直接输入:http://apis.map.qq.com/ws/geocoder/v1/?location=23.357341,103.163205&key=XXXXXX
可以正确返回结果。
在wex5里
- $.ajax({
- type : "GET",
- async:false,
- url : "http://apis.map.qq.com/ws/geocoder/v1/?location=23.357341,103.163205&key=XXX",
- success : function(result){
- alert(result);
- }
复制代码 出现:
- XMLHttpRequest cannot load http://apis.map.qq.com/ws/geocoder/v1/?location=23.357341,103.163205&key=XXX. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
复制代码 然后就是
- Uncaught Error: __justepClientErrorStart__{"code":"JUSTEP230109","message":"网络出错"}__justepClientErrorEnd__l.create @ core.min.js:71(anonymous function) @ core.min.js:71
复制代码 在开发者工具的network里其实已经返回了数据:
- {
- "status": 0,
- "message": "query ok",
- "request_id": "786882144500338501",
- "result": {
- "location": {
- "lat": 23.357341,
- "lng": 103.163205
- },
- "address": "云南省红河哈尼族彝族自治州个旧市绿春巷",
- "formatted_addresses": {
- "recommend": "城区街道个旧市",
- "rough": "城区街道个旧市"
- },
- "address_component": {
- "nation": "中国",
- "province": "云南省",
- "city": "红河哈尼族彝族自治州",
- "district": "个旧市",
- "street": "绿春巷",
- "street_number": "绿春巷"
- },
- "ad_info": {
- "adcode": "532501",
- "city_code": "156532501",
- "name": "中国,云南省,红河哈尼族彝族自治州,个旧市",
- "location": {
- "lat": 23.357342,
- "lng": 103.163208
- },
- "nation": "中国",
- "province": "云南省",
- "city": "红河哈尼族彝族自治州",
- "district": "个旧市"
- },
- "address_reference": {
- "street_number": {
- "title": "",
- "location": {
- "lat": 23.358219,
- "lng": 103.16143
- },
- "_distance": 200.8,
- "_dir_desc": "东"
- },
- "crossroad": {
- "title": "五一路/天桥路(路口)",
- "location": {
- "lat": 23.357031,
- "lng": 103.159378
- },
- "_distance": 387.4,
- "_dir_desc": "东"
- },
- "town": {
- "title": "城区街道",
- "location": {
- "lat": 23.357342,
- "lng": 103.163208
- },
- "_distance": 0,
- "_dir_desc": "内"
- },
- "street": {
- "title": "绿春巷",
- "location": {
- "lat": 23.358219,
- "lng": 103.16143
- },
- "_distance": 200.8,
- "_dir_desc": "东"
- },
- "landmark_l2": {
- "title": "个旧市",
- "location": {
- "lat": 23.359119,
- "lng": 103.160027
- },
- "_distance": 380.6,
- "_dir_desc": "东南"
- }
- }
- }
- }
复制代码 这个需要如何搞?谢谢!
|
|