var plottingEditMap, baseLayer, plottingLayer, plottingEdit, drawFeature;
var mapurl ="http://localhost:8090/iserver/services/map-ShunYiQuPeiTu/rest/maps/顺义区配图";
var serverUrl ="http://localhost:8090/iserver/services/plot-jingyong/rest/plot/";
function init_() {
plottingEditMap = new SuperMap.Map("plottingEditMap", {
controls: [
new SuperMap.Control.LayerSwitcher(),
new SuperMap.Control.ScaleLine(),
new SuperMap.Control.Zoom(),
new SuperMap.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
})]
});
baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("顺义区配图", mapurl, {
transparent: true,
cacheEnabled: true
}, {maxResolution: "auto"});
baseLayer.events.on({"layerInitialized": addLayer});
plottingLayer = new SuperMap.Layer.PlottingLayer("PlottingLayer", serverUrl);
plottingEdit = new SuperMap.Control.PlottingEdit(plottingLayer);
drawFeature = new SuperMap.Control.DrawFeature(plottingLayer, SuperMap.Handler.GraphicObject);
drawFeature.events.on({"featureadded": drawCompleted});
plottingEditMap.addControls([plottingEdit, drawFeature]);
console.log("init:初始化方法");
}
function addLayer(){
console.log("addLayer:添加图层");
plottingEditMap.addLayers([baseLayer, plottingLayer]);
plottingEditMap.setCenter(new SuperMap.LonLat(116.63505 , 40.17000), 3);
}
function drawCompleted(){
drawFeature.deactivate();
plottingEdit.activate();
}
function editableChanges(){
plottingLayer.isEditable = document.getElementById("editable").selectedIndex;
}
function lockedChanges(){
plottingLayer.isLocked = document.getElementById("locked").selectedIndex;
}
function drawPolygon()
{
drawFeature.handler.serverUrl = serverUrl;
drawFeature.handler.libID = 0;
drawFeature.handler.symbolCode = 32;
drawFeature.deactivate();
drawFeature.activate();
}
document.oncontextmenu = function(evt){
drawFeature.deactivate();
return false;
}
这是参考代码里面的模板 怎么获取鼠标绘画的坐标