ArcGIS API for JS implementation Click on the text content to get the corresponding point highlighting.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.