leaflet - MarkerCluster LeafletJS plugin TypeScript definition file creation -


i using leafletjs map out floor plans. learned little typescript @ devintersection , wanted start converting of js use it. luckily created definition file leaflet, 1 of plugins use doesn't have 1 (markercluster).

i have plugin point compiles (after small additions leaflet definition file) when try use don't see of methods (see usage example below). tried creating definition file created empty (using tsc --declaration). since definition file leaflet , plugin bit long uploaded them:

leaflet.d.ts , leaflet.markercluster.ts

usage:

/// <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) { }      } } 

error:

the property 'markerclustergroup' not exist on value of type 'l'

any ideas or guidance on go here?

there lot of different conventions creating "classes" in javascript, , typescript doesn't know of them. have in leaflet.markercluster.ts legal javascript , therefore legal typescript, it's not broken classes typescript understands them , that's why declaration file generated empty.

except in rare cases declaration files created hand, , that's you're going have here. start off this:

/// <reference path="leaflet.d.ts" /> declare module l {     export class markerclustergroup extends featuregroup {         initialize(options: any): void;         addlayer(layer:ilayer):markerclustergroup;         addlayer(layer:layergroup):markerclustergroup;         // , on , forth     } } 

i've had create couple declaration files myself , after short learning curve it's not hard. found this blog post super helpful getting started (props steve if you're reading this) , learning example on definitelytyped.

once you're happy declaration file remember contribute definitelytyped warm fuzzy feelings.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -