From 180cac315deca314f4b3f26a53f6284e5d7deb77 Mon Sep 17 00:00:00 2001 From: Egor Komarov Date: Tue, 15 Mar 2016 18:21:39 +0300 Subject: [PATCH] add-leaflet-awesome-markers --- .../leaflet-awesome-markers.d.ts | 68 +++++++++++++++++++ .../leaflet-awesome-markers.ts | 34 ++++++++++ 2 files changed, 102 insertions(+) create mode 100644 leaflet-awesome-markers/leaflet-awesome-markers.d.ts create mode 100644 leaflet-awesome-markers/leaflet-awesome-markers.ts diff --git a/leaflet-awesome-markers/leaflet-awesome-markers.d.ts b/leaflet-awesome-markers/leaflet-awesome-markers.d.ts new file mode 100644 index 000000000..e81db8225 --- /dev/null +++ b/leaflet-awesome-markers/leaflet-awesome-markers.d.ts @@ -0,0 +1,68 @@ +// Type definitions for Leaflet.awesome-markers plugin v2.0 +// Project: https://github.com/lvoogdt/Leaflet.awesome-markers +// Definitions by: Egor Komarov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module L { + module AwesomeMarkers { + var version: string; + + function icon(options: AwesomeMarkers.IconOptions): AwesomeMarkers.Icon; + + export interface IconStatic extends L.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 L.Icon { + options: AwesomeMarkers.IconOptions; + } + + interface IconOptions extends L.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' | 'darkpuple' | '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; + } +} diff --git a/leaflet-awesome-markers/leaflet-awesome-markers.ts b/leaflet-awesome-markers/leaflet-awesome-markers.ts new file mode 100644 index 000000000..c58bf63d8 --- /dev/null +++ b/leaflet-awesome-markers/leaflet-awesome-markers.ts @@ -0,0 +1,34 @@ +/// + +var map: L.Map; +//var markerClusterGroup: L.MarkerClusterGroup; + +//// CircleMarker +//var circleMarker: L.CircleMarker = new L.CircleMarker(new L.LatLng(0, 0)); + +//markerClusterGroup.addLayer(circleMarker); +//map.addLayer(markerClusterGroup); +//map.removeLayer(markerClusterGroup); + +//// Marker +//var marker = new L.Marker(new L.LatLng(0, 0)); + +//markerClusterGroup.addLayers([circleMarker, marker]); +//map.addLayer(markerClusterGroup); +//markerClusterGroup.refreshClusters(); +//map.removeLayer(markerClusterGroup); + +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'; \ No newline at end of file