Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
  6. <title>Layer Swipe</title>
  7. <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.11/esri/css/esri.css">
  8. <style>
  9. html, body, #map,.map.container {
  10. padding:0;
  11. margin:0;
  12. height:100%;
  13. width:95%;
  14. }
  15. #legendDiv{
  16. background-color: #fff;
  17. position: absolute !important;
  18. z-index: 99;
  19. top:01%;
  20. right:0%;
  21. }
  22. </style>
  23. <script src="//js.arcgis.com/3.11/"></script>
  24. <script>
  25.  
  26. require([
  27. "esri/map",
  28. "esri/dijit/LayerSwipe",
  29. "esri/arcgis/utils",
  30. "dojo/_base/array",
  31. "esri/dijit/Legend",
  32. "dojo/domReady!",
  33. ], function(
  34. Map, LayerSwipe, arcgisUtils, array, Legend
  35. ) {
  36.  
  37. var mapDeferred = arcgisUtils.createMap("e80b5668e7ea478c986dff4bfbe7112a", "map");
  38.  
  39. mapDeferred.then(function(response){
  40.  
  41. var id;
  42. var map = response.map;
  43. var title = "Inundation Post Dike Placement";
  44.  
  45. //loop through all the operational layers in the web map
  46. //to find the one with the specified title;
  47. var layers = response.itemInfo.itemData.operationalLayers;
  48. array.some(layers, function(layer){
  49. id = layer.id;
  50.  
  51. });
  52. //get the layer from the map using the id and set it as the swipe layer.
  53. if(id){
  54. var swipeLayer = map.getLayer(id);
  55. var swipeWidget = new LayerSwipe({
  56. type: "vertical", //Try switching to "scope" or "horizontal"
  57. map: map,
  58. layers: [swipeLayer]
  59. }, "swipeDiv");
  60. swipeWidget.startup();
  61. }
  62. });
  63.  
  64. var legend = new Legend({
  65. map: map,
  66. layerInfos:(arcgisUtils.getLegendLayers(response))
  67. }, "legendDiv");
  68. legend.startup();
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement