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:
Nathan Shively-Sanders
2017-06-02 09:04:03 -07:00
committed by GitHub
6 changed files with 123 additions and 28 deletions

View File

@@ -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;
}
} }

View File

@@ -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';

View File

@@ -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"
]
}
}

View 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;
}
} }

View File

@@ -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';

View 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"
]
}