supermap使用小结

Posted jiangze

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了supermap使用小结相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="UTF-8">
<head>
<title>SuperMap iClient javascript:TiledDynamicRESTLayer</title>
<script src="./libs/SuperMap.Include.js"></script>
<script type="text/javascript">

var map, local, layer, vectorLayer,vectorLayer1,markerLayer,drawLine,
        drawPolygon, lineLayer, polygonLayer,layerCorp,mousePosition,ids,centerLon,centerLat,presentScale, x1, y1,isdrag=false,
        style = {
            strokeColor: "#304DBE",
            strokeWidth: 1,
            fillColor: "#304DBE",
            fillOpacity: "0.8"
        },url = "http://192.168.1.19:8190/iserver/services/map-nanjing4/rest/maps/NanjingMapCorp",//静态切片地图
        styleline = {
            strokeColor: "#304DBE",
            strokeWidth: 2,
            pointerEvents: "visiblePainted",
            fillColor: "#304DBE",
            fillOpacity: 0.8
        },url2 = "http://192.168.1.19:8190/iserver/services/data-nanjing4/rest/data/datasources/nanjingmap/datasets/T_CCP_LABEL_CORP2";//数据更新
        
function init() {
    layer = new SuperMap.Layer.TiledDynamicRESTLayer("底图", url, {transparent: true, cacheEnabled: false, redirect: true},
            {scales:[1/5120000,1/2560000,1/1280000,1/640000,1/320000,1/160000,1/80000,1/40000,1/20000,1/10000,1/5000,1/2500]});
    layer.events.on({"layerInitialized":addLayer});
    vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
    vectorLayer1 = new SuperMap.Layer.Vector("Vector Layer1");
    markerLayer = new SuperMap.Layer.Markers("Markers");

    //新建线矢量图层
    lineLayer = new SuperMap.Layer.Vector("lineLayer");
    //对线图层应用样式style(前面有定义)
    lineLayer.style = styleline;
    //新建面矢量图层
    polygonLayer = new SuperMap.Layer.Vector("polygonLayer");
    //对面图层应用样式style(前面有定义)
    polygonLayer.style = styleline;

    //创建画线控制,图层是lineLayer;这里DrawFeature(图层,类型,属性);multi:true在将要素放入图层之前是否现将其放入几何图层中
    drawLine = new SuperMap.Control.DrawFeature(lineLayer, SuperMap.Handler.Path, { multi: true });

    /*
     注册featureadded事件,触发drawCompleted()方法
     例如注册"loadstart"事件的单独监听
     events.on({ "loadstart": loadStartListener });
     */
    drawLine.events.on({"featureadded": drawCompletedline});

    //创建画面控制,图层是polygonLayer
    drawPolygon = new SuperMap.Control.DrawFeature(polygonLayer, SuperMap.Handler.Polygon);
    drawPolygon.events.on({"featureadded": drawCompletedline});

    //多边形查询
    drawPolygon2 = new SuperMap.Control.DrawFeature(vectorLayer, SuperMap.Handler.Polygon);
    drawPolygon2.events.on({"featureadded": drawCompleted});

    //几何圆查询
    drawPolygon1 = new SuperMap.Control.DrawFeature(vectorLayer, SuperMap.Handler.RegularPolygon,{handlerOptions:{sides:50}});
    drawPolygon1.events.on({"featureadded": drawCompleted});

    //页面鼠标移动控件
    mousePosition = new SuperMap.Control.MousePosition({emptyString:"0,0"});
    mousePosition.numDigits=16;

    map = new SuperMap.Map("map",{controls: [
        new SuperMap.Control.ScaleLine(),
        new SuperMap.Control.PanZoomBar({isShow: true}),
        mousePosition,
        new SuperMap.Control.OverviewMap(),
        new SuperMap.Control.LayerSwitcher({‘ascending‘:false}),
        new SuperMap.Control.Navigation({
            dragPanOptions: {
                enableKinetic: true
            }
        }),
        drawPolygon1,drawPolygon2,drawLine, drawPolygon]
    });
}
function addLayer() {
    map.addLayers([layer,vectorLayer,vectorLayer1, markerLayer,lineLayer, polygonLayer]);
    map.setCenter(new SuperMap.LonLat(118.7263097340030100, 32.0086077019304014),10);
}

