【发布时间】:2013-04-18 14:42:13
【问题描述】:
我正在使用 LeafletJS 绘制平面图。我最近在 DevIntersection 学习了一点关于 TypeScript 的知识,并想开始转换我所有的 JS 以使用它。幸运的是,有人已经为 Leaflet 创建了定义文件,但我使用的插件之一没有(MarkerCluster)。
我的插件可以编译(在传单定义文件中添加了一些小的内容之后),但是当我尝试使用它时,我看不到它的任何方法(参见下面的用法示例)。我也尝试从中创建一个定义文件,但它创建的是空的(使用 tsc --declaration)。由于 Leaflet 和插件的定义文件有点长,我上传了它们:
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) { }
}
}
错误:
“L”类型的值上不存在“MarkerClusterGroup”属性
关于从这里去哪里的任何想法或指导?
【问题讨论】:
-
轻微的烦恼,但如果您创建一个 gist 来托管您的文件(gist.github.com)会更好(对于我们这些想要帮助您的人来说更容易)。
-
@AlexDresko 对此一无所知 - 我会确保下次使用它。谢谢!
标签: typescript leaflet