Last active
August 29, 2015 14:27
-
-
Save nateirwin/1069431ad6e14335f31a to your computer and use it in GitHub Desktop.
Add data from ArcGIS Server/Online services to an NPMap.js map.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 0; | |
padding: 0; | |
} | |
#map { | |
bottom: 0; | |
position: absolute; | |
top: 0; | |
width: 100%; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NPMap = { | |
div: 'map', | |
baseLayers: [{ | |
attribution: 'Esri', | |
clickable: false, | |
tiled: true, | |
type: 'arcgisserver', | |
url: 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer' | |
}], | |
overlays: [{ | |
attribution: 'Land Resources Division', | |
name: 'National Parks', | |
type: 'geojson', | |
url: 'https://server-utils.herokuapp.com/arcgis2geojson/?url=http://mapservices.nps.gov/arcgis/rest/services/LandResourcesDivisionTractAndBoundaryService/MapServer/1' | |
},{ | |
attribution: 'Great Smoky Mountains National Park', | |
name: 'Restrooms', | |
popup: { | |
title: '{{Name}}' | |
}, | |
styles: { | |
point: { | |
'marker-library': 'npmaki', | |
'marker-symbol': 'restroom-white' | |
} | |
}, | |
type: 'geojson', | |
url: 'http://services1.arcgis.com/fBc8EJBxQRMcHlei/ArcGIS/rest/services/GRSM_RESTROOMS/FeatureServer/0/query?f=geojson&outSR=4326&where=OBJECTID+IS+NOT+NULL' | |
},{ | |
attribution: 'Esri', | |
layers: '2', | |
name: 'National Parks', | |
opacity: 0.5, | |
popup: { | |
description: { | |
fields: [ | |
'PARKNAME', | |
'UNIT_TYPE' | |
], | |
format: 'table' | |
}, | |
title: '{{PARKNAME}}' | |
}, | |
tiled: false, | |
type: 'arcgisserver', | |
url: 'http://mapservices.nps.gov/arcgis/rest/services/LandResourcesDivisionTractAndBoundaryService/MapServer' | |
},{ | |
attribution: 'Esri', | |
name: 'Hurricanes', | |
layers: '0,1', | |
opacity: 1, | |
popup: { | |
actions: '<ul><li><a href="#" onclick="window.alert(\'Clicked!\');return false;">Click Me</a></li></ul>', | |
description: function(data) { | |
var html = '<table><tbody>'; | |
if (typeof data.CAT === 'undefined') { | |
html += '' + | |
'<tr><td>Stage</td><td>{{STAGE}}</td></tr>' + | |
'<tr><td>Day</td><td>{{DAY}}</td></tr>' + | |
'<tr><td>Time</td><td>{{TIME}}</td></tr>' + | |
'<tr><td>Pressure</td><td>{{PRESSURE}}</td></tr>' + | |
'<tr><td>Wind Speed (Knots)</td><td>{{WINDSPEED}}</td></tr>' + | |
''; | |
} else { | |
html += '' + | |
'<tr><td>Category</td><td>{{CAT}}</td></tr>' + | |
'<tr><td>Date</td><td>{{Date_date}}</td></tr>' + | |
'<tr><td>Start Time</td><td>{{Time}}</td></tr>' + | |
'<tr><td>End Time</td><td>{{EndTime}}</td></tr>' + | |
'<tr><td>Wind Speed (Knots)</td><td>{{WIND_KTS}}</td></tr>' + | |
''; | |
} | |
return html + '</tbody></table>'; | |
}, | |
title: function(data) { | |
if (typeof data.CAT === 'undefined') { | |
return data.EVENTID; | |
} else { | |
return data.NAME; | |
} | |
} | |
}, | |
tiled: false, | |
type: 'arcgisserver', | |
url: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/Hurricanes/MapServer' | |
}] | |
}; | |
(function() { | |
var s = document.createElement('script'); | |
s.src = 'http://www.nps.gov/lib/npmap.js/2.0.0/npmap-bootstrap.min.js'; | |
document.body.appendChild(s); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"> | |
<title>ArcGIS Layer | Examples | NPMap.js</title> | |
<link href="arcgis-server-layer.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="arcgis-server-layer.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment