ArcGIS SensorThings Javascript Library


SensorUp has created a library in Javascript that allows ArcGIS clients to view and access SensorThings API directly within the Esri map. The minimum code to get you started using the library is shown below.


Options:



<!-- index.html -->

<!DOCTYPE html>
<html>
	<head>
		<title>ArcGIS STA Lib</title>

		<!-- Add path to ArcGIS CSS -->
		<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/4.1/esri/css/main.css">

		<!-- Add path to custom stylesheet -->
		<link rel="stylesheet" type="text/css" href="./css/index.css"/>
	</head>
	<body>
		<!-- Map container -->
		<div id="map"></div>

		<!-- Add path to requirejs library -->
		<script type="text/javascript" src="./lib/require.js"></script>

		<!-- Add path to index.js -->
		<script type="text/javascript" src="./js/index.js"></script>
	</body>
</html>
/* index.css */

html, body, #map{
	height: 100%;
	width: 100%;
	padding: 0;
	margin: 0;
}
// index.js

requirejs.config({
	paths: {
		"staLib": "/arcgis-sta-lib"
	},
	bundles: {
		"arcgis_sta_lib": ["sta_lib"]
	}
});

require(['sta_lib'],function(staLib){
	staLib.init({
		baseURL: "http://example.sensorup.com/v1.0/",     
		mapContainer: "map",  
		view: "Things"
	});
});


Docs

init(settings)

Parameters Type: Object

Return Type: object

Requires an object specifying the settings for the map. Creates a map with the corresponding view. Returns a promise, if the promise is resolved it returns a map object.


processor(settings, initMap)

Parameters: object, boolean

Return Type: object

Expects an object that contians the settings for the map and a boolean indicating whether to initialize the map. Returns a promise, if the promise is resolved it returns a map object.