// 处理异常,弹出
function processFailed(e) {
    alert(e.error.errorMsg);
}
// 清除页面标记
function clearFeatures() {
    vectorLayer.removeAllFeatures();
    vectorLayer1.removeAllFeatures();
    lineLayer.removeAllFeatures();
    polygonLayer.removeAllFeatures();
    markerLayer.clearMarkers();
}

//清除上次的鼠标效果
function clearDrawGeometry(){
    drawLine.deactivate();
    drawPolygon.deactivate();
    drawPolygon1.deactivate();
    drawPolygon2.deactivate();
}

function closeInfoWin(){//关闭窗口--标记弹出
    if(infowin){
        try{
            infowin.hide();//隐藏窗体对象
            infowin.destroy();//消毁窗体对象
        }
        catch(e){
        }
    }
}

//关闭窗口--修改弹出
function closeInfoWin2(){
    if(infowin2){
        try{
            infowin2.hide();//隐藏窗体对象
            infowin2.destroy();//消毁窗体对象
        }
        catch(e){
        }
    }
}
//关闭窗口--添加弹出
function closeAddPoiPopup(){
    if(addPoiPopup){
        try{
            addPoiPopup.hide();//隐藏窗体对象
            addPoiPopup.destroy();//消毁窗体对象
        }
        catch(e){
        }
    }
}

//清除当前选择的marker
function clearMarker() {
    var marker = this;
    marker.destroy();
}

//................................................点击弹出.................................................................
//点击标记弹出
var infowin = null;
function openInfoWin(){
    closeInfoWin();//关闭之前打开的窗口。
    var marker = this;
    var lonlat = marker.lonlat;
    var corp = marker.sm_capital.split(",");
    var picturenum = corp[5];
    var id = corp[6];
    var infowinHtml=‘<div>企业名称:<input type="text" id="njEnterpriseName" style="width:180px;" value="‘+ corp[0] +‘">‘
            + ‘</br>企业地址:<input type="text" id="njEnterpriseAdd" style="width:180px;" value="‘+ corp[1] +‘">‘
            + ‘</br>企业电话:<input type="text" id="njEnterpriseTel" style="width:180px;" value="‘+ corp[2] +‘">‘
            + ‘</br><a href="#" onclick="enterpriseInfomation(‘+ corp[3] +‘,‘+ corp[4] +‘)">详细信息</a>‘
            +‘   <a href="#" onclick="editSelectedFeature(‘+ id + ‘,‘ + lonlat.lon + ‘,‘ + lonlat.lat +‘)">修改</a>‘
            +‘   <a href="#" onclick="deleteSelectedFeatureById(‘+ id +‘)">删除</a>‘
            +‘</div>‘;
    var size = new SuperMap.Size(44, 33);
    var offset = new SuperMap.Pixel(0, -size.h);
    var icon = new SuperMap.Icon("./theme/images/marker.png", size, offset);
    var popup = new SuperMap.Popup.FramedCloud("popwin",
            new SuperMap.LonLat(lonlat.lon,lonlat.lat),
            null,
            infowinHtml,
            icon,
            true);
    infowin = popup;
    map.addPopup(popup);
}

