(function () {
function A(option) {
var t = this;
t.div = null;
t.map = null;
t.data = [];
t.d3Layer = null;
t._svg = null;
t._tempData=null;
t._stepPointCount = 4;//每一步所走过的点
t._stepPointCountOffset = 5;//每一步所走过的点范围
t._minStepLength = 5;//每一段的长度
t._maxStepLength = 15;
t._stepStatus = {};
t._stepPointMargin =3;
t._stepNum =3;//有多少个小段
t._stepOffset = 30; //点的偏移量
t._maxSpeed = 500;
t._minSpeed = 200;
t._startOpacity = 0.1;
t._endOpacity = 0.9;
t._pointCountMultiple = 2;
t._mindelay = 30;
t._maxdelay = 300;
t._startColor=187;
t._endColor=94;
t._isStop = false;
t._isMove = false;
t._isAddData = false;
t.__isStop = null;
for (var key in option) {
t[key] = option[key];
}
t.createSVG();
t.d3Layer.events.on({moveend: function (evt) {
//console.log("moveend");
if(t._isMove){
t._isMove = false;
//t._isStop = t.__isStop;
//t.__isStop = null;
}
t._refresh(evt);
}});
// t.d3Layer.events.on({movestart: function (evt) {
// console.log("movestart");
// t._isStop = true;
// }});
t.d3Layer.events.on({move: function (evt) {
//console.log("move");
if(!t._isMove){
//t.__isStop = t._isStop;
//t._isStop = true;
t._isMove = true;
//t._svg.selectAll("path").style("display","none");
}
t._svg.selectAll("path").style("display","none");
}});
}
var P = A.prototype;
P.createSVG = function () {
var t = this;
var size = t.map.getSize();
t._svg = d3.select(t.div)
.append("svg")
.attr("width", size.w)
.attr("height", size.h);
//d3.select(t.div).html("");
}
P.addData = function(data){
var t = this;
if(t._isAddData){
return;
}
else{
t._isAddData = true;
}
t._isStop = false;
t.data = data;
var defs = d3.select("svg")
.append("defs");
var linearGradient = defs.append("linearGradient").attr({
id:"orange_red",
x1:"0%",
y1:"0%",
x2:"100%",
y2:"0%"
});
linearGradient.append("stop").attr({
offset:"0%"
})
.style({
"stop-color":"rgb("+t._startColor+","+t._startColor+","+t._startColor+")",
"stop-opacity":1
});
linearGradient.append("stop").attr({
offset:"100%"
})
.style({
"stop-color":"rgb("+t._endColor+","+t._endColor+","+t._endColor+")",
"stop-opacity":1
});
var tempData = t._tempData = t.getPosition(data);
var bindData = [];
for(var i=0;i=length){
start = length;
}
if(start-end<=stepLength){
}
else{
end = end+pointCount;
}
var newStart = start;
var offsetX =statusi.offsetX;
var offsetY = statusi.offsetY;
pointStrArray.push("M"+offset(line[end],offsetX,offsetY).join(" "));
if(stepLength>=4){
for(var j=end+1;j=length){
break;
}
var stepLength = t._minStepLength+Math.round(Math.random()*(t._maxStepLength- t._minStepLength));
if(start+stepLength>=length){
stepLength = length-start;
}
for(var j=0;j=length){
obj
.transition()
.duration(500)
.style('opacity', t._startOpacity)
.each('end',function(){
d3.select(this).call(function(selection){
t.lineAnimate(selection);
});
});
}
else{
obj.call(function(selection){
t.step(selection);
});
}
});
}
P.getPosition = function(datas){
var tempDatas = [],t = this;
if(datas){
for(var i=0;i