Use Web GIS to load display maps published by ArcGIS for server and provide query marker display properties

Source: Internet
Author: User

The Mxd map file published by ArcGIS Desktop Association is first opened through ArcGIS Server Manager, and is available in the basic tutorials for ArcGIS server.

1<! DOCTYPE html>234<meta charset="UTF-8">5<title>Test</title>6<link rel="stylesheet"href="Http://js.arcgis.com/3.9/js/esri/css/esri.css"/>7<style type="Text/css">8 Html,body, #map {9Margin0;TenPadding0; OneWidth -%; AHeight -%; - } -</style> the<script src="http://js.arcgis.com/3.9/"></script> -<script type="Text/javascript"> - varinfotemplate; - require ([ + "Dojo/parser", - "Dojo/query",//Enquiry + "dojo/on",//Associate A "Esri/tasks/findtask",//Query Task at "esri/tasks/findparameters",//Query Parameters - "Esri/symbols/simplelinesymbol",//line Symbol - "Esri/symbols/simplefillsymbol",//Fill Symbol - "Esri/color",//Color - "esri/graphic",//Graphics - "esri/infotemplate",//Panel Information Templates in "Esri/geometry/point",//Point - "esri/spatialreference",//Control Reference System to "Esri/map", + "Esri/layers/arcgisdynamicmapservicelayer", - "Dojo/domready" the ],function (parser, * Query, $ On ,Panax Notoginseng Findtask, - Findparameters, the Simplelinesymbol, + Simplefillsymbol, A Color, the Graphic, + Infotemplate, - Point , $ Spatialreference, $ Map, - Arcgisdynamicmapservicelayer) { -  the parser.parse (); - //var map=new map ("map", {Wuyi //center:[114.30,30.60], the //Zoom:9, - //spatialreference:{"Wkid": 4326} Wu //    }); - varmap=NewMap ("Map"); About varLayer=NewArcgisdynamicmapservicelayer ("Http://localhost:6080/arcgis/rest/services/%E6%B5%8B%E8%AF%95/%E8%A7%86%E9%A2%91%E6%95%99%E5%AD%A66/MapServer"); $ map.addlayer (layer); -  -  -Query"#btn"). On ("Click", function () { A //Get Search Name + varName=query (". NM")[0].value; the //instantiating query Parameters - varFindparams =Newfindparameters (); $ //returns a graphic instance geometry theFindparams.returngeometry =true; the //querying the fourth layer theFindparams.layerids = [4]; the //Match property name--name---can add multiple attribute fields -Findparams.searchfields = ["NAME"]; in //Findparams.searchfields = ["id"]; the //Search Name--Search name theFindparams.searchtext =name; About //instantiating a Query object the varFindtask =NewFindtask ("Http://localhost:6080/arcgis/rest/services/%E6%B5%8B%E8%AF%95/%E8%A7%86%E9%A2%91%E6%95%99%E5%AD%A66/MapServer"); the //to query the Findtask.execute (Findparams,showfindresult) + }); -  the //graphing of query parametersBayi function Showfindresult (queryresult) { the map.graphics.clear (); the if(Queryresult.length = =0) { -Alert"without the element"); - return; the } the  for(vari =0; i < queryresult.length; i++) { the //get the shape of the graphic the varFeature=queryresult[i].feature; - varGeometry =Feature.geometry; the  the //Setting Property Information the varAttr={94 "Layer": Queryresult[i].layername, the "name": Queryresult[i].value the };  the //Show Templates98Infotemplate=NewInfotemplate ("title: ${layer}","address: ${name}"); About  - //define a symbol for a highlighted graphic101 //1. Defining boundary line symbols for polygons102 varOutline=NewSimplelinesymbol (Simplelinesymbol.style_dashdot,NewColor ([255,0,0]),1);103 //2. Defining Polygon Symbols104 varPolygonsymbol =NewSimplefillsymbol (Simplefillsymbol.style_solid, outline,NewColor ([0,255,0,1])); the //Create client Graphics---Geometry graphics polygonsymbol symbols attr properties infotemplate templates106 varGraphic =NewGraphic (geometry,polygonsymbol,attr,infotemplate);107 //coordinate system required in case of use of coordinates108 //Add client graphics to map109 map.graphics.add (graphic); the }111 } the 113  the }); the</script> the117<body>118Name:<inputclass="nm"Type="text"/>119<input id="btn"Type="Button"Value="Enquiry"/> -<div id="Map"></div>121</body>122

Use Web GIS to load display maps published by ArcGIS for server and provide query marker display properties

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.