To be resolved.
Resolved.
CodeAs follows:
/* Query attributes */
VaR searchresultcontent = "";
VaR position = 0;
Function attquery (field, value, index, symbol, level, isclear, islocate, iscatagory ){
If (isclear = true) {
map. graphics. clear ();
}< br>
If (iscatagory = false);
{< br> searchresultcontent = ""
position = 0;
}
VaR url = "http: // Meng/ArcGIS/rest/services/statisticdata/mapserver/" + index;
VaR querytask = new ESRI. Tasks. querytask (URL );
VaR query = new ESRI. Tasks. Query ();
Query. returngeometry = true;
Query. outfields = ["zonename", "type"];
Query. Where = field + "like '%" + value + "% '";
Dojo. Connect (querytask, "oncomplete", function (featureset ){
VaR showxbextent;
Searchresultcontent = searchresultcontent + "
For (VAR I = 0, IL = featureset. features. length; I <il; I ++ ){
VaR graphic = featureset. features [I];
Graphic. setsymbol (Symbol );
Graphic. setinfotemplate (statinfotemplate );
map. graphics. add (graphic);
if (I = 0) {
showxbextent = graphic. geometry. getextent ();
}< br> else {
showxbextent = showxbextent. union (graphic. geometry. getextent ();
}
Searchresultcontent = searchresultcontent + "<a" +
"Onclick = lightengraphic (" + index + "," + Position + ");" +
"Onmouseout = unlightengraphic ();" +
"Href = \" javascript: void (0) \ ";>" + graphic. attributes ["zonename"] + "</a>" + ""; // Generate HTML elements cyclically and bind the event processing method added by zhangjun
Position = Position + 1;
}
Get_imagestatistics_infos (searchresultcontent );
If (islocate = true ){
If (showxbextent! = NULL ){
Map. setextent (showxbextent. Expand (1.5 ));
}
}
Else {
Fullextent ();
}
});
Dojo. Connect (querytask, "onerror", function (ERR ){
Alert (ERR. Name + ":" + err. Message );
});
Querytask.exe cute (query );
}
/* Add image statistics */
Function get_imagestatistics_infos (response ){
$ ('Statistics _ result'). style. Display = "Block ";
$ ('Statistics _ result'). innerhtml = response;
}
/* Highlight graphic */
Function lightengraphic (index, position ){
VaR A, value = "";
A = Document. getelementbyid ("statistics_result"). getelementsbytagname ("");
Value = A [position]. innerhtml;
VaR symbol;
Switch (INDEX ){
Case 0:
Symbol = 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]), 0.5), new dojo. color ([0,255,255, 1]);
Break;
Case 1:
Symbol = 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]), 0.5), new dojo. color ([255, 0, 0, 1]);
Break;
}
VaR lightsymbol = 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]), 0.5), new dojo. color ([255,255, 0, 1]);
For (var k = 0; k <map. Graphics. Graphics. length; k ++ ){
If (Map. Graphics. graphics [K]. attributes ["zonename"] = value ){
Map. Graphics. graphics [K]. setsymbol (lightsymbol );
Graphiclocation = K;
Map. setextent (Map. Graphics. graphics [K]. Geometry. getextent (). Expand (4 ));
SetTimeout ("recoversymbol (" + index + ")", 800); // 0.8 seconds
}
}
}
VaR graphiclocation;
/* Restore symbol */
Function recoversymbol (INDEX ){
VaR symbol;
Switch (INDEX ){
Case 0:
Symbol = 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]), 0.5), new dojo. color ([0,255,255, 1]);
Break;
Case 1:
Symbol = 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]), 0.5), new dojo. color ([255, 0, 0, 1]);
Break;
}
Map. Graphics. graphics [graphiclocation]. setsymbol (Symbol );
}