ArcGIS API for JS often encounters the point that you want to click on to get the corresponding points and highlight them. The principle is the same as searching for property values in the search box and highlighting them in the map. The core idea is to get the clicked text value and replace it with the value to pass in the search box. can get our purpose.
The code is as follows:
varName//declare name to be a global variable instead of the value that the search box will pass in$(function(){ $('. Test2 a '). Click (function(){ $( This). Parent (). each (function() {//removing the remaining non-point State$ ('. Test2 a '). Removeclass ("Special_color"); }); $( This). addclass ("Special_color");//give the added style of the pointname=$ ( This). text (); })})//gets the clicked text value and assigns it to name;require (["Esri/map", "Esri/layers/arcgistiledmapservicelayer", "Esri/layers/featurelayer", "Esri/layers/graphicslayer", "Esri/graphic", "Esri/geometry/point", "Esri/symbols/simplefillsymbol", "Esri/symbols/simplelinesymbol", "Esri/symbols/simplemarkersymbol", "Dojo/_base/color", "Esri/tasks/query", "Esri/tasks/querytask", "Dojo/on", "Dojo/dom", "Dojo/domready!"], function(Map, tiled, Featurelayer, Graphicslayer, Graphic, Point, Simplefillsymbol, Simplelinesymbol, Simplemarkersymbol, Color, Query, Querytask, ON, DOM) {$ ('. Test2 a '). Click (function(event) {map.graphics.clear (); varCity =NewFeaturelayer ("http://192.168.58.138:6080/arcgis/rest/services/%E6%9C%80%E5%90%8E%E7%9A%84%E5%9B%BE%E5%B1%82/% e4%b8%9d%e7%bb%b8%e4%b9%8b%e8%b7%af/featureserver/0 "); //var name = Dom.byid ("name"). Value; varquery =NewQuery (); Query.where= "name = '" +name+ "'"; City.queryfeatures (Query,function(results) {varfeatures =Results.features; Console.log (features); Map.centerandzoom (features[0].geometry,4); varSymbol=NewEsri.symbol.SimpleMarkerSymbol (); Symbol.setsize (35); Symbol.setcolor (NewDojo. Color ([250,128,114,0.3])); Map.graphics.add (NewGraphic (features[0].geometry,symbol)); }); }); });
ArcGIS API for JS implementation Click on the text content to get the corresponding point highlighting.