我有一个基础地图图层,其中添加了地图要素图层。路由表由FeatureTable
生成,只要在表格或地图上点击路线,路线的颜色就会从绿色变为红色。我的问题是如果我放大或缩小地图,路线会变回绿色并带有红色轮廓。如果我点击路线,它将变回红色,但我需要它保持红色。我在下面显示了我的代码。任何帮助将不胜感激。
var map, stateBaseMap, geometryLayer, routeFeature, routeDataFeature, myFeatureTable,
stateBaseMapUrl, geometryLayerUrl, routeFeatureUrl, routeDataFeatureUrl, routeChange;
require([ "esri/map",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/tasks/GeometryService",
"esri/layers/FeatureLayer",
"esri/dijit/FeatureTable",
"esri/symbols/SimpleLineSymbol",
"esri/Color",
"dijit/layout/ContentPane",
"dijit/layout/BorderContainer",
"esri/geometry/Extent",
"esri/graphicsUtils",
"esri/tasks/query",
"dojo/dom",
"dojo/parser",
"dojo/ready",
"dojo/on"],
function(Map,
ArcGISDynamicMapServiceLayer,
ArcGISTiledMapServiceLayer,
GeometryService,
FeatureLayer,
FeatureTable,
SimpleLineSymbol,
Color,
ContentPane,
BorderContainer,
Extent,
graphicsUtils,
Query,
dom,
parser,
ready,
on) {
parser.parse();
ready(function(){
esri.config.defaults.io.proxyUrl = "/llr/llrproxy";
esri.config.defaults.io.alwaysUseProxy = false;
esri.config.defaults.io.corsDetection = false;
stateBaseMapUrl = document.getElementById("shipment_stateBaseMapServiceURL").value;
geometryLayerUrl = document.getElementById("shipment_geometryServiceURL").value;
routeFeatureUrl = document.getElementById("shipment_routeLayerURL").value;
map = new Map("map");
stateBaseMap = new ArcGISTiledMapServiceLayer(stateBaseMapUrl);
map.addLayer(stateBaseMap);
geometryLayer = new GeometryService(geometryLayerUrl);
map.addLayer(geometryLayer);
routeFeature = new FeatureLayer(routeFeatureUrl, {
mode : FeatureLayer.MODE_ONDEMAND,
outFields : [ "*" ],
visible:true,
id : "routeFeature"
});
var selectionSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]),6);
routeFeature.setSelectionSymbol(selectionSymbol);
map.addLayer(routeFeature);
on(routeFeature, "load", function(){
loadTable();
});
function loadTable(){
myFeatureTable = new FeatureTable({
featureLayer : routeFeature,
map : map,
editable: false,
showGridMenu:false,
gridOptions: {
selectionMode: "single"
},
editable: true,
fieldInfos: [
{
name: 'ROUTE_ID',
visible: false
},
{
name: 'ORIGIN',
alias: 'Entry State'
},
{
name: 'ROUTE_DESC',
alias: 'Route Description'
},
{
name: 'DESTNATION',
alias: 'Exit State'
}
],
menuFunctions: [
{ label: "Enter a new route.", callback: enterNewRoute }
]
}, 'myTableNode');
myFeatureTable.startup();
}
});
});
答案 0 :(得分:0)
必须有一些其他代码,清除选择。否则它应该工作。 Here是一个JSBin,显示即使在缩放/平移后选择仍然存在。我从esri网站上取样并修改了类似于你的逻辑,除了loadTable部分。
答案 1 :(得分:0)
我发现将)
更改为mode : FeatureLayer.MODE_ONDEMAND,
解决了问题,但如果我缩放或移动地图,问题仍然存在。另外,我只能使用mode : FeatureLayer.MODE_SNAPSHOT,
因为我的地图有少量功能。为了解决缩放/移动问题,我在缩放或移动完成后重新绘制了路径。
MODE_SNAPSHOT