//..............................................SQL查询..............................................................
//查询--企业名称
function queryBySQL() {
    clearFeatures();
    var pop = document.getElementById("pop").value;
    //var area = document.getElementById("area").value;
    if (pop==null || pop=="")
    {
        alert("请输入");
        return;
    }
    vectorLayer.removeAllFeatures();
    var queryParam, queryBySQLParams, queryBySQLService;
    queryParam = new SuperMap.REST.FilterParameter({
        name: "[email protected]",
        attributeFilter: "CORP_NAME LIKE ‘%" + pop + "%‘"
    }),
            queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
                queryParams: [queryParam]
            }),
            queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
                eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}});
    queryBySQLService.processAsync(queryBySQLParams);
}
// 查询--企业ID
function queryBySQL2() {
    clearFeatures();
    var bob = document.getElementById("bob").value;
    //var area = document.getElementById("area").value;
    if (bob==null || bob=="")
    {
        alert("请输入");
        return;
    }
    vectorLayer.removeAllFeatures();
    var queryParam, queryBySQLParams, queryBySQLService;
    queryParam = new SuperMap.REST.FilterParameter({
        name: "[email protected]",
        attributeFilter: "SMID = " + bob
    }),
            queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
                queryParams: [queryParam]
            }),
            queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
                eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}});
    queryBySQLService.processAsync(queryBySQLParams);
}
// 处理查询结果
function processCompleted(queryEventArgs) {
    var i, j, feature,
            result = queryEventArgs.result;
    if (result && result.recordsets) {
        for (i=0; i<result.recordsets.length; i++) {
            if (result.recordsets[i].features.length>0) {
                for (j=0; j<result.recordsets[i].features.length; j++) {
                    var feature = result.recordsets[i].features[j];
                    var point = feature.geometry;
                    if(point.CLASS_NAME == SuperMap.Geometry.Point.prototype.CLASS_NAME){
                        var size = new SuperMap.Size(44, 33),
                                offset = new SuperMap.Pixel(-(size.w/2), -size.h),
                                icon = new SuperMap.Icon("./theme/images/marker.png", size, offset);
                        var marker = new SuperMap.Marker(new SuperMap.LonLat(point.x, point.y), icon);
                        marker.sm_capital = feature.attributes.CORP_NAME + ","
                                + feature.attributes.ADDR + ","
                                + feature.attributes.TEL + ","
                                + feature.attributes.CORP_ORG + ","
                                + feature.attributes.CORP_ID + ","
                                + feature.attributes.PICTURE+ ","
                                + feature.attributes.SMID;
                        marker.events.on({//注册点击事件的处理方法
                            "rightclick":clearMarker,
                            "dblclick":openInfoWin,
                            "scope": marker
                        });
                        //查询出来的结果只有一个时支持拖动
                        if(result.recordsets[i].features.length == 1){
                            //注册事件
                            marker.events.register("mousedown",marker,function(e){
                                isdrag = true;
                                //得到marker的经纬度坐标
                                var lon = marker.lonlat;
                                //将经纬度坐标转换成屏幕坐标
                                var pixel = map.getPixelFromLonLat(lon);
                                //取整
                                tx = parseInt(pixel.x);
                                ty = parseInt(pixel.y);
                                //获取marker相对鼠标的位置
                                x1 = marker ? e.clientX : event.clientX;
                                y1 = marker ? e.clientY : event.clientY;
                            });
                        }
                        markerLayer.addMarker(marker);
                        if (j==0){
                            map.panTo(new SuperMap.LonLat(point.x, point.y));
                            map.zoomTo(10);
                        }
                    }else{
                        feature.style = style;
                        vectorLayer1.addFeatures(feature);
                    }
                }
            }else{
                alert("未查询到结果!");
            }
        }
    }
}

//................................................画图查询................................................................
//画多边形
function drawGeometry2() {
    //先清除上次的显示结果
    clearFeatures();
    drawPolygon2.activate();
}

//画圆
function drawGeometry1() {
    //先清除上次的显示结果
    clearFeatures();
    drawPolygon1.activate();
}

// 圆形查询
function drawCompleted(drawGeometryArgs) {
    getScale();
    //清除上次的鼠标效果
    clearDrawGeometry();
    var feature = new SuperMap.Feature.Vector();
    feature.geometry = drawGeometryArgs.feature.geometry,
            feature.style = style;
    vectorLayer.addFeatures(feature);

    var queryParam, queryByGeometryParameters, queryService;
    queryParam = new SuperMap.REST.FilterParameter({name: "[email protected]"});
    queryByGeometryParameters = new SuperMap.REST.QueryByGeometryParameters({
        queryParams: [queryParam],
        geometry: drawGeometryArgs.feature.geometry,
        spatialQueryMode: SuperMap.REST.SpatialQueryMode.INTERSECT
    });
    queryService = new SuperMap.REST.QueryByGeometryService(url, {
        eventListeners: {
            "processCompleted": processCompleted,
            "processFailed": processFailed
        }
    });
    queryService.processAsync(queryByGeometryParameters);
}

