3.1.3 • Published 6 months ago

leaflet-ellipsis v3.1.3

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

Installing the library

All releases of this package are listed in the release list on github here. To install this library, simply find the latest .js file in there, and put it in the directory of your project.

Import the ellipsis library in leaflet project

with script tags

<!-- Import leaflet -->
<link
  rel="stylesheet"
  href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<!-- Import ellipsis library -->
<script src="https://github.com/ellipsis-drive/ellipsis-js-util/releases/download/1.1.0/ellipsis-js-util-1.1.0.js"></script>
<script src="https://github.com/ellipsis-drive/leaflet-package/releases/download/3.1.0/leaflet-ellipsis-3.1.0.js"></script>

with npm npm install leaflet-ellipsis

Add an ellipsis-drive map to leaflet map

Example

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

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

// Vector layer
new leafletEllipsis.EllipsisVectorLayer({
  pathId: 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 AsyncEllipsisRasterLayer({
    pathId: pathId,
  });
  someRaster.addTo(map);
};

createEllipsisRasterLayer();

In this case only the pathId is required.

RasterLayer options

NameDescription
pathIdid of the path
timestampIdid of the timestamp
styleid of a 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 a 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 render in the view. Default 100.
maxFeaturesPerTileThe maximum number of features to load per tile. Default 200.
useMarkersIf set to true, points will be displayed as markers. Default false.
fetchIntervalThe interval in ms between finishing a request and starting a new one.

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.

EllipsisApi functions

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.getPath description

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

return value It returns JSON, which contains metadata of the the specified path in your drive.

3.1.3

6 months ago

3.1.2

6 months ago

3.1.1

1 year ago

3.1.0

2 years ago

3.0.0

2 years ago