Home  >  Article  >  Web Front-end  >  在jquery boxy中添加百度地图坐标拾取注意流程_jquery

在jquery boxy中添加百度地图坐标拾取注意流程_jquery

WBOY
WBOYOriginal
2016-05-16 16:53:351182browse

作为开发的初学者,这东西仅仅作为个人备份,如果能帮到忙也也不错(我开发用的php,但这是js这本身没多大影响)

这里要说明几个问题:

1.boxy调用的页面中不能出现《script》标签不然不能显示

2.boxy调用的时候要注意流程,要先加载出boxy然后再去渲染地图到boxy页面中

3.百度地图的加载js应放在弹出boxy的那个页面中

注意流程:boxy页面其实为单独的一个页面只是用了ajax中$.get('/index.php?r=comm/map_coordinate', function(data){}方法来调用页面

关键触发js如下:

复制代码 代码如下:

(function(){
$(document).ready(function() {

$("#Mechine_mec_points").click(function(){

__MC.Map_coordinate.getcorrdinate();

});
});

__MC.Map_coordinate = {
getcorrdinate:function(){

$.get('/index.php?r=comm/map_coordinate', function(data){ //调用boxy对应的页面,页面中就只有一个id=allmap的div



new Boxy(data,{ //在外面已经加载好百度地图AIP的js
'title':'地图坐标拾取',
'modal':true,
'draggable':false,
'unloadOnHide' : true,
'afterShow' : function(){


var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(106.566872, 29.536861), 17);
map.enableScrollWheelZoom(); //启用滚轮放大缩小,默认禁用
map.enableContinuousZoom(); //启用地图惯性拖拽,默认禁用
function showInfo(e){
$("#Mechine_mec_points").val(e.point.lng + ", " + e.point.lat);
}
map.addEventListener("click", showInfo);

}//aftershow结束
});

return false;
});

},
}
})();
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn