小弟GIS菜鸟小学生,在进行Javascript开发的时候,单击一次定下第一个点,鼠标移动时候,线会随着鼠标的光标移动;单击第二次时候会定下第二个点,随即鼠标移动的时候会出现第二个点的闪烁偏移,不知道是什么情况,希望得到大家的解答。。。真诚求帮助
附:Api接口是自己封装的,类似ArcGIS 的API
$("#xian").click(function () {
var layer = null, plength = -1;
var points = [];
var layer = new LesGIS.GraphicsLayer();
map.addLayer(layer);
var click = map.onClick(function (evt){
plength++;
var poly = null;
points[plength] = [evt.mapPoint.x,evt.mapPoint.y];
if(plength > 0){
poly=new LesGIS.Polyline(points);
layer.clear();
layer.add(poly);
}
var move = map.onMouseMove(function (evt){
var mp = [evt.mapPoint.x, evt.mapPoint.y];
points[plength + 1] = mp;
poly = new LesGIS.Polyline(points);
layer.clear();
layer.add(poly);
});
//console.log(points);
map.ondblClick(function (evt) {
map.removeEvent(move);
map.removeEvent(click);
});
});
});