Skip to content

Instantly share code, notes, and snippets.

@benheb
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save benheb/a353bd2b06e193a46290 to your computer and use it in GitHub Desktop.

Select an option

Save benheb/a353bd2b06e193a46290 to your computer and use it in GitHub Desktop.
Map from WebMapJson
{"item":{"title":"New Map","snippet":"Map from WebMapJson","extent":[[-137.91425781246292,30.481104222782335],[-79.15937499997854,50.116525543940575]]},"itemData":{"operationalLayers":[{"url":"https://services2.arcgis.com/1UvBaQ5y1ubjUPmd/arcgis/rest/services/Weather_Stations/FeatureServer/0","visibility":true,"opacity":0.78,"layerDefinition":{"drawingInfo":{"renderer":{"type":"simple","label":"","description":"","symbol":{"color":[227,26,28,200],"size":6,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS","style":"esriSMSCircle","outline":{"color":[255,255,255,255],"width":1.3,"type":"esriSLS","style":"esriSLSSolid"}}}}},"mode":1,"id":"graphicsLayer0"},{"url":"https://services3.arcgis.com/66aUo8zsujfVXRIT/arcgis/rest/services/colorado_drug_takeback_locations.gdb/FeatureServer/0","visibility":true,"opacity":0.78,"layerDefinition":{"drawingInfo":{"renderer":{"visualVariables":[{"type":"colorInfo","field":"AREA","stops":[{"value":33.3183239407,"color":{"r":255,"g":247,"b":251,"a":0.7843137254901961},"label":null},{"value":625.8122922581125,"color":{"r":236,"g":226,"b":240,"a":0.7843137254901961},"label":null},{"value":1218.306260575525,"color":{"r":208,"g":209,"b":230,"a":0.7843137254901961},"label":null},{"value":1810.8002288929374,"color":{"r":166,"g":189,"b":219,"a":0.7843137254901961},"label":null},{"value":2403.29419721035,"color":{"r":103,"g":169,"b":207,"a":0.7843137254901961},"label":null},{"value":2995.7881655277624,"color":{"r":54,"g":144,"b":192,"a":0.7843137254901961},"label":null},{"value":3588.282133845175,"color":{"r":2,"g":129,"b":138,"a":0.7843137254901961},"label":null},{"value":4180.776102162587,"color":{"r":1,"g":100,"b":80,"a":0.7843137254901961},"label":null}]}],"type":"simple","label":"","description":"","symbol":{"color":[43,140,190,200],"outline":{"color":[255,255,255,255],"width":0.5,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}}}},"mode":1,"id":"graphicsLayer1"}],"baseMap":{"baseMapLayers":[{"opacity":1,"visibility":true,"url":"http://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Light_Gray_Base/MapServer"},{"opacity":0.3,"visibility":true,"url":"http://services.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade/MapServer"}],"title":"basemap"},"version":"1.0"}}
<!DOCTYPE html> <meta charset="utf-8"> <link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css"> <style> #map { height:100%; } </style> <body> <div id="map"></div> <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script src="http://js.arcgis.com/3.14/"></script> <script> require(["esri/map","esri/urlUtils","esri/arcgis/utils","esri/layers/FeatureLayer","esri/renderers/SimpleRenderer","esri/renderers/jsonUtils","dojo/domReady!"], function(Map,urlUtils,arcgisUtils,FeatureLayer,SimpleRenderer,jsonUtils) { $.getJSON("https://api.github.com/gists/a353bd2b06e193a46290", function(data) { var webmap; for (var file in data.files ) { if ( file !== "index.html" ) { webmap = JSON.parse(data.files[file].content); } }; arcgisUtils.createMap(webmap, "map").then(function(response){ var map = response.map; }); }); }); </script> </body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment