3.1.5 • Published 1 year ago

mapboxgljs-ellipsis v3.1.5

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

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

NameDescription
pathIdid of the path
timestampIdid of the timestamp
styleid of the style or an object describing it
maxZoommaxZoomlevel of the layer. Default 21.
tokentoken of the user

VectorLayer options

NameDescription
pathIdId of the path
timestampIdId of the timestamp
styleid of the style or an object describing it
onFeatureClickA function to run on feature click, with as argument the clicked feature
tokenToken of the user
filterA property filter to use
maxZoommaxZoomlevel of the layer. Default 21.
centerPointsBoolean whether to render only center points. Default false.
pageSizeSize to retreive per step. Default 25, max 3000.
maxMbPerTileThe maximum mb to load per tile. Default 16mb.
maxRenderTilesThe number of tiles to keep in view. Default 500.
maxFeaturesPerTileThe maximum number of features to load per tile. Default 200.
fetchIntervalThe 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.

3.1.5

1 year ago

3.1.4

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago