Skip to content

Instantly share code, notes, and snippets.

@brooksjbr
Last active December 18, 2015 14:05
Show Gist options
  • Save brooksjbr/de5ce2f52a51bfb9816c to your computer and use it in GitHub Desktop.
Save brooksjbr/de5ce2f52a51bfb9816c to your computer and use it in GitHub Desktop.
DC_bikeshare_locations
<!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=de5ce2f52a51bfb9816c"
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/de5ce2f52a51bfb9816c", 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": "DC_bikeshare_locations",
"extent": [
[
-77.29446116308563,
38.807359607533805
],
[
-76.8000763974613,
38.97730974443889
]
]
},
"itemData": {
"operationalLayers": [
{
"url": "http://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Transportation_WebMercator/MapServer/2",
"visibility": true,
"opacity": 0.78,
"mode": 1,
"id": "294e062cdf2c48d5b9cbc374d9709bc0_2",
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
177,
0,
38,
255
],
"width": 1.5,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
}
}
},
{
"url": "https://services.arcgis.com/bkrWlSKcjUDFDtgw/arcgis/rest/services/v10_bike_accidents_2013/FeatureServer/0",
"visibility": true,
"opacity": 0.78,
"mode": 1,
"id": "b456c80e30c44d06a2df930bd7bd1e88_0",
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
34,
94,
168,
128
],
"size": 3,
"angle": 0,
"xoffset": 0,
"yoffset": 0,
"type": "esriSMS",
"style": "esriSMSCircle",
"outline": {
"color": [
255,
255,
255,
255
],
"width": 1.3,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
}
}
}
},
{
"url": "https://services.arcgis.com/bkrWlSKcjUDFDtgw/arcgis/rest/services/DC_bikeshare_locations/FeatureServer/0",
"visibility": true,
"opacity": 0.78,
"mode": 1,
"id": "3e35e23064464af9b2ff6350b205e895_0",
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"type": "simple",
"label": "",
"description": "",
"symbol": {
"color": [
253,
141,
60,
200
],
"size": 4,
"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": 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