<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>订单轨迹回放</title>
<%@include file="/WEB-INF/views/common/common.jsp"%>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你的key"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/LuShu/1.2/src/LuShu_min.js"></script>
<!-- 弹出层 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/plugins/artDialog/jquery.artDialog.js?skin=default&local=auto"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/plugins/artDialog/plugins/iframeTools.js"></script>
<!-- 当前页面的JS -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/order/leaseOrder/orderLocusMap.js"></script>
<style type="text/css">
.stationInfoDivRow {
margin-bottom: 4px;
}
.stationInfoDivLabel {
display: inline-block;
width: 60px;
text-align: center;
}
.stationInfoDivValue {
display: inline-block;
width: 60px;
text-align: left;
}
html{height:100%}
/*地图弹出样式*/
.lanmumc { height:35px; min-width:430px; border-bottom:1px solid #ababab;}
.lanmumc li { height:33px; width:130px; text-align:center; font-size:14px; border-bottom:2px solid #2e8be0; color:#2e8be0; line-height:33px; font-family: "微软雅黑"; margin-left:20px;}
.nrirong ul { line-height:24px;}.nrirong li{ width:135px;}
.title{ width:300px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.search_row {
margin-bottom: 8px;
}
.search_column label {
display: inline-block;
width: 60px;
text-align: center;
}
.search_column input,select {
border: 1px solid #ccc;
height: 20px;
width: 160px;
line-height: 20px;
text-indent: 4px;
outline: none;
}
.search_row .search_column {
margin-right: 10px;
}
.search_columnLast {
margin-right: 0px;
}
.search_button {
border: 1px solid #bacae3;
background: #4eb2e1;
color: #fff;
width: 35px;
}
#searchMapResult {
z-index: 100;
margin-top: 2px;
background: #fff;
box-shadow: 1px 2px 1px rgba(0,0,0,.15);
width: 320px;
max-width: 320px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
.station_ctr_title {
background: #f9f9f9;
border-bottom: 1px solid #dadada;
height: 25px;
line-height: 25px;
font-size: 12px;
color: #4c4c4c;
padding-left: 7px;
}
#searchMapResult_close {
outline: none;
position: relative;
z-index: 50;
top: -20px;
right: -300px;
width: 12px;
height: 12px;
background: url(${pageContext.request.contextPath}/resource/images/popup_close_15d2283.gif) no-repeat;
border: 0;
cursor: pointer;
}
#searchStationList {
z-index: 100;
/* max-height:382px; */
overflow-x:auto;
/* -webkit-user-select:all;
-moz-user-select:all;
-ms-user-select:all;
user-select:all; */
}
.station_icon {
background: url(${pageContext.request.contextPath}/resource/images/markers.png) no-repeat;
width: 19px;
height: 25px;
cursor: pointer;
float: left;
*zoom: 1;
overflow: hidden;
margin: 2px 3px 0 5px;
*margin-right: 0px;
display: inline;
}
.station_info_li {
margin: 2px 0px;
padding: 0px 5px 5px 0px;
/* cursor: pointer; */
overflow: hidden;
line-height: 17px;
border-bottom: 1px solid #CCC;
}
.station_info_div {
zoom: 1;
overflow: hidden;
padding: 0px 5px;
/* background-color: rgb(240, 240, 240) */
}
.station_info_d {
float: left;
font-weight: bold;
*zoom: 1;
overflow: hidden;
padding-right: 5px;
*margin-right: -3px;
}
.station_info_span {
color: #666;
display: block;
zoom: 1;
overflow: hidden;
}
a,a:hover,a:focus{text-decoration:none;background:0 0;}
.op_table img{vertical-align:middle;max-width:100%;}
.ml10{margin-left:10px;}
.mr10{margin-right:10px;}
.left-operate{width:280px;left:0;top:0;bottom:0;position:fixed;padding:10px;padding-right:0;padding-bottom:0;box-sizing:border-box;}
.left-operate>div,.rigth-map>div{border:1px solid #B1C3E0;height:100%;}
.op_table{width:100%;text-align:center;}
.op_table tr{height:38px;line-height:38px;}
.op_table tr:nth-child(odd){background:#f5f8f8;}
.op_table img{cursor:pointer;}
.rigth-map{width:100%;left:0;top:0;bottom:0;position:fixed;padding-left:290px;padding-top:10px;box-sizing:border-box;}
.search_row{padding:0 5px;font-size:12px;line-height:30px;background:#fff;border-radius:5px;box-shadow:0 2px 2px #e5e5e5;}
.search_row img{vertical-align:middle;margin-top:-2px;}
.search_row a{display:inline-block;cursor:pointer;}
.add_elec{border-right:1px solid #eeeeee;}
</style>
</head>
<body>
<div id="mainform" class="m10" >
<div id="container" style="margin:0 auto;width:1300px;height:500px;border:1px solid gray"></div>
<div style="margin:0 auto;width:1300px;"><input id="goBack" name="goBack" type="button" value="返回" style="margin-left:600px;margin-top: 10px;" class="gy_btn gy_gray ml10"/></div>
</div>
</body>
</html>
JS代码:
BaiDuMap_station = function() {
this.mainform = null;
this.baiduMap = null;
this.leaseOrderId=Dic.Url.getRequestParams('leaseOrderId');
this.carNum=decodeURIComponent(Dic.Url.getRequestParams('carNum'));
var marker;//小车标注
var lushu;
/** 初始化百度地图 */
this.initMap=function(){
//创建百度地图实例
this.baiduMap = new BMap.Map("container");
//创建中心坐标深圳
var point = new BMap.Point(114.025973657,22.5460535462); // 创建中心点坐标 ,北京 116.404, 39.915 ; 全国中心 103.21853, 34.798205 ; 西安坐标 108.95033,34.274204
this.baiduMap.centerAndZoom(point, 10); // 初始化地图,设置中心点坐标和地图级别
this.baiduMap.enableScrollWheelZoom(); // 启用滚轮放大缩小
this.baiduMap.addControl(new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_RIGHT})); //地图平移缩放控件
this.baiduMap.addControl(new BMap.ScaleControl()); //比例尺控件
this.baiduMap.addControl(new BMap.CopyrightControl()); //版权控件
this.baiduMap.addControl(new BMap.GeolocationControl()); //定位控件
if(navigator.userAgent.indexOf("MSIE")>0)
{
if(navigator.userAgent.indexOf("MSIE 6.0")>0
|| navigator.userAgent.indexOf("MSIE 7.0")>0
|| navigator.userAgent.indexOf("MSIE 8.0")>0)
{
// IE 6 7 8
} else {
this.baiduMap.addControl(new BMap.CityListControl({ anchor: BMAP_ANCHOR_TOP_RIGHT, offset: new BMap.Size(85, 25)})); // 城市切换
}
} else {
// 其他浏览器
this.baiduMap.addControl(new BMap.CityListControl({ anchor: BMAP_ANCHOR_TOP_RIGHT, offset: new BMap.Size(85, 25)})); // 城市切换
}
}
/** 初始化布局 */
this.initFrameLayout = function() {
if(navigator.userAgent.indexOf("MSIE")>0)
{
if(navigator.userAgent.indexOf("MSIE 6.0")>0
|| navigator.userAgent.indexOf("MSIE 7.0")>0
|| navigator.userAgent.indexOf("MSIE 8.0")>0
|| navigator.userAgent.indexOf("MSIE 9.0")>0)
{
$(document.body).css("width", "100%");
$(document.body).css("height", "98%");
this.mainform.css("height", document.body.clientHeight - 5);
this.mainform.css("width", document.body.clientWidth - 20);
$("#container").css("height", "100%");
$("#container").css("width", "100%");
}
}
}
this.initData = function(){
// 封装请求数据对象
var requestObj = new Object();
requestObj['url'] = ctx + '/leaseOrder/queryTrail.json';
requestObj['data'] = new Object();
requestObj['data']["leaseOrderId"] = baidumap_station.leaseOrderId;
requestObj['data']["pageSize"] = '0';
requestObj['data']["currentPage"] = '0';
var responseObj = Dic.Ajax.request(requestObj);
if (null != responseObj && true == responseObj.success) {
var pointArray =[];//经纬度数组
for(var i=0;i<responseObj.result.trails.length;i++){
var point = new BMap.Point(responseObj.result.trails[i].lo,responseObj.result.trails[i].la);
pointArray.push(point);
}
baidumap_station.baiduMap.setViewport(pointArray);//设置地图视野
marker = new BMap.Marker(pointArray[0],{
icon: new BMap.Icon(
ctx+'/resource/images/origin.png',
new BMap.Size(52,26),
{anchor : new BMap.Size(27, 13)}
)
});
var label = new BMap.Label(this.carNum,{offset:new BMap.Size(0,-30)});//创建地图上的文本标注
label.setStyle({border:"1px solid rgb(204, 204, 204)",color: "rgb(0, 0, 0)",borderRadius:"10px",padding:"5px",background:"rgb(255, 255, 255)",});
//marker.setLabel(label);//添加文本标注
this.baiduMap.addOverlay(marker);//向地图中添加小车覆盖物
BMapLib.LuShu.prototype._move=function(initPos,targetPos,effect) {
var pointsArr = [initPos, targetPos]; //点数组
var me = this, currentCount = 0, timer = 100, step = this._opts.speed / (1000 / timer);//当前的帧数,步长,米/秒
//初始坐标
var init_pos = this._projection.lngLatToPoint(initPos);
//获取结束点的(x,y)坐标
var target_pos = this._projection.lngLatToPoint(targetPos);
//总的步长
var count = Math.round(me._getDistance(init_pos, target_pos) / step);
baidumap_station.baiduMap.addOverlay(new BMap.Polyline(pointsArr, {
strokeColor: "blue",
strokeWeight: 5,
strokeOpacity: 0.5
})); // 画线
//如果小于1直接移动到下一点
if (count < 1) {
me._moveNext(++me.i);
return;
}
me._intervalFlag = setInterval(function () {
//两点之间当前帧数大于总帧数的时候,则说明已经完成移动
if (currentCount >= count) {
clearInterval(me._intervalFlag);
//移动的点已经超过总的长度
if (me.i > me._path.length) {
return;
}
//运行下一个点
me._moveNext(++me.i);
} else {
currentCount++;
var x = effect(init_pos.x, target_pos.x, currentCount, count),
y = effect(init_pos.y, target_pos.y, currentCount, count),
pos = me._projection.pointToLngLat(new BMap.Pixel(x, y));
//设置marker
if (currentCount == 1) {
var proPos = null;
if (me.i - 1 >= 0) {
proPos = me._path[me.i - 1];
}
if (me._opts.enableRotation == true) {
me.setRotation(proPos, initPos, targetPos);
}
if (me._opts.autoView) {
if (!me._map.getBounds().containsPoint(pos)) {
me._map.setCenter(pos);
}
}
}
//正在移动
me._marker.setPosition(pos);
//设置自定义overlay的位置
me._setInfoWin(pos);
}
}, timer);
};
lushu = new BMapLib.LuShu(this.baiduMap,pointArray,{
defaultContent:this.carNum,
autoView:true,//是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
icon : new BMap.Icon('http://developer.baidu.com/map/jsdemo/img/car.png', new BMap.Size(52,26),{anchor : new BMap.Size(27, 13)}),
speed: 2000,
enableRotation:true,//是否设置marker随着道路的走向进行旋转
landmarkPois:[
{lng:116.306954,lat:40.05718,html:'加油站',pauseTime:2}
]
});
//this.baiduMap.clearOverlays(); //清除所有覆盖物
//marker.hide();
lushu.start();
// marker.addEventListener("click",function() {
// marker.enableMassClear(); //设置后可以隐藏改点的覆盖物
// marker.hide();
// lushu.start();
// //map.clearOverlays(); //清除所有覆盖物
// });
} else {
art.dialog.message('error', "数据载入失败", null);
}
}
/**
* 按钮等事件绑定
*/
this.bind = function() {
Dic.addEvent(this.mainform.find('#goBack'), 'click', this.goBack, null, this);
}
this.goBack=function(){
window.location.href=ctx +'/leaseOrder/goAllOrder.do'
}
this.init = function() {
baidumap_station.mainform = $('#mainform');
this.initFrameLayout();
this.initMap();
this.initData();
this.bind();
}
}
var baidumap_station = new BaiDuMap_station();
$(document).ready(function(){
baidumap_station.init();
});