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

mapboxgljs-ellipsis

v3.1.5

Published

Use Ellipsis Drive layers in mapboxgl.js projects.

Downloads

161

Readme

Import the Ellipsis library in a mapbox-gl-js project

with script tags

<!-- Import Mapbox -->
<link
  href="https://api.mapbox.com/mapbox-gl-js/v2.5.1/mapbox-gl.css"
  rel="stylesheet"
/>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.5.1/mapbox-gl.js"></script>
<!-- Import the latest version of the ellipsis library -->
<script src="https://github.com/ellipsis-drive/ellipsis-js-util/releases/download/1.3.3/ellipsis-js-util-1.3.3.js"></script>
<script src="https://github.com/ellipsis-drive/mapboxgljs-package/releases/download/3.1.2/mapboxgljs-ellipsis-3.1.2.js"></script>

with npm npm install mapboxgljs-ellipsis

Add an Ellipsis Drive layer to a mapbox map

Example

import {
	EllipsisVectorLayer,
	EllipsisRasterLayer,
	AsyncEllipsisRasterLayer,
} from 'mapboxgljs-ellipsis';


const map = L.map("map", {
  center: [51.505, -0.09],
  zoom: 13,
});

// Raster layer
new EllipsisRasterLayer({
  pathId,
  timestampId,
  style:styleId,
  token: yourToken,
}).addTo(map);

// Vector layer
new EllipsisVectorLayer({
  pathId,
  token: yourToken,
}).addTo(map);

The timestampId and style are required for raster layers, you can use AsyncEllipsisRasterLayer in order to make use of defaults suggested by the server.


const createEllipsisRasterLayer = async () => {
  const someRaster = await MapboxgljsEllipsis.AsyncEllipsisRasterLayer({
    pathId: "28fb0f5f-e367-4265-b84b-1b8f1a8a6409",
  });
  someRaster.addTo(map);
};

createEllipsisRasterLayer();

RasterLayer options

| Name | Description | | ----------- | ------------------------------------------ | | pathId | id of the path | | timestampId | id of the timestamp | | style | id of the style or an object describing it | | maxZoom | maxZoomlevel of the layer. Default 21. | | token | token of the user |

VectorLayer options

| Name | Description | | ------------------ | ------------------------------------------------------------------------ | | pathId | Id of the path | | timestampId | Id of the timestamp | | style | id of the style or an object describing it | | onFeatureClick | A function to run on feature click, with as argument the clicked feature | | token | Token of the user | | filter | A property filter to use | | maxZoom | maxZoomlevel of the layer. Default 21. | | centerPoints | Boolean whether to render only center points. Default false. | | pageSize | Size to retreive per step. Default 25, max 3000. | | maxMbPerTile | The maximum mb to load per tile. Default 16mb. | | maxRenderTiles | The number of tiles to keep in view. Default 500. | | maxFeaturesPerTile | The maximum number of features to load per tile. Default 200. | | fetchInterval | The interval in ms between finishing and starting a request. Default 0 |

warning loadAll=true will ignore maxMbPerTile, maxTilesInCache and maxFeaturesPerTile settings.

onFeatureClick gets passed two parameters: the geojson of the clicked feature and the event.

note for the style object, refer to this documentation about it: https://app.ellipsis-drive.com/developer/javascript/documentation#POST%20geometryLayers%2FaddStyle.

○ 'rangeToColor': Parameters contains the required property 'rangeToColor' and optional property 'periodic', where 'rangeToColor' should be an array of objects with required properties 'property', 'fromValue', 'toValue' and 'color' and optional property 'alpha', where 'property' should be the name of the property to style by and should be of type string, 'fromValue' and 'toValue' should be the minimum and maximum value of the range respectively, 'color' is the color to use if the property falls inclusively between the fromValue and toValue and should be a rgb hex code color and 'alpha' should be the transparency of the color on a 0 to 1 scale with default 0.5. 'periodic' should be a positive float used when the remainder from dividing the value of the property by the periodic should be used to evaluate the ranges instead.

○ 'transitionPoints': Parameters contains the required properties 'property' and 'transitionPoints' and optional property 'periodic', where 'property' should be the name of the property to style by and should be of type string, 'transitionPoints' should be an array of objects with required properties 'value' and 'color' and optional property 'alpha', where 'value' should be the value at which the next transition starts, 'color' is the color to use if the property falls in the interval before or after the transition point and should be a rgb hex code color and 'alpha' should be the transparency of the color on a 0 to 1 scale with 0.5 as default. 'periodic' should be a positive float used when the remainder from dividing the value of the property by the periodic should be used to evaluate the ranges instead.

○ 'random': Parameters contains the required property 'property' and optional property 'alpha', where 'property' should be the name of the property by which to randomly assign colors and should be of type string and 'alpha' should be the transparency of the color on a 0 to 1 scale with default 0.5.

VectorLayer styling

A vectorlayer can add multiple style layers to your mapbox map. To view all added styling, call yourVectorLayer.getLayers(). You can also get and use the source that contains geojson with yourVectorLayer.getSource().

Use the EllipsisApi to login into Ellipsis Drive or view metadata of layers

EllipsisApi.login description

parameters | name | description | | -- | -- | | username | The username of your ellipsis-drive account | | password | The password of your ellipsis-drive account | | validFor | (Optional) The number of second the access token will be valid for. Default 86400 (24 hours). |

return value

token: string; //token to use in other api calls
expires: number; //expiration time in milliseconds

EllipsisApi.getInfo description

parameters | name | description | | -- | -- | | pathId | The id of the folder or layer. | | user | (Optional) An user object which can contain a token like user: {token: mytoken} |

return value It returns JSON, which depends on the type of the specified object.