mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #62797 Add types for leaflet-boundary-canvas by @TurtIeSocks
* Add types for leaflet-boundary-canvas * linting * test fixes * Remove extra lint rule, add actual type tests * Update types/leaflet-boundary-canvas/index.d.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com> * Update types/leaflet-boundary-canvas/index.d.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com> Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
This commit is contained in:
24
types/leaflet-boundary-canvas/index.d.ts
vendored
Normal file
24
types/leaflet-boundary-canvas/index.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// Type definitions for leaflet-boundary-canvas 1.0
|
||||
// Project: https://github.com/ttungbmt/leaflet-boundary-canvas#readme
|
||||
// Definitions by: TurtIeSocks <https://github.com/TurtIeSocks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as L from 'leaflet';
|
||||
import type { FeatureCollection } from 'geojson';
|
||||
|
||||
declare module 'leaflet' {
|
||||
namespace TileLayer {
|
||||
interface BoundaryCanvasOptions extends TileLayerOptions {
|
||||
boundary?: FeatureCollection | undefined;
|
||||
crossOrigin?: boolean | undefined;
|
||||
trackAttribution?: boolean | undefined;
|
||||
}
|
||||
|
||||
class BoundaryCanvas extends TileLayer {
|
||||
constructor(url: string, options?: BoundaryCanvasOptions);
|
||||
static createFromLayer(tileLayer: TileLayer, options?: BoundaryCanvasOptions): BoundaryCanvas;
|
||||
}
|
||||
|
||||
function boundaryCanvas(url: string, options?: BoundaryCanvasOptions): BoundaryCanvas;
|
||||
}
|
||||
}
|
||||
104
types/leaflet-boundary-canvas/leaflet-boundary-canvas-tests.ts
Normal file
104
types/leaflet-boundary-canvas/leaflet-boundary-canvas-tests.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import * as L from 'leaflet';
|
||||
import 'leaflet-boundary-canvas';
|
||||
import type { FeatureCollection } from 'geojson';
|
||||
|
||||
const geojson: FeatureCollection = {
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[
|
||||
[-74.00822086214981, 40.753286818103476],
|
||||
[-74.01102405111267, 40.744599234477306],
|
||||
[-74.01051438039194, 40.732048498880914],
|
||||
[-74.01510141687663, 40.71138290010927],
|
||||
[-74.01714009975862, 40.704042171618426],
|
||||
[-74.01484658151605, 40.70037150393705],
|
||||
[-74.00592734390723, 40.703848983625505],
|
||||
[-73.99853711846013, 40.70809899002097],
|
||||
[-73.99012755157158, 40.709258035603625],
|
||||
[-73.97636644211791, 40.711189733411004],
|
||||
[-73.97126973491295, 40.72934495359286],
|
||||
[-73.97330841779493, 40.73282092021563],
|
||||
[-73.97254391171408, 40.73687598510827],
|
||||
[-73.96897621667078, 40.74595071091923],
|
||||
[-73.94145399776305, 40.775676244022605],
|
||||
[-73.94323784528488, 40.78281611219731],
|
||||
[-73.93865080880062, 40.78551748380988],
|
||||
[-73.93431860767606, 40.7905340252949],
|
||||
[-73.92922190047109, 40.79342801145626],
|
||||
[-73.92794772366994, 40.798829781464036],
|
||||
[-73.92947673583123, 40.80307372097877],
|
||||
[-73.93431860767606, 40.80924623950841],
|
||||
[-73.9338089369558, 40.81869679586163],
|
||||
[-73.9345734430362, 40.83624425743113],
|
||||
[-73.92871222975039, 40.84511263596684],
|
||||
[-73.92132200430326, 40.8564855584074],
|
||||
[-73.91291243741472, 40.86573666534841],
|
||||
[-73.90959957773158, 40.87209605182841],
|
||||
[-73.91316727277486, 40.875179170878766],
|
||||
[-73.92132200430326, 40.87710604737387],
|
||||
[-73.92463486398638, 40.877876782267606],
|
||||
[-73.93024124191209, 40.874601096993445],
|
||||
[-73.93635729055805, 40.862074923355436],
|
||||
[-73.94629586960788, 40.850510198471596],
|
||||
[-73.9457861988876, 40.84202811714471],
|
||||
[-73.95011840001175, 40.833737761493694],
|
||||
[-73.96693753378835, 40.81194653583228],
|
||||
[-73.98171798468348, 40.79207750027828],
|
||||
[-74.00822086214981, 40.753286818103476],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
const attribution = '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
|
||||
|
||||
const map = L.map('map', {
|
||||
center: [40.76965, -73.97747],
|
||||
zoom: 13,
|
||||
});
|
||||
|
||||
// $ExpectType BoundaryCanvas
|
||||
const layer = L.TileLayer.boundaryCanvas(url, {
|
||||
boundary: geojson,
|
||||
attribution,
|
||||
});
|
||||
|
||||
layer.addTo(map);
|
||||
|
||||
const map2 = L.map('map', {
|
||||
center: [40.76965, -73.97747],
|
||||
zoom: 13,
|
||||
});
|
||||
|
||||
// $ExpectType BoundaryCanvas
|
||||
const layer2 = new L.TileLayer.BoundaryCanvas(url, {
|
||||
boundary: geojson,
|
||||
attribution,
|
||||
});
|
||||
|
||||
layer2.addTo(map2);
|
||||
|
||||
const map3 = L.map('map', {
|
||||
center: [40.76965, -73.97747],
|
||||
zoom: 13,
|
||||
});
|
||||
|
||||
const baseLayer = L.tileLayer(url, {
|
||||
attribution,
|
||||
}).addTo(map);
|
||||
|
||||
// $ExpectType BoundaryCanvas
|
||||
const layer3 = L.TileLayer.BoundaryCanvas.createFromLayer(baseLayer, {
|
||||
boundary: geojson,
|
||||
});
|
||||
|
||||
layer3.addTo(map3);
|
||||
24
types/leaflet-boundary-canvas/tsconfig.json
Normal file
24
types/leaflet-boundary-canvas/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"leaflet-boundary-canvas-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/leaflet-boundary-canvas/tslint.json
Normal file
3
types/leaflet-boundary-canvas/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "@definitelytyped/dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user