Merge pull request #15455 from DenisCarriere/leaflet.locatecontrol

Implement Leaflet.Locate type definition
This commit is contained in:
Nathan Shively-Sanders
2017-03-28 15:18:01 -07:00
committed by GitHub
5 changed files with 95 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
// Type definitions for Leaflet.locate 0.60
// Project: https://github.com/domoritz/leaflet-locatecontrol
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="leaflet" />
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;
}
}
@@ -0,0 +1,22 @@
var map = L.map('map', {
center: [51.505, -0.09],
zoom: 13
});
// 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
}}));
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": {
"@types/leaflet": "^1.0.58"
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"leaflet.locatecontrol-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "../tslint.json"
}