用经纬度获取百度地图位置


$(".mapnav").click(function(){
var latlon = $(this).attr("latlon");
var content = $(this).parents("article:first").find("h1:first").text();
if(latlon != ""){
jConfirm("确认要访问百度地图?",null, function(rs){
if(rs){
var latlons = latlon.split(",");

$.ajax({
type: "GET",
url: "/index.php?g=WShop&m=AjaxPublic&a=getMapxy",
data: {latitude:latlons[0], longitude:latlons[1]},
dataType: "json",
success: function(data){
var mapUrl = "http://map.baidu.com/mobile/webapp/place/marker/qt=inf&vt=map&act=read_share&code=194/third_party=uri_api&point="+data.x+"|"+data.y+"&title=门店位置&content="+content+";
location.href = mapUrl;
}
});
}
});
}
})

public function getMapxy(){
$latitude = $_GET['latitude'];
$longitude = $_GET['longitude'];
$url = "http://api.map.baidu.com/geoconv/v1/?coords=$longitude,$latitude&from=5&to=6&ak=39bcc301207f2d62ed4ecf3cba8be379";
$file_contents = file_get_contents($url);
$mapxy = (array)json_decode($file_contents);
$this->ajaxReturn($mapxy['result'][0]);
}

声明:祁志飞||小祁的博客|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - 用经纬度获取百度地图位置


QQ:137867590