Created
November 18, 2015 20:49
-
-
Save TheMapSmith/6fd66a5a45a11952922d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require([ | |
| "esri/map", "esri/dijit/Search", "esri/layers/FeatureLayer", "esri/InfoTemplate", "dojo/domReady!" | |
| ], function (Map, Search, FeatureLayer, InfoTemplate) { | |
| var map = new Map("map", { | |
| basemap: "gray", | |
| center: [-72.5842345,44.260972], // lon, lat | |
| zoom: 6, | |
| }); | |
| var s = new Search({ | |
| enableLabel: false, | |
| enableInfoWindow: true, | |
| showInfoWindowOnSelect: false, | |
| map: map, | |
| enableSuggestions: true, | |
| }, "search"); | |
| var sources = s.get("sources"); | |
| //Push the sources used to search, by default the ArcGIS Online World geocoder is included. In addition there is a feature layer of US congressional districts. The districts search is set up to find the "DISTRICTID". Also, a feature layer of senator information is set up to find based on the senator name. | |
| sources.push({ | |
| featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServer/0"), | |
| searchFields: ["DISTRICTID"], | |
| displayField: "DISTRICTID", | |
| exactMatch: false, | |
| outFields: ["DISTRICTID", "NAME", "PARTY"], | |
| name: "Congressional Districts", | |
| placeholder: "3708", | |
| maxResults: 6, | |
| maxSuggestions: 6, | |
| //Create an InfoTemplate and include three fields | |
| infoTemplate: new InfoTemplate("Congressional District", "District ID: ${DISTRICTID}</br>Name: ${NAME}</br>Party Affiliation: ${PARTY}"), | |
| enableSuggestions: true, | |
| minCharacters: 0 | |
| }); | |
| sources.push({ | |
| featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"), | |
| searchFields: ["Name"], | |
| displayField: "Name", | |
| exactMatch: false, | |
| name: "Senator", | |
| outFields: ["*"], | |
| placeholder: "Senator name", | |
| maxResults: 6, | |
| maxSuggestions: 6, | |
| //Create an InfoTemplate | |
| infoTemplate: new InfoTemplate("Senator information", "Name: ${Name}</br>State: ${State}</br>Party Affiliation: ${Party}</br>Phone No: ${Phone_Number}<br><a href=${Web_Page} target=_blank ;'>Website</a>"), | |
| enableSuggestions: true, | |
| minCharacters: 0 | |
| }); | |
| //Set the sources above to the search widget | |
| s.set("sources", sources); | |
| s.startup(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment