Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. require([
  2. "esri/WebMap",
  3. "esri/views/MapView",
  4. "esri/widgets/Expand",
  5. "esri/widgets/Legend",
  6. "esri/widgets/BasemapGallery",
  7. "esri/widgets/Home",
  8. "esri/widgets/Locate",
  9. "esri/widgets/Search",
  10. "esri/widgets/LayerList",
  11. "esri/widgets/Print",
  12. "esri/layers/FeatureLayer",
  13. "esri/tasks/Locator",
  14. "esri/widgets/ScaleBar",
  15. "dojo/domReady!"
  16. ], function(
  17. WebMap, MapView, Expand, Legend, BasemapGallery, Home, Locate, Search, LayerList, Print, FeatureLayer, Locator, ScaleBar
  18. ) {
  19.  
  20. /************************************************************
  21. * Creates a new WebMap instance. A WebMap must reference
  22. * a PortalItem ID that represents a WebMap saved to
  23. * arcgis.com or an on-premise portal.
  24. *
  25. * To load a WebMap from an on-premise portal, set the portal
  26. * url in esriConfig.portalUrl.
  27. ************************************************************/
  28. var webmap = new WebMap({
  29. portalItem: { // autocasts as new PortalItem()
  30. id: "xxxxxxI'veEditedOutThePortalIDButTrustMeItIsCorrectxxxxxxx"
  31. }
  32. });
  33.  
  34. /************************************************************
  35. * Set the WebMap instance to the map property in a MapView.
  36. ************************************************************/
  37. var view = new MapView({
  38. map: webmap,
  39. container: "viewDiv"
  40. });
  41.  
  42. var legend = new Legend({
  43. view: view,
  44. container: document.createElement('div'),
  45. layerInfos: [{
  46. layer: webmap,
  47. title: "Legend"
  48. }]
  49. });
  50.  
  51. var legendExpand = new Expand({
  52. view: view,
  53. content: legend.domNode,
  54. container: 'legendDiv',
  55. expandIconClass: "esri-icon-layer-list"
  56. });
  57. view.ui.add(legendExpand,"top-left");
  58.  
  59. var bg = new BasemapGallery({
  60. view: view,
  61. container: document.createElement('div'),
  62. });
  63.  
  64. var bgExpand = new Expand({
  65. view: view,
  66. content: bg.domNode,
  67. container: 'basemapDiv',
  68. expandIconClass: "esri-icon-basemap"
  69. });
  70. view.ui.add(bgExpand,"top-left");
  71.  
  72.  
  73.  
  74. var home = new Home({
  75. view: view
  76. });
  77. view.ui.add(home, "top-left");
  78.  
  79.  
  80. var locate = new Locate({
  81. view: view
  82. });
  83. view.ui.add(locate, "top-left");
  84.  
  85. var print = new Print({
  86. view: view,
  87. container: document.createElement('div'),
  88. printServiceUrl: "https://xxxxxxxx/arcgis/rest/services/PrintLayout/PrintLayout/GPServer/Export%20Web%20Map"
  89. });
  90.  
  91. var printExpand = new Expand({
  92. view: view,
  93. content: print.domNode,
  94. container: 'printDiv',
  95. expandIconClass: "esri-icon-printer"
  96. });
  97. view.ui.add(printExpand,"top-left");
  98.  
  99. var search = new Search({
  100. view: view,
  101. container: 'searchDiv',
  102. allPlaceholder: 'Enter Address or Parcel Number',
  103. sources: [
  104. {
  105. locator: new Locator({ url: "//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer" }),
  106. singleLineFieldName: "SingleLine",
  107. name: "ESRI World Address Geocoder",
  108. localSearchOptions: {
  109. minScale: 300000,
  110. distance: 50000
  111. },
  112. placeholder: "Search Geocoder",
  113. maxResults: 3,
  114. maxSuggestions: 6,
  115. suggestionsEnabled: true,
  116. minSuggestCharacters: 0
  117. },
  118. {
  119. featureLayer: new FeatureLayer({
  120. url: "https://xxxxxxxxx/arcgis/rest/services/xxxxxxxxx/xxxxxxxxxx/MapServer/18",
  121. outFields: ['*']
  122. }),
  123. searchFields: ['PIN','OWNAM1'],
  124. displayField: 'PIN',
  125. exactMatch: false,
  126. outFields: ['*'],
  127. name: 'Parcels: xxxxxxxx County',
  128. placeholder: 'G029001000800',
  129. maxResults: 6,
  130. maxSuggestions: 6,
  131. suggestionsEnabled: true,
  132. minSuggestCharacters: 0
  133. },
  134. {
  135. featureLayer: new FeatureLayer({
  136. url: "https://xxxxxxxxxxx/arcgis/rest/services/xxxxxxxxxxxxx/xxxxxxxxxxxxxxx/MapServer/19",
  137. outFields: ['*']
  138. }),
  139. searchFields: ['ParcelNumb_1'],
  140. displayField: 'ParcelNumb_1',
  141. exactMatch: false,
  142. outFields: ['*'],
  143. name: 'Parcels: xxxxxxxxxxxxxxx County',
  144. placeholder: '9-04-05-031.00',
  145. maxResults: 6,
  146. maxSuggestions: 6,
  147. suggestionsEnabled: true,
  148. minSuggestCharacters: 0
  149. }]
  150. });
  151. view.ui.add(search,"top-left");
  152.  
  153. var layerlist = new LayerList({
  154. view: view,
  155. container: document.createElement('div')
  156. });
  157.  
  158.  
  159.  
  160. var layerExpand = new Expand({
  161. view: view,
  162. content: layerlist.domNode,
  163. container: 'layerlistDiv',
  164. expandIconClass: "esri-icon-layers"
  165. });
  166. view.ui.add(layerExpand, "top-left");
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. var scaleBar = new ScaleBar({
  176. view: view,
  177. style: 'ruler'
  178. });
  179. view.ui.add(scaleBar,'bottom-left');
  180. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement