首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在TypeScript中使用Esri Leaflet javascript插件

如何在TypeScript中使用Esri Leaflet javascript插件
EN

Stack Overflow用户
提问于 2017-05-23 08:31:52
回答 1查看 571关注 0票数 0

我在TypeScript中的Aurelia项目使用Leaflet进行映射。虽然Leaflet有类型,但esri-leaflet插件没有,它只是javascript。如何在我的TypeScript类中使用/导入javascript插件。提亚

EN

回答 1

Stack Overflow用户

发布于 2017-05-24 01:38:44

您应该扩展leaflet的类型定义。创建一个新的typescript文件并添加以下内容。

代码语言:javascript
复制
declare module L {
   export let esri:any;
   export class Esri {

   }
}

在leaflet之后导入此文件

如果您需要扩展其他插件:

代码语言:javascript
复制
declare module L {
   //plugins that extend Control comes here
   export namespace Control {
      export let Navbar: any;
   }
   // plugins that have control factories come here
  export namespace control {
     export let navbar: any;
  }
  //plugins that extend Layer comes here
   export namespace Layer {
      export let NewLayer: any;
   }
   // plugins that have layer factories come here
  export namespace layer {
     export let newLayer: any;
  }
  //plugins that extend Handler comes here
   export namespace Handler {
      export let NewHandler: any;
   }
   // plugins that have handler factories come here
  export namespace handler {
     export let newHandler: any;
  }
}

如果您愿意,您可以显式地使用这些类型。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44123983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档