首页 / 浏览问题 / 云GIS / 问题详情
js创建的矢量图拖动时lable信息丢失
3EXP 2016年12月22日

如下图:拖动矢量图层上的这个蓝色多边形时,lable信息(010759)是闪烁的,停止拖动时,010759有时可见有时丢失

1个回答

你使用的JavaScript包是哪个版本的呢
1,620EXP 2016年12月22日
用的这个版本 SuperMap iClient 8C for JavaScript,

刚刚换了SuperMap-6.1.3-10027.js 出现同样的问题
你是有设置什么其他的吗,比如矢量图层的styleMap

我这边没有重现,你可以提供一下具体的代码吗
好的,麻烦帮忙看下代码吧:

//新建面矢量图层,用来画图
    //新建面矢量图层,用来画图
    polygonLayer = new SuperMap.Layer.Vector("vector");
    //画多边形要素
    drawPolygon = new SuperMap.Control.DrawFeature(polygonLayer, SuperMap.Handler.Polygon);
    //支持拖拽要素
    dragFeature = new SuperMap.Control.DragFeature(polygonLayer);
    
    map = new SuperMap.Map("map",{
        controls: [
            new SuperMap.Control.OverviewMap({
                        autoPan : true
                    }),
                    new SuperMap.Control.MousePosition(),
                    new SuperMap.Control.PanZoomBar({
                        showSlider : true
                    }),
                    new SuperMap.Control.Navigation( {
                        dragPanOptions : {
                            enableKinetic : true
                        }
                    }),
                    drawPolygon,dragFeature
        ]
    });
    baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("dajitudi@GIS", url, {transparent: true, cacheEnabled: true}, {maxResolution: "auto"});
    baseLayer.events.on({"layerInitialized": addLayer});
    map.events.register("zoomend", map, mapzoomend);
    //画的多边形要素支持选择事件
    var  selectFeature = new SuperMap.Control.SelectFeature(polygonLayer,
             {
                 callbacks: callbacks
             });
     map.addControl(selectFeature);
     selectFeature.activate();
     
     function addData(){
        var point_features=[];
        createRec(572040,5225280,10,2,point_features);
        polygonLayer.addFeatures(point_features);
}
//画矩形,指定起点,然后向上边,向左边绘画距离:右下右上左上左下
function createRec(x,y,dx,dy,point_features){
    var train_len = 6;//换算后的车长
    var x1 = x;
    var y1 = y;
    var x2 = x1;
    var y2 = y1 + dy;
    var x3 = x1 - train_len + 2;
    var y3 = y2;
    var x4 = x1 - train_len;
    var y4 = y1;
    
    var polygon_data=[
                      [x1,y1],
                      [x2,y2],
                      [x3,y3],
                      [x4,y4]
                 ];
    var points=[];
    for(var i= 0,len=polygon_data.length;i<len;i++){
        var point = new SuperMap.Geometry.Point(polygon_data[i][0],polygon_data[i][1]);
        points.push(point);
    }
    var linearRing=new SuperMap.Geometry.LinearRing(points);
    var polygon=new SuperMap.Geometry.Polygon([linearRing]);
    //属性数据
    var polygon_data = {"train_no":"100100","train_name":"你猜"};
    //指定样式
    var drawFeatureStyle = {  
            strokeColor: "#FF0000",  
            strokeWidth: 2,  
            strokeOpacity: 0.8,  
            pointRadius: 6,  
            fillColor: "#0000FF",
            fillOpacity: 0.5,
            cursor: "pointer",
            label:"010759",
            fontFamily:"宋体",//标签字体
            fontColor:"#00FF00",
            fontSize:1,
            labelSelect:true
    };
    var polygon_feature=new SuperMap.Feature.Vector(polygon,polygon_data,drawFeatureStyle);
    point_features.push(polygon_feature);
}
不知道跟我的底图是cad有没有关系,我把底图换成            url="http://support.supermap.com.cn:8090/iserver/services/map-china400/rest/maps/China_4326";

然后其他不变,拖动时信息不丢失,好悲催
你能具体描述一下你的CAD图吗,在桌面是怎么制作的工作空间,是直接导入cad,以复合数据集的形式,还是简单数据集的形式导入做的
我是新增的文件型工作空间,以复合数据集形式导入的cad,然后没有任何处理,就把导入的cad数据添加到地图,发布了
你私信我一下你的联系方式吧
...