//...............................................测量..........................................................................
//距离测量
function distanceMeasure(){
    clearFeatures();
    drawLine.activate();
}

//面积测量
function areaMeasure(){
    clearFeatures();
    drawPolygon.activate();
}

//测量--绘完触发事件
function drawCompletedline(drawGeometryArgs) {
    //清除上次的鼠标效果
    clearDrawGeometry();
    //获得图层几何对象
    var geometry = drawGeometryArgs.feature.geometry,
            measureParam = new SuperMap.REST.MeasureParameters(geometry), /* MeasureParameters:量算参数类。 客户端要量算的地物间的距离或某个区域的面积*/
            myMeasuerService = new SuperMap.REST.MeasureService(url); //量算服务类,该类负责将量算参数传递到服务端,并获取服务端返回的量算结果
    myMeasuerService.events.on({ "processCompleted": measureCompleted });

    //对MeasureService类型进行判断和赋值,当判断出是LineString时设置MeasureMode.DISTANCE,否则是MeasureMode.AREA
    if (geometry.CLASS_NAME.indexOf("LineString") > -1) {
        myMeasuerService.measureMode = SuperMap.REST.MeasureMode.DISTANCE;
    } else {
        myMeasuerService.measureMode = SuperMap.REST.MeasureMode.AREA;
    }
    myMeasuerService.processAsync(measureParam); //processAsync负责将客户端的量算参数传递到服务端。
}

//测量结束调用事件
function measureCompleted(measureEventArgs) {
    var distance = measureEventArgs.result.distance,
            area = measureEventArgs.result.area,
            unit = measureEventArgs.result.unit;
    if (distance != -1) {
        alert("量算结果:"+distance + "米");
    } else if (area != -1) {
        alert("量算结果:"+ area + "平方米");
    }
}

// .......................................插入数据..................................................................
//执行添加地物
function addFeatureCompleted(geometryDate) {
    var temp = geometryDate.split(",");
    var geometry;
    geometry = new SuperMap.Geometry.Point(temp[0], temp[1]);
    var name = document.getElementById("enterpriseName").value;
    var add = document.getElementById("enterpriseAdd").value;
    var tel = document.getElementById("enterpriseTel").value;
    closeAddPoiPopup();
    var editFeatureParameter,
            editFeatureService,
            features = {
                fieldNames:["CORP_NAME","SMUSERID","TEL","ADDR"],
                fieldValues:[name,1,tel,add],
                geometry:geometry
            };
    editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
        features: [features],
        editType: SuperMap.REST.EditType.ADD,
        returnContent:true
    });
    editFeatureService = new SuperMap.REST.EditFeaturesService(url2, {
        eventListeners: {
            "processCompleted": addFeaturesProcessCompleted,
            "processFailed": processFailed
        }
    });
    editFeatureService.processAsync(editFeatureParameter);
}
//添加成功
function addFeaturesProcessCompleted(editFeaturesEventArgs) {
    ids = editFeaturesEventArgs.result.IDs,
            resourceInfo = editFeaturesEventArgs.result.resourceInfo;
    if(ids === null && resourceInfo === null) return;

    if((ids && ids.length > 0) || (resourceInfo && resourceInfo.succeed)) {
        alert("新增成功");
        getCenterLonLat();
        getScale();
        //重新加载图层
        clearFeatures();
        map.removeLayer(layer,true);
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("底图", url, {transparent: true, cacheEnabled: false, redirect: true},
                {scales:[1/5120000,1/2560000,1/1280000,1/640000,1/320000,1/160000,1/80000,1/40000,1/20000,1/10000,1/5000,1/2500]});
        layer.events.on({"layerInitialized":reloadLayer});
    }else {
        alert("新增失败");
    }
}

