我正在使用LeafletJS绘制出平面图。我最近在DevIntersection上学到了一点关于TypeScript的知识,并想开始转换我的所有JS以使用它。幸运的是,有人已经为Leaflet创建了定义文件,但是我使用的一个插件没有一个(MarkerCluster)。MarkerCluster LeafletJS插件TypeScript定义文件创建
我有插件到它编译的地步(在传单定义文件的一些小的添加之后),但是当我尝试使用它时,我没有看到它的任何方法(参见下面的使用示例)。我也尝试从它创建一个定义文件,但它创建的是空的(使用tsc --declaration)。自定义文件传单和插件都有点长我上传他们:
leaflet.d.ts,leaflet.markercluster.ts
用法:
/// <reference path="typings/jquery/jquery.d.ts" />
/// <reference path="typings/jqueryui/jqueryui.d.ts" />
/// <reference path="typings/leaflet/leaflet.d.ts" />
/// <reference path="typings/leaflet.markercluster.ts" />
module FloorPlans
{
export class Floor
{
deskMarkers : L.MarkerClusterGroup; // <-- Compile error
peopleMarkers: L.MarkerClusterGroup; // <-- Compile error
tileLayer: L.TileLayer;
desks = new Object();
people = new Object();
constructor(public floorName: string, public floorID: number) { }
}
}
错误:
The property 'MarkerClusterGroup' does not exist on value of type 'L'
任何意见或指导从哪里出发?
小麻烦,但它是(对于我们这些想帮助你更容易),如果你创建了一个要点,以托管文件更好(HTTP ://gist.github.com)。 –
@AlexDresko不知道这一点 - 我将确保下次使用它。谢谢! – Doug