标签:cat out oca query doc com 1.5 long geo
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> 请输入经纬度 <input type="text" placeholder="请输入经度" id="long" value="121.51155629576095" /> <input type="text" placeholder="请输入纬度" id="lati" value="38.86043635958201"/> <input type="button" value="查询" id="btn1" /> <script src="js/jquery.js"></script> <script> $(function() { $(‘#btn1‘).click(function() { //获得经纬度值 var long = $(‘#long‘).val(); var lati = $(‘#lati‘).val(); //请求的url地址(jsonp请求) var url = ‘http://api.map.baidu.com/geocoder/v2/?output=json&ak=Q6aiD950lCsEWDWblF8T5BzQjxeUylCj&callback=?‘; //发送的参数 var params = { location:lati + ‘,‘ + long, coord_type:‘wgs84‘ } $.getJSON(url,params,function(data) { console.log(data); alert(‘查询位置:‘ + data.result.formatted_address); }) .error(function(xhr,errorStatus,errorText){ alert(‘请求失败!‘ + errorStatus + ‘,‘ + errorText + ‘,‘ + xhr.status); }); }); }); </script> </body> </html>
标签:cat out oca query doc com 1.5 long geo
原文地址:http://www.cnblogs.com/1020182600HENG/p/7278363.html