rec-tab
require([
"esri/map",
"esri/geometry/Extent",
"esri/control/GeoPlotting",//extra 导入扩展包
"esri/control/GeoPlottingEdit",//extra 导入扩展包
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/TextSymbol",
"esri/symbols/Font",
"esri/graphic",
"dojo/_base/event",
"dojo/_base/Color",
"dojo/domReady!"
], function (Map,
Extent,
Plotting,
PlottingEdit,
SimpleMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol,
TextSymbol,
Font,
Graphic,
event,
Color) {
$("#esricdBar").delegate("a", "click", function () {
var type = $(this).attr("node-type");
if(type){
mapHelper.toolbar.activate(type);
}
});
$("#esricdBar").delegate("button[node-type=operation]", "click", function () {
var name = $(this).attr("node-name");
if(name=="close"){
mapHelper.toolbar.deactivate();
}else if(name=="clear"){
mapHelper.map.graphics.clear();
mapHelper.editToolbar.deactivate();
}
});
/** 新建地图画布*/
mapHelper.map = new Map("map_canvas", {
"logo": false,
"maxZoom": initial_max_zoom,//最大缩放级别
"minZoom": initial_min_zoom,//最小缩放级别
"nav": false
});
/** 地图中心点*/
var point = esri.geometry.geographicToWebMercator(new esri.geometry.Point({
"x": initial_lng,
"y": initial_lat
}));
/** 设置中心点位置*/
mapHelper.map.centerAt(point);
/** 缩放级别*/
mapHelper.map.setZoom(7);
/** 添加google底图*/
var googleMap = getGoogleSatelliteMapTileLayer(googlemaptileurl_satellite);
mapHelper.map.addLayer(googleMap);
/**工具栏激活 */
mapHelper.toolbar = new Plotting(mapHelper.map);
mapHelper.editToolbar = new PlottingEdit(mapHelper.map);
mapHelper.toolbar.on("draw-end", function(evt){
mapHelper.toolbar.deactivate();
var symbol;
switch (evt.geometry.type) {
case "point":
// 文本类型
if(evt.geometry.isText){
symbol = new TextSymbol(evt.geometry.text).setColor(new Color([128,0,0])).setAlign(Font.ALIGN_START).setAngle(0).setFont(new Font("16pt").setWeight(Font.WEIGHT_BOLD)).setHorizontalAlignment("left");
break;
}
case "multipoint":
symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 12, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 2), new Color([255, 0, 0,0.4]));
break;
case "polyline":
symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 3);
break;
default:
symbol = new SimpleFillSymbol(
SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 1),
new Color([255, 0, 0, 0.3]));
break;
}
console.log(evt.geometry.toJson())
var graphic = new Graphic(evt.geometry, symbol);
mapHelper.map.graphics.add(graphic);
});
mapHelper.map.graphics.on("click", function(evt) {
if(evt.graphic&&!mapHelper.toolbar.activated){
event.stop(evt);
mapHelper.editToolbar.activate(evt.graphic);
}
});
mapHelper.map.on("click", function(evt){
mapHelper.editToolbar.deactivate();
});
console.log('Contact:[email protected]');
});