mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-03 06:27:46 +08:00
Merge pull request #16527 from sebek64/leaflet-awesome-markers-v1-support
feat(leaflet.awesome-markers): support both v0 and v1 leaflet
This commit is contained in:
25
types/leaflet.awesome-markers/index.d.ts
vendored
25
types/leaflet.awesome-markers/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Leaflet.awesome-markers plugin v2.0
|
||||
// Project: https://github.com/sigma-geosistemas/Leaflet.awesome-markers#properties
|
||||
// Definitions by: Egor Komarov <https://github.com/Odrin>
|
||||
// Definitions by: Marcel Sebek <https://github.com/sebek64>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as Leaflet from "leaflet";
|
||||
@@ -11,27 +11,12 @@ declare global { namespace L {
|
||||
|
||||
function icon(options: AwesomeMarkers.IconOptions): AwesomeMarkers.Icon;
|
||||
|
||||
interface IconStatic extends Leaflet.IconStatic {
|
||||
/**
|
||||
* Creates an icon instance with the given options.
|
||||
*/
|
||||
new (options: IconOptions): Icon;
|
||||
|
||||
Default: {
|
||||
/**
|
||||
* Creates a default icon instance with the given options.
|
||||
*/
|
||||
new (options?: IconOptions): Icon.Default;
|
||||
|
||||
imagePath: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Icon extends Leaflet.Icon {
|
||||
class Icon extends Leaflet.BaseIcon {
|
||||
constructor(options?: AwesomeMarkers.IconOptions);
|
||||
options: AwesomeMarkers.IconOptions;
|
||||
}
|
||||
|
||||
interface IconOptions extends Leaflet.IconOptions {
|
||||
interface IconOptions extends Leaflet.BaseIconOptions {
|
||||
/**
|
||||
* Name of the icon. See glyphicons or font-awesome.
|
||||
*/
|
||||
@@ -62,7 +47,5 @@ declare global { namespace L {
|
||||
*/
|
||||
extraClasses?: string;
|
||||
}
|
||||
|
||||
var Icon: AwesomeMarkers.IconStatic;
|
||||
}
|
||||
} }
|
||||
|
||||
@@ -15,4 +15,4 @@ var blueMarker = new L.AwesomeMarkers.Icon({
|
||||
L.marker([51.941196, 4.512291], { icon: redMarker }).addTo(map);
|
||||
L.marker([51.941196, 4.512291], { icon: blueMarker }).addTo(map);
|
||||
|
||||
L.AwesomeMarkers.Icon.prototype.options.prefix = 'ion';
|
||||
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
|
||||
|
||||
@@ -13,11 +13,6 @@
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"leaflet": [
|
||||
"leaflet/v0"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
@@ -25,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"leaflet.awesome-markers-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
68
types/leaflet.awesome-markers/v0/index.d.ts
vendored
Normal file
68
types/leaflet.awesome-markers/v0/index.d.ts
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
// Type definitions for Leaflet.awesome-markers plugin v2.0 with Leaflet 0.x
|
||||
// Project: https://github.com/sigma-geosistemas/Leaflet.awesome-markers#properties
|
||||
// Definitions by: Egor Komarov <https://github.com/Odrin>, Marcel Sebek <https://github.com/sebek64>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as Leaflet from "leaflet";
|
||||
|
||||
declare global { namespace L {
|
||||
module AwesomeMarkers {
|
||||
var version: string;
|
||||
|
||||
function icon(options: AwesomeMarkers.IconOptions): AwesomeMarkers.Icon;
|
||||
|
||||
interface IconStatic extends Leaflet.IconStatic {
|
||||
/**
|
||||
* Creates an icon instance with the given options.
|
||||
*/
|
||||
new (options: IconOptions): Icon;
|
||||
|
||||
Default: {
|
||||
/**
|
||||
* Creates a default icon instance with the given options.
|
||||
*/
|
||||
new (options?: IconOptions): Icon.Default;
|
||||
|
||||
imagePath: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Icon extends Leaflet.Icon {
|
||||
options: AwesomeMarkers.IconOptions;
|
||||
}
|
||||
|
||||
interface IconOptions extends Leaflet.IconOptions {
|
||||
/**
|
||||
* Name of the icon. See glyphicons or font-awesome.
|
||||
*/
|
||||
icon?: string;
|
||||
|
||||
/**
|
||||
* Select de icon library. 'fa' for font-awesome or 'glyphicon' for bootstrap 3.
|
||||
*/
|
||||
prefix?: 'fa' | 'glyphicon';
|
||||
|
||||
/**
|
||||
* Color of the marker
|
||||
*/
|
||||
markerColor?: 'red' | 'darkred' | 'orange' | 'green' | 'darkgreen' | 'blue' | 'purple' | 'darkpurple' | 'cadetblue';
|
||||
|
||||
/**
|
||||
* Color of the icon. 'white', 'black' or css code (hex, rgba etc).
|
||||
*/
|
||||
iconColor?: 'white' | 'black' | string;
|
||||
|
||||
/**
|
||||
* Make the icon spin. true or false. Font-awesome required
|
||||
*/
|
||||
spin?: boolean;
|
||||
|
||||
/**
|
||||
* Additional classes in the created tag
|
||||
*/
|
||||
extraClasses?: string;
|
||||
}
|
||||
|
||||
var Icon: AwesomeMarkers.IconStatic;
|
||||
}
|
||||
} }
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
var map: L.Map;
|
||||
|
||||
var redMarker = L.AwesomeMarkers.icon({
|
||||
icon: 'coffee',
|
||||
markerColor: 'red'
|
||||
});
|
||||
|
||||
var blueMarker = new L.AwesomeMarkers.Icon({
|
||||
icon: 'star',
|
||||
markerColor: 'blue'
|
||||
});
|
||||
|
||||
L.marker([51.941196, 4.512291], { icon: redMarker }).addTo(map);
|
||||
L.marker([51.941196, 4.512291], { icon: blueMarker }).addTo(map);
|
||||
|
||||
L.AwesomeMarkers.Icon.prototype.options.prefix = 'ion';
|
||||
31
types/leaflet.awesome-markers/v0/tsconfig.json
Normal file
31
types/leaflet.awesome-markers/v0/tsconfig.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"leaflet": [
|
||||
"leaflet/v0"
|
||||
],
|
||||
"leaflet.awesome-markers": [
|
||||
"leaflet.awesome-markers/v0"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"leaflet.awesome-markers-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user