var ws=null,wo=null;
var em=null,map=null;
// H5 plus事件处理
function plusReady(){
if(!em||ws){return};
// 获取窗口对象
ws=plus.webview.currentWebview();
wo=ws.opener();
setTimeout(function(){
map=new plus.maps.Map("map");
map.centerAndZoom(new plus.maps.Point(106.507568,29.613543),16);
createMarker();
// 创建子窗口
createSubview();
},300);
// 显示页面并关闭等待框
ws.show("slide-in-right",300);
wo.evalJS("closeWaiting()");
}
if(window.plus){
plusReady();
}else{
document.addEventListener("plusready",plusReady,false);
}
// DOMContentloaded事件处理
document.addEventListener("DOMContentLoaded",function(){
em=document.getElementById("map");
window.plus&&plusReady();
},false);
function userLocation(){
map.showUserLocation( true );
map.getUserLocation(function(state,pos){
if(0==state){
map.setCenter(pos);
}
});
}
function createMarker(){
var marker=new plus.maps.Marker(new plus.maps.Point(106.507568,29.613543));
marker.setIcon("img/iconfont-location.png");
// marker.setLabel("谢谢");
var bubble = new plus.maps.Bubble("麻烦了");
marker.setBubble(bubble);
map.addOverlay(marker);
}
function createSubview(){
if('Android'!=plus.os.name){
return;
}//这里注释起来也之后可以IOS上显示出来,但是地图变成了静态的,页面也无法点击。
var wsub=plus.webview.create('maps_map_sub.html','sub',{top:'44px',height:'60px',position:'absolute',scrollIndicator:'none',background:'red',border:'1px solid red'});
ws.append(wsub);
}
function resetMap(){
map.centerAndZoom(new plus.maps.Point(106.507568,29.613543),6);
}