//.......................................点击标注.....................................................
function markPOI() {
    //先清除上次的显示结果
    clearFeatures();
    //清除上次的鼠标效果
    clearDrawGeometry();
    map.events.on({"click":addPOIHandler});
}

function addPOIHandler(arg,geometry){
    clientX = arg.clientX;
    clientY = arg.clientY;
    //获取浏览器页面的宽度和高度
    var clientWidth = document.body.clientWidth;
    var clientHeight = document.body.clientHeight;
    //获取地图的高度和宽度
    var mapWidth = map.size.w;
    var mapHeight = map.size.h;
    //当前point的经纬度坐标=传入坐标-(当前页面高度-地图的高度)
    var px = new SuperMap.Pixel(clientX-(clientWidth-mapWidth),clientY-(clientHeight-mapHeight));
    var point = map.getLonLatFromPixel(px);
    var x = clientX-(clientWidth-mapWidth);
    var y = clientY-(clientHeight-mapHeight);
    map.events.unregister("click",map,addPOIHandler);
    addPOI(x,y);
}
var addPoiPopup = null;
function addPOI(x,y)
{ //获取鼠标位置
    var my_mouse = document.getElementById("SuperMap.Control.MousePosition_57");
    var num = my_mouse.innerHTML.split(‘,‘);
    var infomation=num[0].trim()+","+num[1].trim();

    var infowinHtml="";
    infowinHtml += ‘<div id="addInfo" class="infowindowTitle" style="width:270px;height:200px;"><div class="mapInfo"><h4>添加企业</h4>‘;

    infowinHtml +=‘<ul class="comInfo"><li>企业名称:<input type="text" id="enterpriseName" value=""></li>‘;
    infowinHtml +=‘<li>企业地址:<input type="text" id="enterpriseAdd" style="width:180px;" value=""></li>‘;
    infowinHtml +=‘<li>企业电话:<input type="text" id="enterpriseTel" style="width:180px;" value=""></li>‘;
    infowinHtml +=‘<li><input type="button" value="保&nbsp;存" onclick=addFeatureCompleted("‘+infomation+‘") ></li>‘;
    infowinHtml +=‘</ul>‘;
    infowinHtml += ‘</div> </div>‘;
    //*********************
    //点击后pop弹窗
    addPoiPopup = new SuperMap.Popup.FramedCloud("popwin",new SuperMap.LonLat(num[0],num[1]),null,infowinHtml,null,true);
    map.addPopup(addPoiPopup,true);
    var size = new SuperMap.Size(44,33);
    var offset = new SuperMap.Pixel(-(size.w/2), -size.h);
    var icon = new SuperMap.Icon(‘./theme/images/marker.png‘, size, offset);
    var marker = new SuperMap.Marker(new SuperMap.LonLat(num[0],num[1]),icon);
    marker.events.on({//注册点击事件的处理方法
        "rightclick":clearMarker,
        "dblclick":openInfoWin2,
        "scope": marker
    });
    //注册事件
    marker.events.register("mousedown",marker,function(e){
        isdrag = true;
        //得到marker的经纬度坐标
        var lon = marker.lonlat;
        //将经纬度坐标转换成屏幕坐标
        var pixel = map.getPixelFromLonLat(lon);
        //取整
        tx = parseInt(pixel.x);
        ty = parseInt(pixel.y);
        //获取marker相对鼠标的位置
        x1 = marker ? e.clientX : event.clientX;
        y1 = marker ? e.clientY : event.clientY;
    });
    markerLayer.addMarker(marker);
    info = "";
}

