小编Dou*_*oug的帖子

MarkerCluster LeafletJS插件TypeScript定义文件创建

我正在使用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) { }

    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

属性'MarkerClusterGroup'在类型'L'的值上不存在

从这里开始的任何想法或指导?

leaflet typescript

6
推荐指数
2
解决办法
3096
查看次数

标签 统计

leaflet ×1

typescript ×1