|
楼主 |
发表于 2017-5-15 15:01:38
|
显示全部楼层
Model.prototype.button1Click = function(event){
var id = this.getIDByXID("container");
var self = this;
var data=this.comp("statusData");
window._baiduInit = function() {
var map = new BMap.Map(id,{minZoom:2,enableMapClick:true}); //创建地图对象,可以设置地图缩放最大最小级别,设置是否显示POI点击
var geoc = new BMap.Geocoder();
var localSearch = new BMap.LocalSearch(map, {
renderOptions : {
pageCapacity : 8,
autoViewport : true,
selectFirstResult : false
}
});
localSearch.enableAutoViewport();
var keyword = self.getElementByXid("input5").value;
alert(keyword);
localSearch.setSearchCompleteCallback(function(searchResult) {
var poi = searchResult.getPoi(0);
$(self.getElementByXid("input6")).text(poi.point.lng);
alert(poi.point.lng + " " + poi.point.lat);
//map.centerAndZoom(poi.point, 8);
});
localSearch.search(keyword);
};
require([ 'http://api.map.baidu.com/api?v=2.0&ak=Y83GQasuZaacQqo5xY1oEbMVtXVPMsDB&callback=_baiduInit' ], function() {
if (window.BMap && window.BMap.Map) {
window._baiduInit();
}
});
};
|
|