蚂蚁彩票

正在努力为您加载地图,请稍后...
X
显示路线
友情链接:七彩娱乐  UC彩票  UC彩票官网  UC彩票官网  UC彩票注册  UC彩票  

免责声明: 本站资料及图片来源互联网文章,本网不承担任何由内容信息所引起的争议和法律责任。所有作品版权归原创作者所有,与本站立场无关,如用户分享不慎侵犯了您的权益,请联系我们告知,我们将做删除处理!


	var thisPoint,showaddress='';	
	var scrollObj,referrerURL = window.document.referrer;
	var is_SYStem = !referrerURL || referrerURL.indexOf('dmin.php')>0 ? true : false;
	
	function iscrollloaded(){
		if(typeof(iScroll)!='undefined')scrollObj = new iScroll('transition', { useTransition:true });
	}
	document.addEventListener('touchmove', function (e){e.preventDefault(); }, false);
	document.addEventListener('DOMContentLoaded', iscrollloaded, false);
	
	function init() {
		var dituContent = document.getElementById('dituContent');
		if (!window.BMap){
			dituContent.innerHTML = '亲,您的浏览器不支持地图后台预览功能,请更换浏览器再试';
			return;// [FF]切换模式后报错
		}
		dituContent.style.width = widthParam + 'px';
		dituContent.style.height = heightParam + 'px';
		/*
		if(is_SYStem){
			dituContent.style.width = '99%';
			dituContent.style.height = '99%';
			dituContent.style.margin = '4px 3px';
		}
		*/
		
		createMap();//创建地图
		setMapEvent();//设置地图事件
		addMapControl();//向地图添加控件
		
		// 创建标注
		var markersArr = markersParam.split(',');
		var point = new BMap.Point(markersArr[0], markersArr[1]);
		marker = new BMap.Marker(point);
		
		marker.setAnimation(BMAP_ANIMATION_BOUNCE); //标注使用跳动的动画
		if(!is_SYStem){
			marker.addEventListener("click", function(e){//标注图标点击事件
				//getLocation(marker);
				hide_thendrive(0);
				showLocationInfo(marker);
			});
		}
		
		map.addOverlay(marker);// 将标注添加到地图中
		thisPoint = point;//记忆坐标
		
		if(!is_SYStem){
			// 添加html5对当前位置定位(默认不标记)
			if(navigator.geolocation){
				var hospitalIcon = new BMap.Icon("Images/icon.bmp", new BMap.Size(100, 50), { offset: new BMap.Size(0, 0), imageOffset: new BMap.Size(50, 25) });
				var geoCtrl = new BMap.GeolocationControl({
					showAddressBar       : true //是否显示定位后的地址
					,enableAutoLocation  : false //页面加载完毕自动定位
					,offset              : new BMap.Size(0,28) //定位器坐标
					,anchor				 : BMAP_ANCHOR_BOTTOM_LEFT //位置
					//,locationIcon		 : hospitalIcon //定位的icon图标
				});
				geoCtrl.addEventListener('locationSuccess',function(e){
					var addComp = this.getAddressComponent();//console.log(e);
					showaddress = addComp.city + addComp.district + addComp.street;
					document.getElementById("point_end").value = addComp.province + showaddress;
					showLocationInfo(marker);
				});
				geoCtrl.addEventListener('locationError',function(e){
					//getLocation(marker);//console.log(e);//type returnValue target currentTarget code fa
					showLocationInfo(marker);
				});		
				map.addControl(geoCtrl);//向地图中添加定位控件
			}
		
			//标注文本说明
			var opts = {
				position : point,    // 指定文本标注所在的地理位置
				offset   : new BMap.Size(0, -2)    //设置文本偏移量
			}
			var label = new BMap.Label("点击查找路线指引", opts);  // 创建文本标注对象
			label.setStyle({
				color : "red",			
				fontSize : "12px",
				padding : "2px 4px",
				lineHeight : "20px",
				fontFamily:"微软雅黑"
			});
			label.addEventListener("click", function(e){  
				hide_thendrive(0);
				showLocationInfo(marker);
			});
			map.addOverlay(label);   
		}
		
		/*
		var driving = new BMap.DrivingRoute(map, {onSearchComplete:yyy,renderOptions:{map: map, autoViewport: true}}); 
		driving.search("安定门", "王府井");   //驾车查询
		function yyy(rs){           
			alert("从安定门到王府井打车总费用为:"+rs.taxiFare.day.totalFare+"元");     //计算出白天的打车费用的总价
		}	
		*/			
	}
		
	//创建地图函数:
	function createMap(){
		//在百度地图容器中创建一个地图
		var map = new BMap.Map("dituContent",{
			enableHighResolution: true //是否开启高清
		});
		var centerArr = centerParam.split(',');
		var point = new BMap.Point(centerArr[0], centerArr[1]);//定义一个中心点坐标
		map.centerAndZoom(point, zoomParam); //设定地图的中心点和坐标并将地图显示在地图容器中
		map.enableInertialDragging();//开启关系拖拽
		window.map = map;//将map变量存储在全局		
	}
	
	//地图事件设置函数:
	function setMapEvent(){
		map.enableDragging();//启用地图拖拽事件,默认启用(可不写)
		//map.enableScrollWheelZoom();//启用地图滚轮放大缩小
		map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写)
		//map.enableKeyboard();//启用键盘上下左右键移动地图
	}
	
	//地图控件添加函数:
	function addMapControl(){
		//向地图中添加比例尺控件
		map.addControl(new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}));
		//向地图中添加缩放控件
		map.addControl(new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}));
		//向地图中添加缩略图控件(鹰眼地图)
		map.addControl(new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1}));
		//添加地图类型控件
		map.addControl(new BMap.MapTypeControl());
	}
	
	//通过浏览器获取访问者坐标
	function getLocation(marker){
		var geolocation = new BMap.Geolocation(); 
		if(geolocation){
			geolocation.getCurrentPosition(function (r) { 
				if (this.getStatus() == BMAP_STATUS_SUCCESS ) { 
					showPosition(marker, r.point.lng, r.point.lat);
				}
			});	
		}else{
			alert("您的浏览器不支持地理定位");
		}
	}
	
	//通过坐标获取地址
	function showPosition(marker,lng,lat){
		var point = new BMap.Point(lng, lat);    // 创建点坐标
		var gc = new BMap.Geocoder();   
		gc.getLocation(point, function(rs){
			var addComp = rs.addressComponents;
			showaddress = addComp.city + addComp.district + addComp.street;
			document.getElementById("point_end").value = addComp.province + showaddress;
			showLocationInfo(marker);
		});
	}
	
	//显示查线路地址信息窗口
	function showLocationInfo(marker){
		showaddress = showaddress?showaddress:document.getElementById("point_end").value;
		var opts = {  
			width : 235  // 信息窗口宽度
			,title : '查询从某地来到这里线路'  // 信息窗口标题
			//,enableMessage:true //设置允许信息窗发送短息,1.5版支持
  			//,message:""
		},
		infoWindow = new BMap.InfoWindow("
到这
", opts); // 创建信息窗口对象 infoWindow.disableAutoPan(); marker.openInfoWindow(infoWindow); map.centerAndZoom(thisPoint,zoomParam); } //公交线路查询 function bus_end(){ var nowaddress = document.getElementById("point_end_show").value; nowaddress = nowaddress ? nowaddress : document.getElementById("point_end").value; document.getElementById("point_end_box").innerHTML = '正为您获取公交路线,请稍后...'; //map.centerAndZoom(thisPoint, 14); var driving = new BMap.TransitRoute(map, { renderOptions: {map: map, panel: "results", autoViewport: true} }); driving.setPolicy(BMAP_TRANSIT_POLICY_LEAST_WALKING); /* BMAP_TRANSIT_POLICY_LEAST_TIME 最少时间。 BMAP_TRANSIT_POLICY_LEAST_TRANSFER 最少换乘。 BMAP_TRANSIT_POLICY_LEAST_WALKING 最少步行。 BMAP_TRANSIT_POLICY_AVOID_SUBWAYS 不乘地铁。 */ driving.setSearchCompleteCallback(function(results){ if(results.getNumPlans()==0){ alert('抱歉,无法查询到公交路线,请填详细起点地址'); } }); driving.setPageCapacity(5); driving.setResultsHtmlSetCallback(function(){ show_thendrive(); if(scrollObj)scrollObj.refresh(); }); driving.search(nowaddress, thisPoint); } //自驾线路查询 function drive_end(){ var nowaddress = document.getElementById("point_end_show").value; nowaddress = nowaddress ? nowaddress : document.getElementById("point_end").value; document.getElementById("point_end_box").innerHTML = '正为您获取自驾车路线,请稍后...'; //map.centerAndZoom(thisPoint, 14); var driving = new BMap.DrivingRoute(map, { renderOptions: {map: map, panel: "results", autoViewport: true} }); driving.setSearchCompleteCallback(function(results){ if(results.taxiFare==null){ alert('抱歉,暂无自驾路线可供参考,请填详细起点地址'); }else{ //alert("打车总费用为:"+results.taxiFare.day.totalFare+"元"); } }); driving.setResultsHtmlSetCallback(function(){ show_thendrive(); if(scrollObj)scrollObj.refresh(); }); driving.search(nowaddress, thisPoint); } function show_thendrive(){ document.getElementById("showRoute").style.display = 'none'; document.getElementById("results_box").style.display = 'block'; } function hide_thendrive(isclose){ if(isclose)document.getElementById("showRoute").style.display = 'block'; document.getElementById("results_box").style.display = 'none'; } function GetCityName(result){ var cityName = result.name;//map.setCenter(cityName); document.getElementById("point_end").value = cityName; } if(!is_SYStem && window.BMap){ var GetMyCity = new BMap.LocalCity(); GetMyCity.get(GetCityName); }