Skip to content

Instantly share code, notes, and snippets.

@ajturner
Last active May 3, 2016 21:18
Show Gist options
  • Save ajturner/471da94b931d854c89b03ecbe27c9659 to your computer and use it in GitHub Desktop.
Save ajturner/471da94b931d854c89b03ecbe27c9659 to your computer and use it in GitHub Desktop.
Streets
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href=
"http://js.arcgis.com/3.14/esri/css/esri.css">
<link rel="stylesheet" type="text/css" href=
"https://rawgit.com/benheb/legend/master/legend.css">
<title>Webmap created with Mundi</title>
<style>
#map { height:500px; } #mundi-link { position: absolute; right: 5px; z-index: 200; display: block; background: #FFF; text-decoration: none; color: #4C4C4C; top: 5px; padding: 5px; border-radius: 2px; } #legend-container { width: 218px; position: absolute; bottom: 20px; left: 13px; }
</style>
</head>
<body>
<div id="map">
<a id="mundi-link" href=
"http://benheb.github.io/mundi/?id=471da94b931d854c89b03ecbe27c9659"
target="_blank">View map in Mundi</a>
<div id="legend-container"></div>
</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=
"https://rawgit.com/benheb/legend/master/sortable.js">
</script> <script src="http://js.arcgis.com/3.14/">
</script> <script src=
"https://rawgit.com/benheb/legend/master/legend.js">
</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) { var legend = new Legend("legend-container", { editable: false, layers: [] }); $.getJSON("https://api.github.com/gists/471da94b931d854c89b03ecbe27c9659", 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; map.graphicsLayerIds.forEach(function(layer) { var layer = map.getLayer(layer); layer.setMinScale(0); layer.setMaxScale(0); layer.redraw(); legend.addLayer({ "id": layer.id, "name": layer.name, "renderer": layer.renderer.toJson() }); }); }); }); });
</script>
</body>
</html>
{
"item": {
"title": "New Map",
"snippet": "Streets",
"extent": [
[
-79.93781511219555,
35.31389240370199
],
[
-77.30658952625704,
36.282917486456945
]
]
},
"itemData": {
"operationalLayers": [
{
"url": "http://maps.wakegov.com/arcgis/rest/services/Education/Education/MapServer/2",
"visibility": true,
"opacity": 0.78,
"mode": 1,
"id": "e3d23ad1415c4a72a7c97c0d3b6833ed_2",
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"visualVariables": [
{
"type": "colorInfo",
"field": "YEAROPEN",
"stops": [
{
"value": 1997,
"color": [
255,
247,
251,
200
],
"label": null
},
{
"value": 1999.25,
"color": [
236,
226,
240,
200
],
"label": null
},
{
"value": 2001.5,
"color": [
208,
209,
230,
200
],
"label": null
},
{
"value": 2003.75,
"color": [
166,
189,
219,
200
],
"label": null
},
{
"value": 2006,
"color": [
103,
169,
207,
200
],
"label": null
},
{
"value": 2008.25,
"color": [
54,
144,
192,
200
],
"label": null
},
{
"value": 2010.5,
"color": [
2,
129,
138,
200
],
"label": null
},
{
"value": 2012.75,
"color": [
1,
100,
80,
200
],
"label": null
}
]
}
],
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
43,
140,
190,
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"
}
}
}
}
}
},
{
"url": "http://maps.wakegov.com/arcgis/rest/services/Inspections/RestaurantInspections/MapServer/0",
"visibility": true,
"opacity": 0.78,
"mode": 1,
"id": "5c68797ce230422d92a9edf72193a04e_0",
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"visualVariables": [
{
"type": "colorInfo",
"field": "LONGITUDE",
"stops": [
{
"value": -78.90188372,
"color": [
255,
245,
235,
200
],
"label": null
},
{
"value": -78.82305178,
"color": [
254,
230,
206,
200
],
"label": null
},
{
"value": -78.74421984,
"color": [
253,
208,
162,
200
],
"label": null
},
{
"value": -78.6653879,
"color": [
253,
174,
107,
200
],
"label": null
},
{
"value": -78.58655596,
"color": [
253,
141,
60,
200
],
"label": null
},
{
"value": -78.50772402,
"color": [
241,
105,
19,
200
],
"label": null
},
{
"value": -78.42889208,
"color": [
217,
72,
1,
200
],
"label": null
},
{
"value": -78.35006014,
"color": [
140,
45,
4,
200
],
"label": null
}
]
}
],
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
43,
140,
190,
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"
}
}
}
}
}
},
{
"url": "http://maps.wakegov.com/arcgis/rest/services/Transportation/Transportation/MapServer/1",
"visibility": true,
"opacity": 0.78,
"mode": 1,
"id": "c46f59745d924e9f82bdda7381bc371a_1",
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
0,
122,
194,
255
],
"width": 2,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
}
}
}
],
"baseMap": {
"baseMapLayers": [
{
"opacity": 0.5,
"visibility": false,
"url": "http://services.arcgisonline.com/arcgis/rest/services/Specialty/DeLorme_World_Base_Map/MapServer"
},
{
"opacity": 0.8,
"visibility": true,
"url": "http://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Light_Gray_Base/MapServer"
},
{
"opacity": 1,
"visibility": false,
"url": "http://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer"
}
],
"title": "basemap"
},
"version": "1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment