npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

esri-leaflet-stream

v1.1.0

Published

Plugin for consuming streaming data from ArcGIS for Server via a socket connection

Downloads

21

Readme

Esri Leaflet Stream

A plugin for Esri Leaflet that enables consuming Stream Services published by ArcGIS for Server. View Demo

Basic Usage

Step 1. Include the required js in your document.

   	<script src="dist/esri-leaflet-stream.min.js"></script>

Step 2. Create a stream layer using the L.esri.streamFeatureLayer function, the socket connection is started automatically when the layer is added to the map.

	var buses = L.esri.streamFeatureLayer({
		url: 'https://geoeventsample1.esri.com:6443/arcgis/rest/services/LABus/StreamServer'
	}).addTo(map);

Background Information

Esri Stream Services provide a convenient way to consume streaming data published via the GeoEvent Extension with ArcGIS for Server. Basically they continually send data to the website which you can then use however you'd like. For more information also check out the REST API.

Options

| Option | Type | Description | | ------------- |--------|---------------| | url | String | Required The service url of a streaming layer eg https://geoeventsample3.esri.com:6443/arcgis/rest/services/SeattleBus/StreamServer | | useMapViewExtent | Boolean | Applies a geographic filter meaning data is only sent for the current map view (note: the extent updates as the map is panned and zoomed). Defaults to false. | | customExtent | Envelope Object | An Esri envelope to spatial restrict the features. Not set by default. | | where | String | An optional expression to filter features server side. String values should be denoted using single quotes ie: where: "FIELDNAME = 'field value'"; More information about valid SQL syntax. | | fields | Array | An array of fieldnames to pull from the service. Includes all fields by default. | | wss | Boolean | Whether to use secure protocol or not. Set to false as default. |

Example

	var buses = L.esri.streamFeatureLayer({
		url: 'https://geoeventsample1.esri.com:6443/arcgis/rest/services/LABus/StreamServer',
		useMapViewExtent: true,
		where: "run_id='76_173_1'",
		fields: ['run_id', 'heading'],
		pointToLayer: function (geojson, latlng) {
			return L.circleMarker(latlng, {
				fillColor: createRandomFill(),
				fillOpacity: 0.8,
				color: "#cccccc",
				weight: 2
			});
		},
	}).addTo(map);

Methods

| Method | Description | | ------------- |---------------| | setCustomExtent(<Envelope Object>) | Set a new custom extent for the socket connection. | | clearCustomExtent() | Removes the custom extent meaning no geographic filter will be applied to the socket connection. | | useMapViewExtent(Boolean) | Set whether to use the map view extent as a geographic filter for the socket connection, this updates automatically as the map is zoomed and panned. | | setWhere(String) | Sets a where clause on the socket connection to limit data received by the socket connection. | | clearWhere() | Remove the where clause from the socket connection. | | clearLayers() | Clears the layers drawn by the socket connection. |

Example

	var buses = L.esri.streamFeatureLayer({
		url: 'https://geoeventsample1.esri.com:6443/arcgis/rest/services/LABus/StreamServer'
	}).addTo(map);
	buses.setWhere("run_id='76_173_1'");
	buses.useMapViewExtent(false);

Events

| Event | Description | | ------------ |---------------| | socketConnected | The socket connection has successfully connected. | | socketError | The socket connection failed to connect. | | socketMessage | A message was received by the socket connection, returns an object containing the geojson feature as well as the resulting leaflet layer. | | socketUpdated | A message confirming that the socket connection has been updated, triggered when the filters change. |

Example

	function msgEvent (msgDetails) {
		console.log(msgDetails.feature);
		console.log(msgDetails.layer);
	}
	buses.on('socketMessage', msgDetails);

Acknowledgements

Huge hats off go to mourner and all the contributors to the leaflet.js project! Additional thanks to the folks involved in esri-leaflet for making it super easy to work with services published from the Esri stack.