//点击标记弹出
var infowin2 = null;
function openInfoWin2(){
    closeInfoWin2();//关闭之前打开的窗口。
    var marker = this;
    if(confirm("确定清除该标记?"))
    {
        //如果是true
        alert("你按了确定,那就是返回true");
        marker.destroy();
    }
    else
    {
        //否则
        alert("你按了取消,那就是返回false");
    }

    var lonlat = marker.lonlat;
    //queryIdBySQL(lonlat.lon,lonlat.lat);
    var infowinHtml="";
    infowinHtml += ‘<div id="updateInfo" class="infowindowTitle" style="width:270px;height:200px;"><div class="mapInfo"><h4>修改企业</h4>‘;
    infowinHtml +=‘<ul class="comInfo"><li>企业名称:<input type="text" id="updateEnterpriseName" value="‘+‘"></li> ‘;
    infowinHtml +=‘<li>企业地址:<input type="text" id="updateEnterpriseAdd" style="width:180px;" value="‘+‘"></li>‘;
    infowinHtml +=‘<li>企业电话:<input type="text" id="updateEnterpriseTel" style="width:180px;" value="‘+‘"></li>‘;
    infowinHtml +=‘<li><input type="button" value="保&nbsp;存" onclick=updateSelectedFeature() >‘+ ‘</li>   ‘;
    infowinHtml +=‘   <input type="button" value="删&nbsp;除" onclick=deleteSelectedFeature() >‘+ ‘</li></ul>‘;
    infowinHtml += ‘</div> </div>‘;
    var size = new SuperMap.Size(44, 33);
    var offset = new SuperMap.Pixel(-(size.w/2), -size.h);
    //var offset = new SuperMap.Pixel(0, -size.h);
    var icon = new SuperMap.Icon("./theme/images/marker.png", size, offset);
    var popup = new SuperMap.Popup.FramedCloud("popwin",
            new SuperMap.LonLat(lonlat.lon,lonlat.lat),
            null,
            infowinHtml,
            icon,
            true);
    infowin = popup;
    map.addPopup(popup);
}

//..........................................移动标记....................................................................
//marker移动方法
function movemouse(e)
{
    //鼠标的实时位置
    if (isdrag)
    {
        var x2,y2,marker,tempSm_capital;
        if(markerLayer.markers.length==1){
            marker = markerLayer.markers[0];
            tempSm_capital = marker.sm_capital;
        }
        //获取鼠标的实时位置
        x2 = marker ? tx + e.clientX - x1 : tx + event.clientX - x1;
        y2 = marker ? ty + e.clientY - y1 : ty + event.clientY - y1;
        //转为屏幕坐标
        var pix = new SuperMap.Pixel(x2,y2);
        //屏幕坐标转为经纬度坐标
        var lon1 = map.getLonLatFromPixel(pix);
        //将此前的marker坐标清理
        markerLayer.clearMarkers();
        //var offset = new SuperMap.Pixel(x2,y2);
        var size = new SuperMap.Size(44, 33);
        var offset = new SuperMap.Pixel(-(size.w/2), -size.h);
        var icon = new SuperMap.Icon(‘./theme/images/marker.png‘,size, offset);
        marker = new SuperMap.Marker(lon1,icon);
        marker.sm_capital = tempSm_capital;
        marker.events.on({//注册点击事件的处理方法
            "rightclick":clearMarker,
            "dblclick":openInfoWin,
            "scope": marker
        });
        //注册事件
        marker.events.register("mousedown",marker,function(e){
            isdrag = true;
            var lon = marker.lonlat;
            var pixel = map.getPixelFromLonLat(lon);
            tx = parseInt(pixel.x);
            ty = parseInt(pixel.y);
            x1 = marker ? e.clientX : event.clientX;
            y1 = marker ? e.clientY : event.clientY;
        });
        markerLayer.addMarker(marker);
    }
}
document.onmousemove=movemouse;
document.onmouseup=new Function("isdrag=false");

