From d7c46d4bab5de70376566524557a1b8ef86d1652 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 28 Mar 2017 14:27:18 -0400 Subject: [PATCH 1/3] Implement Leaflet.Locate type definition --- types/leaflet.locatecontrol/index.d.ts | 45 +++++++++++++++++++ .../leaflet.locatecontrol-tests.ts | 19 ++++++++ types/leaflet.locatecontrol/package.json | 5 +++ types/leaflet.locatecontrol/tsconfig.json | 20 +++++++++ 4 files changed, 89 insertions(+) create mode 100644 types/leaflet.locatecontrol/index.d.ts create mode 100644 types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts create mode 100644 types/leaflet.locatecontrol/package.json create mode 100644 types/leaflet.locatecontrol/tsconfig.json diff --git a/types/leaflet.locatecontrol/index.d.ts b/types/leaflet.locatecontrol/index.d.ts new file mode 100644 index 0000000000..cf7bf98319 --- /dev/null +++ b/types/leaflet.locatecontrol/index.d.ts @@ -0,0 +1,45 @@ +// Type definitions for Leaflet.locate v0.60 +// Project: https://github.com/domoritz/leaflet-locatecontrol +// Definitions by: Denis Carriere +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace L { + namespace Control { + export interface Locate extends L.Control {} + export interface LocateOptions { + position?: string + layer?: L.Layer + setView?: boolean | string + flyTo?: boolean + keepCurrentZoomLevel?: boolean + clickBehavior?: any + returnToPrevBounds?: boolean + cacheLocation?: boolean + drawCircle?: boolean + drawMarker?: boolean + markerClass?: any + circleStyle?: L.PathOptions + markerStyle?: L.PathOptions + followCircleStyle?: L.PathOptions + followMarkerStyle?: L.PathOptions + icon?: string + iconLoading?: string + iconElementTag?: string + circlePadding?: number[] + onLocationError?: any + onLocationOutsideMapBounds?: any + showPopup?: boolean + strings?: any + locateOptions?: L.LocateOptions + } + } + + namespace control { + /** + * Creates a Leaflet.Locate control + */ + export function locate(options?: Control.LocateOptions): L.Control.Locate; + } +} diff --git a/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts b/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts new file mode 100644 index 0000000000..284414c6aa --- /dev/null +++ b/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts @@ -0,0 +1,19 @@ +var map: L.Map; + +// Defaults +L.control.locate().addTo(map); + +// Simple +var lc = L.control.locate({ + position: 'topright', + strings: { + title: "Show me where I am, yo!" + } +}).addTo(map); + +// Locate Options +map.addControl(L.control.locate({ + locateOptions: { + maxZoom: 10, + enableHighAccuracy: true +}})); \ No newline at end of file diff --git a/types/leaflet.locatecontrol/package.json b/types/leaflet.locatecontrol/package.json new file mode 100644 index 0000000000..8afe476d51 --- /dev/null +++ b/types/leaflet.locatecontrol/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@types/leaflet": "^1.0.58" + } +} diff --git a/types/leaflet.locatecontrol/tsconfig.json b/types/leaflet.locatecontrol/tsconfig.json new file mode 100644 index 0000000000..5f2074cccc --- /dev/null +++ b/types/leaflet.locatecontrol/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "leaflet.locatecontrol-tests.ts" + ] +} \ No newline at end of file From 68f7d2312f795d3df6dde3ea1ba9eb11963bfc52 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 28 Mar 2017 14:33:56 -0400 Subject: [PATCH 2/3] Add tslinting to definition --- types/leaflet.locatecontrol/index.d.ts | 2 +- types/leaflet.locatecontrol/tsconfig.json | 2 +- types/leaflet.locatecontrol/tslint.json | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 types/leaflet.locatecontrol/tslint.json diff --git a/types/leaflet.locatecontrol/index.d.ts b/types/leaflet.locatecontrol/index.d.ts index cf7bf98319..3f4d94e9ce 100644 --- a/types/leaflet.locatecontrol/index.d.ts +++ b/types/leaflet.locatecontrol/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Leaflet.locate v0.60 +// Type definitions for Leaflet.locate 0.60 // Project: https://github.com/domoritz/leaflet-locatecontrol // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/leaflet.locatecontrol/tsconfig.json b/types/leaflet.locatecontrol/tsconfig.json index 5f2074cccc..0637d48285 100644 --- a/types/leaflet.locatecontrol/tsconfig.json +++ b/types/leaflet.locatecontrol/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "types": [], "noEmit": true, diff --git a/types/leaflet.locatecontrol/tslint.json b/types/leaflet.locatecontrol/tslint.json new file mode 100644 index 0000000000..fdc7cdc370 --- /dev/null +++ b/types/leaflet.locatecontrol/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From e6244de6e32a5fd8119fe304f519ca076fb34d81 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 28 Mar 2017 14:39:33 -0400 Subject: [PATCH 3/3] Update tests because of linting --- types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts b/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts index 284414c6aa..40fc41142f 100644 --- a/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts +++ b/types/leaflet.locatecontrol/leaflet.locatecontrol-tests.ts @@ -1,4 +1,7 @@ -var map: L.Map; +var map = L.map('map', { + center: [51.505, -0.09], + zoom: 13 +}); // Defaults L.control.locate().addTo(map);