Skip to content

Instantly share code, notes, and snippets.

@chelm
Created July 31, 2015 16:58
Show Gist options
  • Save chelm/07cceaecf8f6b0b292f7 to your computer and use it in GitHub Desktop.
Save chelm/07cceaecf8f6b0b292f7 to your computer and use it in GitHub Desktop.
Map from WebMapJson
{"item":{"title":"New Map","snippet":"Map from WebMapJson","extent":[[-74.20396678888578,40.787254107974555],[-68.60093944513606,43.40350656905478]]},"itemData":{"operationalLayers":[{"url":"http://services.massdot.state.ma.us/ArcGIS/rest/services/Transit/ParkandRideLots/MapServer/0","visibility":true,"opacity":0.78,"mode":1,"id":"graphicsLayer1","layerDefinition":{"drawingInfo":{"renderer":{"type":"simple","label":"","description":"","symbol":{"color":[8,88,158,200],"size":13.999999999999998,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS","style":"esriSMSCircle","outline":{"color":[255,255,255,255],"width":1.3,"type":"esriSLS","style":"esriSLSSolid"}}}}}}],"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:500px; } </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/07cceaecf8f6b0b292f7", 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