//..........................................修改....................................................................
function editSelectedFeature(id,tmplon,tmplat) {
    if(id == null || id == ""
        || tmplon == null || tmplon == ""
        || tmplat == null || tmplat == ""){
        return;
    }
    var editFeatureParameter,
            editFeatureService,
            features,
            njEnterpriseName=document.getElementById("njEnterpriseName").value,
            njEnterpriseAdd=document.getElementById("njEnterpriseAdd").value,
            njEnterpriseTel=document.getElementById("njEnterpriseTel").value;
    if(njEnterpriseName == null || njEnterpriseName == ""
            || njEnterpriseAdd == null || njEnterpriseAdd == ""
            || njEnterpriseTel == null || njEnterpriseTel == ""){
            alert("请输入!");
        return;
    }
    closeInfoWin();
    var geometry = new SuperMap.Geometry.Point(tmplon, tmplat);
    features = {
        fieldNames:["CORP_NAME","SMUSERID","TEL","ADDR"],
        fieldValues:[njEnterpriseName,1,njEnterpriseTel,njEnterpriseAdd],
        geometry:geometry
    };
    features.geometry.id = id;
    editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
        features: [features],
        editType: SuperMap.REST.EditType.UPDATE
    });
    editFeatureService = new SuperMap.REST.EditFeaturesService(url2, {
        eventListeners: {
            "processCompleted": updateFeaturesProcessCompleted,
            "processFailed": processFailed
        }
    });
    editFeatureService.processAsync(editFeatureParameter);
}

//更新地物完成
function updateFeaturesProcessCompleted(editFeaturesEventArgs) {
    if(editFeaturesEventArgs.result.resourceInfo.succeed) {
        alert("更新成功");
        //重新加载图层
        getCenterLonLat();
        getScale();
        //重新加载图层
        clearFeatures();
        map.removeLayer(layer,true);
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("底图", url, {transparent: true, cacheEnabled: false, redirect: true},
                {scales:[1/5120000,1/2560000,1/1280000,1/640000,1/320000,1/160000,1/80000,1/40000,1/20000,1/10000,1/5000,1/2500]});
        layer.events.on({"layerInitialized":reloadLayer});
    }
    else {
        alert("更新失败");
    }
}

//..........................................删除....................................................................
//删除选中地物
function deleteSelectedFeature() {
    closeInfoWin2();
    if(ids === null || typeof ids === "undefined") return;
    var editFeatureParameter,
            editFeatureService;
    editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
        IDs: ids,
        editType: SuperMap.REST.EditType.DELETE
    });
    editFeatureService = new SuperMap.REST.EditFeaturesService(url2, {
        eventListeners: {
            "processCompleted": deleteFeaturesProcessCompleted,
            "processFailed": processFailed
        }
    });
    editFeatureService.processAsync(editFeatureParameter);
}
//删除选中地物
function deleteSelectedFeatureById(id) {
    closeInfoWin();
    if(id === null || typeof id === "undefined") return;
    var tempIds = [id];
    var editFeatureParameter,
            editFeatureService;
    editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
        IDs: tempIds,
        editType: SuperMap.REST.EditType.DELETE
    });
    editFeatureService = new SuperMap.REST.EditFeaturesService(url2, {
        eventListeners: {
            "processCompleted": deleteFeaturesProcessCompleted,
            "processFailed": processFailed
        }
    });
    editFeatureService.processAsync(editFeatureParameter);
}
//删除地物完成
function deleteFeaturesProcessCompleted(editFeaturesEventArgs) {
    if(editFeaturesEventArgs.result.resourceInfo.succeed) {
        alert("删除成功");
        getCenterLonLat();
        getScale();
        //重新加载图层
        clearFeatures();
        map.removeLayer(layer,true);
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("底图", url, {transparent: true, cacheEnabled: false, redirect: true},
                {scales:[1/5120000,1/2560000,1/1280000,1/640000,1/320000,1/160000,1/80000,1/40000,1/20000,1/10000,1/5000,1/2500]});
        layer.events.on({"layerInitialized":reloadLayer});
    }
    else {
        alert("删除失败");
    }
}
//....................................................................................................................
function reloadLayer(){
    map.addLayers([layer,vectorLayer,vectorLayer1, markerLayer,lineLayer, polygonLayer]);
    map.setCenter(new SuperMap.LonLat(centerLon, centerLat),presentScale);
}

//......................................................................................................................


