var longtitude = 0;
var latitude = 0;
function GetPostion() {
//通过百度获取经纬度
var address = "具体的地理位置 ";
var url = "http://api.map.baidu.com/geocoder/v2/?address=" + address + "&output=json&ak=FG7wxr1VUj0k2NwoO3yXzymd&callback=?";
$.getJSON(url, function (data) {
longtitude = data.result.location.lng;
latitude = data.result.location.lat;
});
}
//引用百度的资源api,申请ak获取经纬度(亲测)
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=a7PqrtFp5LdUueXsKTw5GDAN"></script>
function theLocation(lng,lat){
//var new_point = new BMap.Point(116.331398,39.897445);
var new_point = new BMap.Point(lng,lat);
var gc = new BMap.Geocoder();
gc.getLocation(new_point, function(rs){
var addComp = rs.addressComponents;
//alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
$("#jwd").val(addComp.city);
loadYuYue();
});
}