Estoy usando ArcGIS 10.1 para Server y tratando de conseguir un FindTask trabajando a través de esta muestra y la única diferencia entre mi código y las muestras que puedo ver es que los datos de la muestra tienen una operación de búsqueda habilitada.
No encuentro en mi gestor de servidores dónde habilitar esto. ¿Y es necesario? Ahora mismo la búsqueda no devuelve ningún resultado.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Encontrar la tarea
<style type="text/css">
html, body { height: 100%; width: 100%; margin: 0; padding: 0; overflow:hidden; }
body { font-size: 0.9em; font-family: Geneva, Arial, Helvetica, sans-serif;
} .details { font-weight: bold; } #grid { border:
1px solid #333;}
</style>
<script type="text/javascript">
dojoConfig = {
parseOnLoad: true
};
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"></script>
<script type="text/javascript" language="Javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("esri.map");
dojo.require("esri.tasks.find");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
var findTask, findParams, map;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-9199621.530456403,
"ymin":3365235.5214724857,
"xmax":-9077475.159256855,
"ymax":3443965.6606061114,
"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
var censusMapLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisprod2/arcgis/rest/services/Dynamic/Zoning/MapServer", {
});
map.addLayer(censusMapLayer);
//create find task with url to map service
findTask = new esri.tasks.FindTask("http://gisprod2/arcgis/rest/services/Dynamic/Zoning/MapServer");
//create find parameters and define known values
findParams = new esri.tasks.FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [4];
findParams.searchFields = ["ZONECLASS"];
dojo.connect(map, 'onLoad', function(theMap) {
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
});
}
function execute(searchText) {
//set the search text to find parameters
findParams.searchText = searchText;
findTask.execute(findParams, showResults);
}
function showResults(results) {
//symbology for graphics
var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 1);
var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
//find results return an array of findResult.
map.graphics.clear();
var dataForGrid = [];
//Build an array of attribute information and add each found graphic to the map
dojo.forEach(results, function(result) {
var graphic = result.feature;
dataForGrid.push([result.layerName, result.foundFieldName, result.value]);
switch (graphic.geometry.type) {
case "point":
graphic.setSymbol(markerSymbol);
break;
case "polyline":
graphic.setSymbol(lineSymbol);
break;
case "polygon":
graphic.setSymbol(polygonSymbol);
break;
}
map.graphics.add(graphic);
});
var data = {
items: dataForGrid
};
var store = new dojo.data.ItemFileReadStore({
data: data
});
grid.setStore(store);
}
dojo.addOnLoad(init);
</script>
Encuentre el estado/ciudad/río: Nombre de la capa Nombre del campo Valor