//坐标转换:
var latlng = new Point(parseFloat(p.lng), parseFloat(p.lat), wgs);
var webMercator = webMercatorUtils.geographicToWebMercator(latlng);
return {
"x": webMercator.x,
"y": webMercator.y,
"attributes": attributes
};
//设置中心
var centerPoint = new esri.geometry.Point(x, y, new esri.SpatialReference({ wkid: 4326 }));
map.centerAt(centerPoint);
//添加点要素
var symbol = new esri.symbol.PictureMarkerSymbol('images/positionIco.png', 27, 38);
var attr = {"NAME": "name"};
var point = new esri.geometry.Point(x, y, map.spatialReference);
var graphic = new esri.Graphic(point, symbol,attr);
map.graphics.add(graphic);
//点击获取面要素的范围
console.log(evt.graphic.geometry.cache._extent.xmin);
console.log(evt.graphic.geometry.cache._extent.xmax);
//创建线符号
var pointSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 10,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([0, 0, 0]), 1),
new esri.Color([255, 0, 0, 1]));
var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 255, 255]), 0.35);
var fillsymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, lineSymbol);
var fillsymbol1 = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0, 1]), 1),
new dojo.Color([255, 170, 0, 1])); //黄色
//地图事件
featureLayer.on("click", function(evt) {
if(evt.graphic.geometry.type == "point"){
}
});
map.on("extent-change", function (evt){});
//弹出框
var infoTemplate = new esri.InfoTemplate("Attributes", "State Name: ${CYJBDWMC}
Population: ${XZQDM}");
var popUp = new esri.Graphic(evt.graphic.geometry, pointSymbol,evt.graphic.attributes, infoTemplate);
map.graphics.add(popUp);
function init(){
var customExtentAndSr=new esri.geometry.Extent(5498775.53881282,718595.518276498,5563466.29319433,765029.986145433,new esri.SpatialReference({"wkid":32650}));
var map=new esri.Map("map",{
extent:customExtentAndSR,
showLabels:true
});
var mapLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://admin-admin:8010/ArcGISServer/rest/services/B-1-12/B-1-12%E5%B1%82/MapServer");
map.addLayer(mapLayer);
}
//添加文字标注:
var labelSymbol = new TextSymbol(json);
var json = {
"labelExpressionInfo": {"value": "{BZ2}"},
"fieldInfos": [{fieldName: "BZ2"}]
};
var lc = new LabelClass(json);
lc.symbol = labelSymbol;
featureLayer.setLabelingInfo([ lc ]);
//文字标注
var font = new esri.symbol.Font();
font.setSize("8pt");
font.setFamily("微软雅黑");
var text = new esri.symbol.TextSymbol(name);
text.setFont(font);
text.setColor(new dojo.Color([255, 0, 0, 100]));
text.setOffset(0, 15);
//FindTask属性查询
var map;
function init() {
map = new esri.Map("mapDiv");
var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://admin-admin:8010/ArcGIS/rest/services/B-1-12/MapServer");
map.addLayer(layer)
}
function doFind() {
//创建属性查询对象
var findTask = new esri.tasks.FindTask("http://admin-admin:8010/ArcGIS/rest/services/B-1-12/MapServer");
//创建属性查询参数
var findParams = new esri.tasks.FindParameters();
//是否返回给我们几何信息
findParams.returnGeometry = true;
//对哪一个图层进行属性查询
findParams.layerIds = [1];
//查询的字段
findParams.searchFields = ["ID"];
//searchText和searchFields结合使用
findParams.searchText = "0";
//执行查询对象
findTask.execute(findParams, ShowFindResult);
}
function ShowFindResult(queryResult) {
//创建线符号
var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new esri.Color([255, 0, 0]), 3);
//创建面符号
var fill = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, lineSymbol);
if (queryResult.length == 0) {
alert("无符合条件的要素");
}
if (queryResult.length > 0) {
for (var i = 0; i < queryResult.length; i++) {
//获得图形graphic
var graphic = queryResult[i].feature;
//赋予相应的符号
graphic.setSymbol(fill);
//将graphic添加到地图中,从而实现高亮效果
map.graphics.add(graphic);
}
}
}
//QueryTask属性查询
function doFind() {
var queryTask = new esri.tasks.QueryTask("http://192.168.1.60:8010/ArcGIS/rest/services/%E9%AB%98%E6%96%B0%E4%BA%A7%E4%B8%9A%E5%9B%AD/MapServer/1");
var query = new esri.tasks.Query();
query.where = "YQ = '创新产业园一期' AND LD = 'A1' AND LC = '5'";
query.outSpatialReference = {wkid:32650};
query.returnGeometry = true;
query.outFields = ["*"];
queryTask.execute(query, showQueryResult);
};
function showQueryResult(queryResult) {
if (queryResult.features.length == 0) {
alert("无符合条件的要素");
}
else if (queryResult.features.length > 0) {
alert(queryResult.features.length);
xmin = queryResult.features[0].geometry.getExtent().xmin;
xmax = queryResult.features[0].geometry.getExtent().xmax;
ymin = queryResult.features[0].geometry.getExtent().ymin;
ymax = queryResult.features[0].geometry.getExtent().ymax;
for (var i = 0; i < queryResult.features.length; i++) {
var graphic = queryResult.features[i];
map.graphics.add(graphic);
if (queryResult.features[i].geometry.getExtent().xmin < xmin) {
xmin = queryResult.features[i].geometry.getExtent().xmin
}
if (queryResult.features[i].geometry.getExtent().xmax > xmax) {
xmax = queryResult.features[i].geometry.getExtent().xmax
}
if (queryResult.features[i].geometry.getExtent().ymin < ymin) {
ymin = queryResult.features[i].geometry.getExtent().ymin
}
if (queryResult.features[i].geometry.getExtent().ymax > ymax) {
ymax = queryResult.features[i].geometry.getExtent().ymax
}
extent = new esri.geometry.Extent({xmin,ymin,xmax,ymax,"spatialReference":{"wkid":32650}});
map.setExtent(extent);
mapLayer.setVisibility(true);
}
}
}
//map成功加载第一张地图时触发
dojo.connect(map, 'onLoad', function(map) {
//继续加载别的地图
var layer2 = new ArcGISDynamicMapServiceLayer(SERVER2);
//设置只显示哪些图层
layer2.setVisibleLayers([0, 1]);
map.addLayer(layer2);
//给map注册事件等等
//......
});
//oracle空间缓冲区查询
select count(OBJECTID) FROM CYJBDWSJ2 where sde.st_intersects (cyjbdwsj2.shape,sde.st_buffer(sde.st_polygon('polygon ((117.05461126849292 31.90898040457745,117.32888364936622 31.976941702492955,117.25121359460564 31.773057808746433,117.14684445852112 31.797329700859112,117.05461126849292 31.90898040457745))',4326),0.1)) = 1
select count(OBJECTID) FROM CYJBDWSJ2 where sde.st_intersects (cyjbdwsj2.shape,sde.st_buffer(sde.st_multilinestring('multilinestring ((116.95752370004219 116.95752370004219,117.28033986514086 31.955096999591543,117.22451451328169 31.692960564774584))',4326),0.1)) = 1
select count(OBJECTID) FROM CYJBDWSJ2 where sde.st_intersects (cyjbdwsj2.shape,sde.st_buffer(sde.st_point('point (117.05461126849292 31.90898040457745)',4326),0.1)) = 1
以下为ArcGIS中Python代码:
ArcGIS Python属性自动编号脚本:
rec=0
def autoIncrement():
global rec
pstart=1
pInterval=1
if(rec==0):
rec=pstart
else:
rec=rec+pInterval
return rec
autoIncrement()
ArcGIS Python多字段标注
Function FindLabel ( [FH] , [JZMJ] )
FindLabel =[FH] & vbNewLine & [JZMJ]
End Function
ArcGIS Python条件符号化
Function FindLabel ( [Name] )
if (len([Name])) >10 then
FindLabel = left( [Name],6) & chr(13) & right([Name],len([Name])-6)
else
FindLabel = [Name]
end if
End Function