//..........................................显示当前中心点....................................................................
function getCenterLonLat(){
   var piont =  map.getCenter();
    centerLon = piont.lon;
    centerLat = piont.lat;
    document.getElementById("centerPoint").value =centerLon + ":" + centerLat;
}

//..........................................显示当前比例尺....................................................................
function getScale(){
    var scale = map.getScale().toFixed(7);
    if(scale==(1/160000).toFixed(7)){
        presentScale = 5;
    }
    else if(scale==(1/80000).toFixed(7)){
        presentScale = 6;
    }
    else if(scale==(1/40000).toFixed(7)){
        presentScale = 7;
    }
    else if(scale==(1/20000).toFixed(7)){
        presentScale = 8;
    }
    else if(scale==(1/10000).toFixed(7)){
        presentScale = 9;
    }
    else if(scale==(1/5000).toFixed(7)){
        presentScale = 10;
    }
    else if(scale==(1/2500).toFixed(7)){
        presentScale = 11;
    }
    else if(scale==(1/320000).toFixed(7)){
        presentScale = 4;
    }
    else if(scale==(1/640000).toFixed(7)){
        presentScale = 3;
    }
    else if(scale==(1/1280000).toFixed(7)){
        presentScale = 2;
    }
    else if(scale==(1/2560000).toFixed(7)){
        presentScale = 1;
    }
    else if(scale==(1/5120000).toFixed(7)){
        presentScale = 0;
    }
    else{
        presentScale = 8;
    }
    document.getElementById("scale").value =presentScale;
}
function checkLeave()
{
    getCenterLonLat();
    getScale();
}
</script>
</head>
<body onload="init()" onbeforeunload="checkLeave()">
<div id="top" style="width:100%;height:100px;">江苏地图</div>
<div id="map" style="position:absolute;left:1px;right:0px;width:90%;height:80%;" >
</div>
<div id="query" style="position:absolute;right:0px;right:0px;width:10%;height:80%;">
    <table>
        <tr align="left">
            <td>条件查询</td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td>企业名称:<input id="pop" type="text" value=""/></td>
        </tr>
        <tr align="left">
            <td><a class="btn green mini" onclick="queryBySQL()" data-func="addC" href="#">查询</a>
                <a class="btn green mini" onclick="clearFeatures()" data-func="addC" href="#">清除</a>
            </td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td>企业ID:<input id="bob" type="text" value=""/></td>
        </tr>
        <tr align="left">
            <td><a class="btn green mini" onclick="queryBySQL2()" data-func="addC" href="#">查询</a></td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td><a class="btn green mini" onclick="drawGeometry1()" data-func="addC" href="#">查询(圆)</a></td>
        </tr>
        <tr align="left">
            <td><a class="btn green mini" onclick="drawGeometry2()" data-func="addC" href="#">查询(多边形)</a></td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td>
                <input type="button" value="距离量算" onclick="distanceMeasure()" />
                <input type="button" value="面积量算" onclick="areaMeasure()" />
            </td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td>
                <input type="button" value="标记" onclick="markPOI()" />
            </td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td>企业ID:<input id="qiyeid" type="text" value=""/></td>
        </tr>
        <tr align="left">
            <td><input type="button" value="删除" onclick="deleteSelectedFeature()" /></td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
        <tr align="left">
            <td><input type="button" value="显示当前中心点" onclick="getCenterLonLat()" />
                <br>
                <input id="centerPoint" type="text" value="" readonly/>
                <br>
                <input type="button" value="显示当前比例尺" onclick="getScale()" />
                <br>
                <input id="scale" type="text" value="" readonly/>
            </td>
        </tr>
        <tr align="left">
            <td>**********************************************</td>
        </tr>
    </table>
</div>
</body>
</html>

以上是关于supermap使用小结的主要内容,如果未能解决你的问题,请参考以下文章

supermap中线状要素与面状要素之间如何进行转换?

supermap 面试

vue 使用 supermap iclient-classic

IllegalStateException: supermap_license_error_wronglicensemode at com.supermap.data.Toolki

使用SuperMap Deskpro 6R.NET生成地图缓存

原创SuperMap iServer搭建