leaflet.d.ts 130 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382
  1. // Type definitions for Leaflet.js 1.0.0
  2. // Project: https://github.com/Leaflet/Leaflet
  3. // Definitions by: Vladimir Zotov <https://github.com/rgripper>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. /// <reference path='../geojson/geojson.d.ts' />
  6. declare namespace L {
  7. type LatLngExpression = LatLng | number[] | ({ lat: number; lng: number })
  8. type LatLngBoundsExpression = LatLngBounds | LatLngExpression[];
  9. type PositionString = 'topleft' | 'topright' | 'bottomleft' | 'bottomright';
  10. }
  11. declare namespace L {
  12. export interface AttributionOptions {
  13. /**
  14. * The position of the control (one of the map corners). See control positions.
  15. * Default value: 'bottomright'.
  16. */
  17. position?: PositionString;
  18. /**
  19. * The HTML text shown before the attributions. Pass false to disable.
  20. * Default value: 'Powered by Leaflet'.
  21. */
  22. prefix?: string;
  23. }
  24. }
  25. declare namespace L {
  26. /**
  27. * Creates a Bounds object from two coordinates (usually top-left and bottom-right
  28. * corners).
  29. */
  30. export function bounds(topLeft: Point, bottomRight: Point): Bounds;
  31. /**
  32. * Creates a Bounds object defined by the points it contains.
  33. */
  34. export function bounds(points: Point[]): Bounds;
  35. export interface BoundsStatic {
  36. /**
  37. * Creates a Bounds object from two coordinates (usually top-left and bottom-right
  38. * corners).
  39. */
  40. new(topLeft: Point, bottomRight: Point): Bounds;
  41. /**
  42. * Creates a Bounds object defined by the points it contains.
  43. */
  44. new(points: Point[]): Bounds;
  45. }
  46. export var Bounds: BoundsStatic;
  47. export interface Bounds {
  48. /**
  49. * Extends the bounds to contain the given point.
  50. */
  51. extend(point: Point): void;
  52. /**
  53. * Returns the center point of the bounds.
  54. */
  55. getCenter(): Point;
  56. /**
  57. * Returns true if the rectangle contains the given one.
  58. */
  59. contains(otherBounds: Bounds): boolean;
  60. /**
  61. * Returns true if the rectangle contains the given point.
  62. */
  63. contains(point: Point): boolean;
  64. /**
  65. * Returns true if the rectangle intersects the given bounds.
  66. */
  67. intersects(otherBounds: Bounds): boolean;
  68. /**
  69. * Returns true if the bounds are properly initialized.
  70. */
  71. isValid(): boolean;
  72. /**
  73. * Returns the size of the given bounds.
  74. */
  75. getSize(): Point;
  76. /**
  77. * The top left corner of the rectangle.
  78. */
  79. min: Point;
  80. /**
  81. * The bottom right corner of the rectangle.
  82. */
  83. max: Point;
  84. }
  85. }
  86. declare namespace L {
  87. namespace Browser {
  88. /**
  89. * true for all Internet Explorer versions.
  90. */
  91. export var ie: boolean;
  92. /**
  93. * true for Internet Explorer 6.
  94. */
  95. export var ie6: boolean;
  96. /**
  97. * true for Internet Explorer 6.
  98. */
  99. export var ie7: boolean;
  100. /**
  101. * true for webkit-based browsers like Chrome and Safari (including mobile
  102. * versions).
  103. */
  104. export var webkit: boolean;
  105. /**
  106. * true for webkit-based browsers that support CSS 3D transformations.
  107. */
  108. export var webkit3d: boolean;
  109. /**
  110. * true for Android mobile browser.
  111. */
  112. export var android: boolean;
  113. /**
  114. * true for old Android stock browsers (2 and 3).
  115. */
  116. export var android23: boolean;
  117. /**
  118. * true for modern mobile browsers (including iOS Safari and different Android
  119. * browsers).
  120. */
  121. export var mobile: boolean;
  122. /**
  123. * true for mobile webkit-based browsers.
  124. */
  125. export var mobileWebkit: boolean;
  126. /**
  127. * true for mobile Opera.
  128. */
  129. export var mobileOpera: boolean;
  130. /**
  131. * true for all browsers on touch devices.
  132. */
  133. export var touch: boolean;
  134. /**
  135. * true for browsers with Microsoft touch model (e.g. IE10).
  136. */
  137. export var msTouch: boolean;
  138. /**
  139. * true for devices with Retina screens.
  140. */
  141. export var retina: boolean;
  142. }
  143. }
  144. declare namespace L {
  145. /**
  146. * Instantiates a circle object given a geographical point, a radius in meters
  147. * and optionally an options object.
  148. */
  149. function circle(latlng: LatLngExpression, radius: number, options?: PathOptions): Circle;
  150. export interface CircleStatic extends ClassStatic {
  151. /**
  152. * Instantiates a circle object given a geographical point, a radius in meters
  153. * and optionally an options object.
  154. */
  155. new(latlng: LatLngExpression, radius: number, options?: PathOptions): Circle;
  156. }
  157. export var Circle: CircleStatic;
  158. export interface Circle extends Path {
  159. /**
  160. * Returns the current geographical position of the circle.
  161. */
  162. getLatLng(): LatLng;
  163. /**
  164. * Returns the current radius of a circle. Units are in meters.
  165. */
  166. getRadius(): number;
  167. /**
  168. * Sets the position of a circle to a new location.
  169. */
  170. setLatLng(latlng: LatLngExpression): Circle;
  171. /**
  172. * Sets the radius of a circle. Units are in meters.
  173. */
  174. setRadius(radius: number): Circle;
  175. /**
  176. * Returns a GeoJSON representation of the circle (GeoJSON Point Feature).
  177. */
  178. toGeoJSON(): GeoJSON.Feature<GeoJSON.Point>;
  179. }
  180. }
  181. declare namespace L {
  182. /**
  183. * Instantiates a circle marker given a geographical point and optionally
  184. * an options object. The default radius is 10 and can be altered by passing a
  185. * "radius" member in the path options object.
  186. */
  187. function circleMarker(latlng: LatLngExpression, options?: PathOptions): CircleMarker;
  188. export interface CircleMarkerStatic extends ClassStatic {
  189. /**
  190. * Instantiates a circle marker given a geographical point and optionally
  191. * an options object. The default radius is 10 and can be altered by passing a
  192. * "radius" member in the path options object.
  193. */
  194. new(latlng: LatLngExpression, options?: PathOptions): CircleMarker;
  195. }
  196. export var CircleMarker: CircleMarkerStatic;
  197. export interface CircleMarker extends Circle {
  198. /**
  199. * Sets the position of a circle marker to a new location.
  200. */
  201. setLatLng(latlng: LatLngExpression): CircleMarker;
  202. /**
  203. * Sets the radius of a circle marker. Units are in pixels.
  204. */
  205. setRadius(radius: number): CircleMarker;
  206. }
  207. }
  208. declare namespace L {
  209. export interface ClassExtendOptions {
  210. /**
  211. * Your class's constructor function, meaning that it gets called when you do 'new MyClass(...)'.
  212. */
  213. initialize?: Function;
  214. /**
  215. * options is a special property that unlike other objects that you pass
  216. * to extend will be merged with the parent one instead of overriding it
  217. * completely, which makes managing configuration of objects and default
  218. * values convenient.
  219. */
  220. options?: any;
  221. /**
  222. * includes is a special class property that merges all specified objects
  223. * into the class (such objects are called mixins). A good example of this
  224. * is L.Mixin.Events that event-related methods like on, off and fire
  225. * to the class.
  226. */
  227. includes?: any;
  228. /**
  229. * statics is just a convenience property that injects specified object
  230. * properties as the static properties of the class, useful for defining
  231. * constants.
  232. */
  233. static?: any;
  234. [prop: string]: any;
  235. }
  236. export interface ClassStatic {
  237. /**
  238. * You use L.Class.extend to define new classes, but you can use the
  239. * same method on any class to inherit from it.
  240. */
  241. extend(options: ClassExtendOptions): any;
  242. extend<Options, NewClass>(options: ClassExtendOptions): { new(options?: Options): NewClass };
  243. /**
  244. * You can also use the following shortcut when you just need to make
  245. * one additional method call.
  246. */
  247. addInitHook(methodName: string, ...args: any[]): void;
  248. }
  249. /**
  250. * L.Class powers the OOP facilities of Leaflet and is used to create
  251. * almost all of the Leaflet classes documented.
  252. */
  253. namespace Class {
  254. /**
  255. * You use L.Class.extend to define new classes, but you can use the
  256. * same method on any class to inherit from it.
  257. */
  258. function extend(options: ClassExtendOptions): any;
  259. }
  260. }
  261. declare namespace L {
  262. export interface ControlStatic extends ClassStatic {
  263. /**
  264. * Creates a control with the given options.
  265. */
  266. new(options?: ControlOptions): Control;
  267. Zoom: Control.ZoomStatic;
  268. Attribution: Control.AttributionStatic;
  269. Layers: Control.LayersStatic;
  270. Scale: Control.ScaleStatic;
  271. }
  272. export var Control: ControlStatic;
  273. export interface Control extends IControl {
  274. /**
  275. * Sets the position of the control. See control positions.
  276. */
  277. setPosition(position: PositionString): Control;
  278. /**
  279. * Returns the current position of the control.
  280. */
  281. getPosition(): PositionString;
  282. /**
  283. * Adds the control to the map.
  284. */
  285. addTo(map: Map): Control;
  286. /**
  287. * Removes the control from the map.
  288. */
  289. removeFrom(map: Map): Control;
  290. /**
  291. * Returns the HTML container of the control.
  292. */
  293. getContainer(): HTMLElement;
  294. // IControl members
  295. /**
  296. * Should contain code that creates all the neccessary DOM elements for the
  297. * control, adds listeners on relevant map events, and returns the element
  298. * containing the control. Called on map.addControl(control) or control.addTo(map).
  299. */
  300. onAdd(map: Map): HTMLElement;
  301. /**
  302. * Optional, should contain all clean up code (e.g. removes control's event
  303. * listeners). Called on map.removeControl(control) or control.removeFrom(map).
  304. * The control's DOM container is removed automatically.
  305. */
  306. onRemove(map: Map): void;
  307. }
  308. namespace Control {
  309. export interface ZoomStatic extends ClassStatic {
  310. /**
  311. * Creates a zoom control.
  312. */
  313. new (options?: ZoomOptions): Zoom;
  314. }
  315. export interface Zoom extends L.Control {
  316. }
  317. export interface ZoomOptions {
  318. /**
  319. * The position of the control (one of the map corners).
  320. * Can be 'topleft', 'topright', 'bottomleft', or 'bottomright'.
  321. *
  322. * Default value: 'topright'.
  323. */
  324. position?: PositionString;
  325. /**
  326. * The text set on the zoom in button.
  327. *
  328. * Default value: '+'
  329. */
  330. zoomInText?: string;
  331. /**
  332. * The text set on the zoom out button.
  333. *
  334. * Default value: '-'
  335. */
  336. zoomOutText?: string;
  337. /**
  338. * The title set on the zoom in button.
  339. *
  340. * Default value: 'Zoom in'
  341. */
  342. zoomInTitle?: string;
  343. /**
  344. * The title set on the zoom out button.
  345. *
  346. * Default value: 'Zoom out'
  347. */
  348. zoomOutTitle?: string;
  349. }
  350. export interface AttributionStatic extends ClassStatic {
  351. /**
  352. * Creates an attribution control.
  353. */
  354. new(options?: AttributionOptions): Attribution;
  355. }
  356. export interface Attribution extends L.Control {
  357. /**
  358. * Sets the text before the attributions.
  359. */
  360. setPrefix(prefix: string): Attribution;
  361. /**
  362. * Adds an attribution text (e.g. 'Vector data &copy; CloudMade').
  363. */
  364. addAttribution(text: string): Attribution;
  365. /**
  366. * Removes an attribution text.
  367. */
  368. removeAttribution(text: string): Attribution;
  369. }
  370. export interface LayersStatic extends ClassStatic {
  371. /**
  372. * Creates an attribution control with the given layers. Base layers will be
  373. * switched with radio buttons, while overlays will be switched with checkboxes.
  374. */
  375. new(baseLayers?: any, overlays?: any, options?: LayersOptions): Layers;
  376. }
  377. export interface Layers extends L.Control, IEventPowered<Layers> {
  378. /**
  379. * Adds a base layer (radio button entry) with the given name to the control.
  380. */
  381. addBaseLayer(layer: ILayer, name: string): Layers;
  382. /**
  383. * Adds an overlay (checkbox entry) with the given name to the control.
  384. */
  385. addOverlay(layer: ILayer, name: string): Layers;
  386. /**
  387. * Remove the given layer from the control.
  388. */
  389. removeLayer(layer: ILayer): Layers;
  390. ////////////////
  391. ////////////////
  392. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
  393. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
  394. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Layers;
  395. hasEventListeners(type: string): boolean;
  396. fireEvent(type: string, data?: any): Layers;
  397. on(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
  398. once(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
  399. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Layers;
  400. fire(type: string, data?: any): Layers;
  401. addEventListener(eventMap: any, context?: any): Layers;
  402. removeEventListener(eventMap?: any, context?: any): Layers;
  403. clearAllEventListeners(): Layers;
  404. on(eventMap: any, context?: any): Layers;
  405. off(eventMap?: any, context?: any): Layers;
  406. }
  407. export interface ScaleStatic extends ClassStatic {
  408. /**
  409. * Creates an scale control with the given options.
  410. */
  411. new(options?: ScaleOptions): Scale;
  412. }
  413. export interface Scale extends L.Control {
  414. }
  415. }
  416. export interface control {
  417. /**
  418. * Creates a control with the given options.
  419. */
  420. (options?: ControlOptions): Control;
  421. }
  422. export namespace control {
  423. /**
  424. * Creates a zoom control.
  425. */
  426. export function zoom(options?: Control.ZoomOptions): L.Control.Zoom;
  427. /**
  428. * Creates an attribution control.
  429. */
  430. export function attribution(options?: AttributionOptions): L.Control.Attribution;
  431. /**
  432. * Creates an attribution control with the given layers. Base layers will be
  433. * switched with radio buttons, while overlays will be switched with checkboxes.
  434. */
  435. export function layers(baseLayers?: any, overlays?: any, options?: LayersOptions): L.Control.Layers;
  436. /**
  437. * Creates an scale control with the given options.
  438. */
  439. export function scale(options?: ScaleOptions): L.Control.Scale;
  440. }
  441. }
  442. declare namespace L {
  443. export interface ControlOptions {
  444. /**
  445. * The initial position of the control (one of the map corners). See control
  446. * positions.
  447. * Default value: 'topright'.
  448. */
  449. position?: PositionString;
  450. }
  451. }
  452. declare namespace L {
  453. namespace CRS {
  454. /**
  455. * The most common CRS for online maps, used by almost all free and commercial
  456. * tile providers. Uses Spherical Mercator projection. Set in by default in
  457. * Map's crs option.
  458. */
  459. export var EPSG3857: ICRS;
  460. /**
  461. * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
  462. */
  463. export var EPSG4326: ICRS;
  464. /**
  465. * Rarely used by some commercial tile providers. Uses Elliptical Mercator
  466. * projection.
  467. */
  468. export var EPSG3395: ICRS;
  469. /**
  470. * A simple CRS that maps longitude and latitude into x and y directly. May be
  471. * used for maps of flat surfaces (e.g. game maps). Note that the y axis should
  472. * still be inverted (going from bottom to top).
  473. */
  474. export var Simple: ICRS;
  475. }
  476. }
  477. declare namespace L {
  478. /**
  479. * Creates a div icon instance with the given options.
  480. */
  481. function divIcon(options: DivIconOptions): DivIcon;
  482. export interface DivIconStatic extends ClassStatic {
  483. /**
  484. * Creates a div icon instance with the given options.
  485. */
  486. new(options: DivIconOptions): DivIcon;
  487. }
  488. export var DivIcon: DivIconStatic;
  489. export interface DivIcon extends Icon {
  490. }
  491. }
  492. declare namespace L {
  493. export interface DivIconOptions {
  494. /**
  495. * Size of the icon in pixels. Can be also set through CSS.
  496. */
  497. iconSize?: Point|[number, number];
  498. /**
  499. * The coordinates of the "tip" of the icon (relative to its top left corner).
  500. * The icon will be aligned so that this point is at the marker's geographical
  501. * location. Centered by default if size is specified, also can be set in CSS
  502. * with negative margins.
  503. */
  504. iconAnchor?: Point|[number, number];
  505. /**
  506. * A custom class name to assign to the icon.
  507. *
  508. * Default value: 'leaflet-div-icon'.
  509. */
  510. className?: string;
  511. /**
  512. * A custom HTML code to put inside the div element.
  513. *
  514. * Default value: ''.
  515. */
  516. html?: string;
  517. /**
  518. * The coordinates of the point from which popups will "open", relative to the
  519. * icon anchor.
  520. */
  521. popupAnchor?: Point|[number, number];
  522. }
  523. }
  524. declare namespace L {
  525. export interface DomEvent {
  526. /**
  527. * Adds a listener fn to the element's DOM event of the specified type. this keyword
  528. * inside the listener will point to context, or to the element if not specified.
  529. */
  530. addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent;
  531. on(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent;
  532. /**
  533. * Removes an event listener from the element.
  534. */
  535. removeListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent;
  536. off(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent;
  537. /**
  538. * Stop the given event from propagation to parent elements. Used inside the
  539. * listener functions:
  540. * L.DomEvent.addListener(div, 'click', function
  541. * (e) {
  542. * L.DomEvent.stopPropagation(e);
  543. * });
  544. */
  545. stopPropagation(e: Event): DomEvent;
  546. /**
  547. * Prevents the default action of the event from happening (such as following
  548. * a link in the href of the a element, or doing a POST request with page reload
  549. * when form is submitted). Use it inside listener functions.
  550. */
  551. preventDefault(e: Event): DomEvent;
  552. /**
  553. * Does stopPropagation and preventDefault at the same time.
  554. */
  555. stop(e: Event): DomEvent;
  556. /**
  557. * Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown'
  558. * and 'touchstart' events.
  559. */
  560. disableClickPropagation(el: HTMLElement): DomEvent;
  561. /**
  562. * Gets normalized mouse position from a DOM event relative to the container
  563. * or to the whole page if not specified.
  564. */
  565. getMousePosition(e: Event, container?: HTMLElement): Point;
  566. /**
  567. * Gets normalized wheel delta from a mousewheel DOM event.
  568. */
  569. getWheelDelta(e: Event): number;
  570. }
  571. export var DomEvent: DomEvent;
  572. }
  573. declare namespace L {
  574. namespace DomUtil {
  575. /**
  576. * Returns an element with the given id if a string was passed, or just returns
  577. * the element if it was passed directly.
  578. */
  579. export function get(id: string): HTMLElement;
  580. /**
  581. * Returns the value for a certain style attribute on an element, including
  582. * computed values or values set through CSS.
  583. */
  584. export function getStyle(el: HTMLElement, style: string): string;
  585. /**
  586. * Returns the offset to the viewport for the requested element.
  587. */
  588. export function getViewportOffset(el: HTMLElement): Point;
  589. /**
  590. * Creates an element with tagName, sets the className, and optionally appends
  591. * it to container element.
  592. */
  593. export function create(tagName: string, className: string, container?: HTMLElement): HTMLElement;
  594. /**
  595. * Makes sure text cannot be selected, for example during dragging.
  596. */
  597. export function disableTextSelection(): void;
  598. /**
  599. * Makes text selection possible again.
  600. */
  601. export function enableTextSelection(): void;
  602. /**
  603. * Returns true if the element class attribute contains name.
  604. */
  605. export function hasClass(el: HTMLElement, name: string): boolean;
  606. /**
  607. * Adds name to the element's class attribute.
  608. */
  609. export function addClass(el: HTMLElement, name: string): void;
  610. /**
  611. * Removes name from the element's class attribute.
  612. */
  613. export function removeClass(el: HTMLElement, name: string): void;
  614. /**
  615. * Set the opacity of an element (including old IE support). Value must be from
  616. * 0 to 1.
  617. */
  618. export function setOpacity(el: HTMLElement, value: number): void;
  619. /**
  620. * Goes through the array of style names and returns the first name that is a valid
  621. * style name for an element. If no such name is found, it returns false. Useful
  622. * for vendor-prefixed styles like transform.
  623. */
  624. export function testProp(props: string[]): any;
  625. /**
  626. * Returns a CSS transform string to move an element by the offset provided in
  627. * the given point. Uses 3D translate on WebKit for hardware-accelerated transforms
  628. * and 2D on other browsers.
  629. */
  630. export function getTranslateString(point: Point): string;
  631. /**
  632. * Returns a CSS transform string to scale an element (with the given scale origin).
  633. */
  634. export function getScaleString(scale: number, origin: Point): string;
  635. /**
  636. * Sets the position of an element to coordinates specified by point, using
  637. * CSS translate or top/left positioning depending on the browser (used by
  638. * Leaflet internally to position its layers). Forces top/left positioning
  639. * if disable3D is true.
  640. */
  641. export function setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void;
  642. /**
  643. * Returns the coordinates of an element previously positioned with setPosition.
  644. */
  645. export function getPosition(el: HTMLElement): Point;
  646. /**
  647. * Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit).
  648. */
  649. export var TRANSITION: string;
  650. /**
  651. * Vendor-prefixed transform style name.
  652. */
  653. export var TRANSFORM: string;
  654. }
  655. }
  656. declare namespace L {
  657. export interface DraggableStatic extends ClassStatic {
  658. /**
  659. * Creates a Draggable object for moving the given element when you start dragging
  660. * the dragHandle element (equals the element itself by default).
  661. */
  662. new(element: HTMLElement, dragHandle?: HTMLElement): Draggable;
  663. }
  664. export var Draggable: DraggableStatic;
  665. export interface Draggable extends IEventPowered<Draggable> {
  666. /**
  667. * Enables the dragging ability.
  668. */
  669. enable(): void;
  670. /**
  671. * Disables the dragging ability.
  672. */
  673. disable(): void;
  674. ////////////////
  675. ////////////////
  676. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
  677. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
  678. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Draggable;
  679. hasEventListeners(type: string): boolean;
  680. fireEvent(type: string, data?: any): Draggable;
  681. on(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
  682. once(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
  683. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Draggable;
  684. fire(type: string, data?: any): Draggable;
  685. addEventListener(eventMap: any, context?: any): Draggable;
  686. removeEventListener(eventMap?: any, context?: any): Draggable;
  687. clearAllEventListeners(): Draggable;
  688. on(eventMap: any, context?: any): Draggable;
  689. off(eventMap?: any, context?: any): Draggable;
  690. }
  691. }
  692. declare namespace L {
  693. /**
  694. * Create a layer group, optionally given an initial set of layers.
  695. */
  696. function featureGroup<T extends ILayer>(layers?: T[]): FeatureGroup<T>;
  697. export interface FeatureGroupStatic extends ClassStatic {
  698. /**
  699. * Create a layer group, optionally given an initial set of layers.
  700. */
  701. new<T extends ILayer>(layers?: T[]): FeatureGroup<T>;
  702. }
  703. export var FeatureGroup: FeatureGroupStatic;
  704. export interface FeatureGroup<T extends ILayer> extends LayerGroup<T>, ILayer, IEventPowered<FeatureGroup<T>> {
  705. /**
  706. * Binds a popup with a particular HTML content to a click on any layer from the
  707. * group that has a bindPopup method.
  708. */
  709. bindPopup(htmlContent: string, options?: PopupOptions): FeatureGroup<T>;
  710. /**
  711. * Returns the LatLngBounds of the Feature Group (created from bounds and coordinates
  712. * of its children).
  713. */
  714. getBounds(): LatLngBounds;
  715. /**
  716. * Sets the given path options to each layer of the group that has a setStyle method.
  717. */
  718. setStyle(style: PathOptions): FeatureGroup<T>;
  719. /**
  720. * Brings the layer group to the top of all other layers.
  721. */
  722. bringToFront(): FeatureGroup<T>;
  723. /**
  724. * Brings the layer group to the bottom of all other layers.
  725. */
  726. bringToBack(): FeatureGroup<T>;
  727. ////////////
  728. ////////////
  729. /**
  730. * Should contain code that creates DOM elements for the overlay, adds them
  731. * to map panes where they should belong and puts listeners on relevant map events.
  732. * Called on map.addLayer(layer).
  733. */
  734. onAdd(map: Map): void;
  735. /**
  736. * Should contain all clean up code that removes the overlay's elements from
  737. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  738. */
  739. onRemove(map: Map): void;
  740. ////////////////
  741. ////////////////
  742. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>;
  743. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>;
  744. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>;
  745. hasEventListeners(type: string): boolean;
  746. fireEvent(type: string, data?: any): FeatureGroup<T>;
  747. on(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>;
  748. once(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>;
  749. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>;
  750. fire(type: string, data?: any): FeatureGroup<T>;
  751. addEventListener(eventMap: any, context?: any): FeatureGroup<T>;
  752. removeEventListener(eventMap?: any, context?: any): FeatureGroup<T>;
  753. clearAllEventListeners(): FeatureGroup<T>;
  754. on(eventMap: any, context?: any): FeatureGroup<T>;
  755. off(eventMap?: any, context?: any): FeatureGroup<T>;
  756. }
  757. }
  758. declare namespace L {
  759. /**
  760. * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format
  761. * to display on the map (you can alternatively add it later with addData method)
  762. * and an options object.
  763. */
  764. function geoJson(geojson?: any, options?: GeoJSONOptions): GeoJSON;
  765. export interface GeoJSONStatic extends ClassStatic {
  766. /**
  767. * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format
  768. * to display on the map (you can alternatively add it later with addData method)
  769. * and an options object.
  770. */
  771. new(geojson?: any, options?: GeoJSONOptions): GeoJSON;
  772. /**
  773. * Creates a layer from a given GeoJSON feature.
  774. */
  775. geometryToLayer(featureData: GeoJSON, pointToLayer?: (featureData: any, latlng: LatLng) => ILayer): ILayer;
  776. /**
  777. * Creates a LatLng object from an array of 2 numbers (latitude, longitude)
  778. * used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted
  779. * as (longitude, latitude).
  780. */
  781. coordsToLatLng(coords: number[], reverse?: boolean): LatLng;
  782. /**
  783. * Creates a multidimensional array of LatLng objects from a GeoJSON coordinates
  784. * array. levelsDeep specifies the nesting level (0 is for an array of points,
  785. * 1 for an array of arrays of points, etc., 0 by default). If reverse is set to
  786. * true, the numbers will be interpreted as (longitude, latitude).
  787. */
  788. coordsToLatLngs(coords: any[], levelsDeep?: number, reverse?: boolean): any[];
  789. }
  790. export var GeoJSON: GeoJSONStatic;
  791. export interface GeoJSON extends FeatureGroup<ILayer> {
  792. /**
  793. * Adds a GeoJSON object to the layer.
  794. */
  795. addData(data: any): boolean;
  796. /**
  797. * Changes styles of GeoJSON vector layers with the given style function.
  798. */
  799. setStyle(style: (featureData: any) => any): GeoJSON;
  800. /**
  801. * Changes styles of GeoJSON vector layers with the given style options.
  802. */
  803. setStyle(style: PathOptions): GeoJSON;
  804. /**
  805. * Resets the the given vector layer's style to the original GeoJSON style,
  806. * useful for resetting style after hover events.
  807. */
  808. resetStyle(layer: Path): GeoJSON;
  809. }
  810. }
  811. declare namespace L {
  812. export interface GeoJSONOptions {
  813. /**
  814. * Function that will be used for creating layers for GeoJSON points (if not
  815. * specified, simple markers will be created).
  816. */
  817. pointToLayer?: (featureData: any, latlng: LatLng) => ILayer;
  818. /**
  819. * Function that will be used to get style options for vector layers created
  820. * for GeoJSON features.
  821. */
  822. style?: (featureData: any) => any;
  823. /**
  824. * Function that will be called on each created feature layer. Useful for attaching
  825. * events and popups to features.
  826. */
  827. onEachFeature?: (featureData: any, layer: ILayer) => void;
  828. /**
  829. * Function that will be used to decide whether to show a feature or not.
  830. */
  831. filter?: (featureData: any, layer: ILayer) => boolean;
  832. /**
  833. * Function that will be used for converting GeoJSON coordinates to LatLng points
  834. * (if not specified, coords will be assumed to be WGS84 � standard[longitude, latitude]
  835. * values in degrees).
  836. */
  837. coordsToLatLng?: (coords: any[]) => LatLng[];
  838. }
  839. }
  840. declare namespace L {
  841. /**
  842. * Creates an icon instance with the given options.
  843. */
  844. function icon(options: IconOptions): Icon;
  845. export interface IconStatic extends ClassStatic {
  846. /**
  847. * Creates an icon instance with the given options.
  848. */
  849. new(options: IconOptions): Icon;
  850. Default: {
  851. /**
  852. * Creates a default icon instance with the given options.
  853. */
  854. new(options?: IconOptions): Icon.Default;
  855. imagePath: string;
  856. };
  857. }
  858. export var Icon: IconStatic;
  859. export interface Icon {
  860. }
  861. namespace Icon {
  862. /**
  863. * L.Icon.Default extends L.Icon and is the blue icon Leaflet uses
  864. * for markers by default.
  865. */
  866. export interface Default extends Icon {
  867. }
  868. }
  869. }
  870. declare namespace L {
  871. export interface IconOptions {
  872. /**
  873. * (required) The URL to the icon image (absolute or relative to your script
  874. * path).
  875. */
  876. iconUrl?: string;
  877. /**
  878. * The URL to a retina sized version of the icon image (absolute or relative to
  879. * your script path). Used for Retina screen devices.
  880. */
  881. iconRetinaUrl?: string;
  882. /**
  883. * Size of the icon image in pixels.
  884. */
  885. iconSize?: Point|[number, number];
  886. /**
  887. * The coordinates of the "tip" of the icon (relative to its top left corner).
  888. * The icon will be aligned so that this point is at the marker's geographical
  889. * location. Centered by default if size is specified, also can be set in CSS
  890. * with negative margins.
  891. */
  892. iconAnchor?: Point|[number, number];
  893. /**
  894. * The URL to the icon shadow image. If not specified, no shadow image will be
  895. * created.
  896. */
  897. shadowUrl?: string;
  898. /**
  899. * The URL to the retina sized version of the icon shadow image. If not specified,
  900. * no shadow image will be created. Used for Retina screen devices.
  901. */
  902. shadowRetinaUrl?: string;
  903. /**
  904. * Size of the shadow image in pixels.
  905. */
  906. shadowSize?: Point|[number, number];
  907. /**
  908. * The coordinates of the "tip" of the shadow (relative to its top left corner)
  909. * (the same as iconAnchor if not specified).
  910. */
  911. shadowAnchor?: Point|[number, number];
  912. /**
  913. * The coordinates of the point from which popups will "open", relative to the
  914. * icon anchor.
  915. */
  916. popupAnchor?: Point|[number, number];
  917. /**
  918. * A custom class name to assign to both icon and shadow images. Empty by default.
  919. */
  920. className?: string;
  921. }
  922. }
  923. declare namespace L {
  924. export interface IControl {
  925. /**
  926. * Should contain code that creates all the neccessary DOM elements for the
  927. * control, adds listeners on relevant map events, and returns the element
  928. * containing the control. Called on map.addControl(control) or control.addTo(map).
  929. */
  930. onAdd(map: Map): HTMLElement;
  931. /**
  932. * Optional, should contain all clean up code (e.g. removes control's event
  933. * listeners). Called on map.removeControl(control) or control.removeFrom(map).
  934. * The control's DOM container is removed automatically.
  935. */
  936. onRemove(map: Map): void;
  937. }
  938. }
  939. declare namespace L {
  940. export interface ICRS {
  941. /**
  942. * Projection that this CRS uses.
  943. */
  944. projection: IProjection;
  945. /**
  946. * Transformation that this CRS uses to turn projected coordinates into screen
  947. * coordinates for a particular tile service.
  948. */
  949. transformation: Transformation;
  950. /**
  951. * Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').
  952. */
  953. code: string;
  954. /**
  955. * Projects geographical coordinates on a given zoom into pixel coordinates.
  956. */
  957. latLngToPoint(latlng: LatLng, zoom: number): Point;
  958. /**
  959. * The inverse of latLngToPoint. Projects pixel coordinates on a given zoom
  960. * into geographical coordinates.
  961. */
  962. pointToLatLng(point: Point, zoom: number): LatLng;
  963. /**
  964. * Projects geographical coordinates into coordinates in units accepted
  965. * for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
  966. */
  967. project(latlng: LatLng): Point;
  968. /**
  969. * Returns the scale used when transforming projected coordinates into pixel
  970. * coordinates for a particular zoom. For example, it returns 256 * 2^zoom for
  971. * Mercator-based CRS.
  972. */
  973. scale(zoom: number): number;
  974. /**
  975. * Returns the size of the world in pixels for a particular zoom.
  976. */
  977. getSize(zoom: number): Point;
  978. }
  979. }
  980. declare namespace L {
  981. export interface IEventPowered<T> {
  982. /**
  983. * Adds a listener function (fn) to a particular event type of the object. You
  984. * can optionally specify the context of the listener (object the this keyword
  985. * will point to). You can also pass several space-separated types (e.g. 'click
  986. * dblclick').
  987. */
  988. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
  989. /**
  990. * The same as above except the listener will only get fired once and then removed.
  991. */
  992. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
  993. /**
  994. * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
  995. */
  996. addEventListener(eventMap: any, context?: any): T;
  997. /**
  998. * Removes a previously added listener function. If no function is specified,
  999. * it will remove all the listeners of that particular event from the object.
  1000. */
  1001. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): T;
  1002. /**
  1003. * Removes a set of type/listener pairs.
  1004. */
  1005. removeEventListener(eventMap?: any, context?: any): T;
  1006. /**
  1007. * Returns true if a particular event type has some listeners attached to it.
  1008. */
  1009. hasEventListeners(type: string): boolean;
  1010. /**
  1011. * Fires an event of the specified type. You can optionally provide an data object
  1012. * — the first argument of the listener function will contain its properties.
  1013. */
  1014. fireEvent(type: string, data?: any): T;
  1015. /**
  1016. * Removes all listeners to all events on the object.
  1017. */
  1018. clearAllEventListeners(): T;
  1019. /**
  1020. * Alias to addEventListener.
  1021. */
  1022. on(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
  1023. /**
  1024. * Alias to addEventListener.
  1025. */
  1026. on(eventMap: any, context?: any): T;
  1027. /**
  1028. * Alias to addOneTimeEventListener.
  1029. */
  1030. once(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
  1031. /**
  1032. * Alias to removeEventListener.
  1033. */
  1034. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): T;
  1035. /**
  1036. * Alias to removeEventListener.
  1037. */
  1038. off(eventMap?: any, context?: any): T;
  1039. /**
  1040. * Alias to fireEvent.
  1041. */
  1042. fire(type: string, data?: any): T;
  1043. }
  1044. }
  1045. declare namespace L {
  1046. export interface IHandler {
  1047. /**
  1048. * Enables the handler.
  1049. */
  1050. enable(): void;
  1051. /**
  1052. * Disables the handler.
  1053. */
  1054. disable(): void;
  1055. /**
  1056. * Returns true if the handler is enabled.
  1057. */
  1058. enabled(): boolean;
  1059. }
  1060. export interface Handler {
  1061. initialize(map: Map): void;
  1062. }
  1063. }
  1064. declare namespace L {
  1065. export interface ILayer {
  1066. /**
  1067. * Should contain code that creates DOM elements for the overlay, adds them
  1068. * to map panes where they should belong and puts listeners on relevant map events.
  1069. * Called on map.addLayer(layer).
  1070. */
  1071. onAdd(map: Map): void;
  1072. /**
  1073. * Should contain all clean up code that removes the overlay's elements from
  1074. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  1075. */
  1076. onRemove(map: Map): void;
  1077. }
  1078. }
  1079. declare namespace L {
  1080. namespace Mixin {
  1081. export interface LeafletMixinEvents extends IEventPowered<LeafletMixinEvents> {
  1082. }
  1083. export var Events: LeafletMixinEvents;
  1084. }
  1085. }
  1086. declare namespace L {
  1087. /**
  1088. * Instantiates an image overlay object given the URL of the image and the geographical
  1089. * bounds it is tied to.
  1090. */
  1091. function imageOverlay(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay;
  1092. export interface ImageOverlayStatic extends ClassStatic {
  1093. /**
  1094. * Instantiates an image overlay object given the URL of the image and the geographical
  1095. * bounds it is tied to.
  1096. */
  1097. new(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay;
  1098. }
  1099. export var ImageOverlay: ImageOverlayStatic;
  1100. export interface ImageOverlay extends ILayer {
  1101. /**
  1102. * Adds the overlay to the map.
  1103. */
  1104. addTo(map: Map): ImageOverlay;
  1105. /**
  1106. * Sets the opacity of the overlay.
  1107. */
  1108. setOpacity(opacity: number): ImageOverlay;
  1109. /**
  1110. * Changes the URL of the image.
  1111. */
  1112. setUrl(imageUrl: string): ImageOverlay;
  1113. /**
  1114. * Brings the layer to the top of all overlays.
  1115. */
  1116. bringToFront(): ImageOverlay;
  1117. /**
  1118. * Brings the layer to the bottom of all overlays.
  1119. */
  1120. bringToBack(): ImageOverlay;
  1121. ////////////
  1122. ////////////
  1123. /**
  1124. * Should contain code that creates DOM elements for the overlay, adds them
  1125. * to map panes where they should belong and puts listeners on relevant map events.
  1126. * Called on map.addLayer(layer).
  1127. */
  1128. onAdd(map: Map): void;
  1129. /**
  1130. * Should contain all clean up code that removes the overlay's elements from
  1131. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  1132. */
  1133. onRemove(map: Map): void;
  1134. }
  1135. }
  1136. declare namespace L {
  1137. export interface ImageOverlayOptions {
  1138. /**
  1139. * The opacity of the image overlay.
  1140. */
  1141. opacity?: number;
  1142. }
  1143. }
  1144. declare namespace L {
  1145. export interface IProjection {
  1146. /**
  1147. * Projects geographical coordinates into a 2D point.
  1148. */
  1149. project(latlng: LatLng): Point;
  1150. /**
  1151. * The inverse of project. Projects a 2D point into geographical location.
  1152. */
  1153. unproject(point: Point): LatLng;
  1154. }
  1155. }
  1156. declare namespace L {
  1157. /**
  1158. * A constant that represents the Leaflet version in use.
  1159. */
  1160. export var version: string;
  1161. /**
  1162. * This method restores the L global variale to the original value it had
  1163. * before Leaflet inclusion, and returns the real Leaflet namespace.
  1164. */
  1165. export function noConflict(): typeof L;
  1166. }
  1167. declare namespace L {
  1168. /**
  1169. * Creates an object representing a geographical point with the given latitude
  1170. * and longitude.
  1171. */
  1172. function latLng(latitude: number, longitude: number): LatLng;
  1173. /**
  1174. * Creates an object representing a geographical point with the given latitude
  1175. * and longitude.
  1176. */
  1177. function latLng(coords: LatLngExpression): LatLng;
  1178. export interface LatLngStatic {
  1179. /**
  1180. * Creates an object representing a geographical point with the given latitude
  1181. * and longitude.
  1182. */
  1183. new(latitude: number, longitude: number): LatLng;
  1184. /**
  1185. * Creates an object representing a geographical point with the given latitude
  1186. * and longitude.
  1187. */
  1188. new(coords: LatLngExpression): LatLng;
  1189. /**
  1190. * A multiplier for converting degrees into radians.
  1191. *
  1192. * Value: Math.PI / 180.
  1193. */
  1194. DEG_TO_RAD: number;
  1195. /**
  1196. * A multiplier for converting radians into degrees.
  1197. *
  1198. * Value: 180 / Math.PI.
  1199. */
  1200. RAD_TO_DEG: number;
  1201. /**
  1202. * Max margin of error for the equality check.
  1203. *
  1204. * Value: 1.0E-9.
  1205. */
  1206. MAX_MARGIN: number;
  1207. }
  1208. export var LatLng: LatLngStatic;
  1209. export interface LatLng {
  1210. /**
  1211. * Returns the distance (in meters) to the given LatLng calculated using the
  1212. * Haversine formula. See description on wikipedia
  1213. */
  1214. distanceTo(otherLatlng: LatLngExpression): number;
  1215. /**
  1216. * Returns true if the given LatLng point is at the same position (within a small
  1217. * margin of error).
  1218. */
  1219. equals(otherLatlng: LatLngExpression): boolean;
  1220. /**
  1221. * Returns a string representation of the point (for debugging purposes).
  1222. */
  1223. toString(): string;
  1224. /**
  1225. * Returns a new LatLng object with the longitude wrapped around left and right
  1226. * boundaries (-180 to 180 by default).
  1227. */
  1228. wrap(left?: number, right?: number): LatLng;
  1229. /**
  1230. * Latitude in degrees.
  1231. */
  1232. lat: number;
  1233. /**
  1234. * Longitude in degrees.
  1235. */
  1236. lng: number;
  1237. }
  1238. }
  1239. declare namespace L {
  1240. /**
  1241. * Creates a LatLngBounds object by defining south-west and north-east corners
  1242. * of the rectangle.
  1243. */
  1244. function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds;
  1245. /**
  1246. * Creates a LatLngBounds object defined by the geographical points it contains.
  1247. * Very useful for zooming the map to fit a particular set of locations with fitBounds.
  1248. */
  1249. function latLngBounds(latlngs: LatLngBoundsExpression): LatLngBounds;
  1250. export interface LatLngBoundsStatic {
  1251. /**
  1252. * Creates a LatLngBounds object by defining south-west and north-east corners
  1253. * of the rectangle.
  1254. */
  1255. new(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds;
  1256. /**
  1257. * Creates a LatLngBounds object defined by the geographical points it contains.
  1258. * Very useful for zooming the map to fit a particular set of locations with fitBounds.
  1259. */
  1260. new(latlngs: LatLngBoundsExpression): LatLngBounds;
  1261. }
  1262. export var LatLngBounds: LatLngBoundsStatic;
  1263. export interface LatLngBounds {
  1264. /**
  1265. * Extends the bounds to contain the given point.
  1266. */
  1267. extend(latlng: LatLngExpression): LatLngBounds;
  1268. /**
  1269. * Extends the bounds to contain the given bounds.
  1270. */
  1271. extend(latlng: LatLngBoundsExpression): LatLngBounds;
  1272. /**
  1273. * Returns the south-west point of the bounds.
  1274. */
  1275. getSouthWest(): LatLng;
  1276. /**
  1277. * Returns the north-east point of the bounds.
  1278. */
  1279. getNorthEast(): LatLng;
  1280. /**
  1281. * Returns the north-west point of the bounds.
  1282. */
  1283. getNorthWest(): LatLng;
  1284. /**
  1285. * Returns the south-east point of the bounds.
  1286. */
  1287. getSouthEast(): LatLng;
  1288. /**
  1289. * Returns the west longitude in degrees of the bounds.
  1290. */
  1291. getWest(): number;
  1292. /**
  1293. * Returns the east longitude in degrees of the bounds.
  1294. */
  1295. getEast(): number;
  1296. /**
  1297. * Returns the north latitude in degrees of the bounds.
  1298. */
  1299. getNorth(): number;
  1300. /**
  1301. * Returns the south latitude in degrees of the bounds.
  1302. */
  1303. getSouth(): number;
  1304. /**
  1305. * Returns the center point of the bounds.
  1306. */
  1307. getCenter(): LatLng;
  1308. /**
  1309. * Returns true if the rectangle contains the given one.
  1310. */
  1311. contains(otherBounds: LatLngBoundsExpression): boolean;
  1312. /**
  1313. * Returns true if the rectangle contains the given point.
  1314. */
  1315. contains(latlng: LatLngExpression): boolean;
  1316. /**
  1317. * Returns true if the rectangle intersects the given bounds.
  1318. */
  1319. intersects(otherBounds: LatLngBoundsExpression): boolean;
  1320. /**
  1321. * Returns true if the rectangle is equivalent (within a small margin of error)
  1322. * to the given bounds.
  1323. */
  1324. equals(otherBounds: LatLngBoundsExpression): boolean;
  1325. /**
  1326. * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat'
  1327. * format. Useful for sending requests to web services that return geo data.
  1328. */
  1329. toBBoxString(): string;
  1330. /**
  1331. * Returns bigger bounds created by extending the current bounds by a given
  1332. * percentage in each direction.
  1333. */
  1334. pad(bufferRatio: number): LatLngBounds;
  1335. /**
  1336. * Returns true if the bounds are properly initialized.
  1337. */
  1338. isValid(): boolean;
  1339. }
  1340. }
  1341. declare namespace L {
  1342. /**
  1343. * Create a layer group, optionally given an initial set of layers.
  1344. */
  1345. function layerGroup<T extends ILayer>(layers?: T[]): LayerGroup<T>;
  1346. export interface LayerGroupStatic extends ClassStatic {
  1347. /**
  1348. * Create a layer group, optionally given an initial set of layers.
  1349. */
  1350. new<T extends ILayer>(layers?: T[]): LayerGroup<T>;
  1351. }
  1352. export var LayerGroup: LayerGroupStatic;
  1353. export interface LayerGroup<T extends ILayer> extends ILayer {
  1354. /**
  1355. * Adds the group of layers to the map.
  1356. */
  1357. addTo(map: Map): LayerGroup<T>;
  1358. /**
  1359. * Adds a given layer to the group.
  1360. */
  1361. addLayer(layer: T): LayerGroup<T>;
  1362. /**
  1363. * Removes a given layer from the group.
  1364. */
  1365. removeLayer(layer: T): LayerGroup<T>;
  1366. /**
  1367. * Removes a given layer of the given id from the group.
  1368. */
  1369. removeLayer(id: string): LayerGroup<T>;
  1370. /**
  1371. * Returns true if the given layer is currently added to the group.
  1372. */
  1373. hasLayer(layer: T): boolean;
  1374. /**
  1375. * Returns the layer with the given id.
  1376. */
  1377. getLayer(id: string): T;
  1378. /**
  1379. * Returns an array of all the layers added to the group.
  1380. */
  1381. getLayers(): T[];
  1382. /**
  1383. * Removes all the layers from the group.
  1384. */
  1385. clearLayers(): LayerGroup<T>;
  1386. /**
  1387. * Iterates over the layers of the group, optionally specifying context of
  1388. * the iterator function.
  1389. */
  1390. eachLayer(fn: (layer: T) => void, context?: any): LayerGroup<T>;
  1391. /**
  1392. * Returns a GeoJSON representation of the layer group (GeoJSON FeatureCollection).
  1393. * Note: Descendent classes MultiPolygon & MultiPolyLine return `Feature`s, not `FeatureCollection`s
  1394. */
  1395. toGeoJSON(): GeoJSON.FeatureCollection<GeoJSON.GeometryObject>|GeoJSON.Feature<GeoJSON.MultiLineString|GeoJSON.MultiPolygon>;
  1396. ////////////
  1397. ////////////
  1398. /**
  1399. * Should contain code that creates DOM elements for the overlay, adds them
  1400. * to map panes where they should belong and puts listeners on relevant map events.
  1401. * Called on map.addLayer(layer).
  1402. */
  1403. onAdd(map: Map): void;
  1404. /**
  1405. * Should contain all clean up code that removes the overlay's elements from
  1406. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  1407. */
  1408. onRemove(map: Map): void;
  1409. }
  1410. }
  1411. declare namespace L {
  1412. export interface LayersOptions {
  1413. /**
  1414. * The position of the control (one of the map corners). See control positions.
  1415. *
  1416. * Default value: 'topright'.
  1417. */
  1418. position?: PositionString;
  1419. /**
  1420. * If true, the control will be collapsed into an icon and expanded on mouse hover
  1421. * or touch.
  1422. *
  1423. * Default value: true.
  1424. */
  1425. collapsed?: boolean;
  1426. /**
  1427. * If true, the control will assign zIndexes in increasing order to all of its
  1428. * layers so that the order is preserved when switching them on/off.
  1429. *
  1430. * Default value: true.
  1431. */
  1432. autoZIndex?: boolean;
  1433. }
  1434. }
  1435. declare namespace L {
  1436. export interface LeafletErrorEvent extends LeafletEvent {
  1437. /**
  1438. * Error message.
  1439. */
  1440. message: string;
  1441. /**
  1442. * Error code (if applicable).
  1443. */
  1444. code: number;
  1445. }
  1446. }
  1447. declare namespace L {
  1448. export interface LeafletEvent {
  1449. /**
  1450. * The event type (e.g. 'click').
  1451. */
  1452. type: string;
  1453. /**
  1454. * The object that fired the event.
  1455. */
  1456. target: any;
  1457. }
  1458. }
  1459. declare namespace L {
  1460. export interface LeafletGeoJSONEvent extends LeafletEvent {
  1461. /**
  1462. * The layer for the GeoJSON feature that is being added to the map.
  1463. */
  1464. layer: ILayer;
  1465. /**
  1466. * GeoJSON properties of the feature.
  1467. */
  1468. properties: any;
  1469. /**
  1470. * GeoJSON geometry type of the feature.
  1471. */
  1472. geometryType: string;
  1473. /**
  1474. * GeoJSON ID of the feature (if present).
  1475. */
  1476. id: string;
  1477. }
  1478. }
  1479. declare namespace L {
  1480. export interface LeafletLayerEvent extends LeafletEvent {
  1481. /**
  1482. * The layer that was added or removed.
  1483. */
  1484. layer: ILayer;
  1485. }
  1486. }
  1487. declare namespace L {
  1488. export interface LeafletLayersControlEvent extends LeafletEvent {
  1489. /**
  1490. * The layer that was added or removed.
  1491. */
  1492. layer: ILayer;
  1493. /**
  1494. * The name of the layer that was added or removed.
  1495. */
  1496. name: string;
  1497. }
  1498. }
  1499. declare namespace L {
  1500. export interface LeafletLocationEvent extends LeafletEvent {
  1501. /**
  1502. * Detected geographical location of the user.
  1503. */
  1504. latlng: LatLng;
  1505. /**
  1506. * Geographical bounds of the area user is located in (with respect to the accuracy
  1507. * of location).
  1508. */
  1509. bounds: LatLngBounds;
  1510. /**
  1511. * Accuracy of location in meters.
  1512. */
  1513. accuracy: number;
  1514. /**
  1515. * Height of the position above the WGS84 ellipsoid in meters.
  1516. */
  1517. altitude: number;
  1518. /**
  1519. * Accuracy of altitude in meters.
  1520. */
  1521. altitudeAccuracy: number;
  1522. /**
  1523. * The direction of travel in degrees counting clockwise from true North.
  1524. */
  1525. heading: number;
  1526. /**
  1527. * Current velocity in meters per second.
  1528. */
  1529. speed: number;
  1530. /**
  1531. * The time when the position was acquired.
  1532. */
  1533. timestamp: number;
  1534. }
  1535. }
  1536. declare namespace L {
  1537. export interface LeafletMouseEvent extends LeafletEvent {
  1538. /**
  1539. * The geographical point where the mouse event occured.
  1540. */
  1541. latlng: LatLng;
  1542. /**
  1543. * Pixel coordinates of the point where the mouse event occured relative to
  1544. * the map layer.
  1545. */
  1546. layerPoint: Point;
  1547. /**
  1548. * Pixel coordinates of the point where the mouse event occured relative to
  1549. * the map сontainer.
  1550. */
  1551. containerPoint: Point;
  1552. /**
  1553. * The original DOM mouse event fired by the browser.
  1554. */
  1555. originalEvent: MouseEvent;
  1556. }
  1557. }
  1558. declare namespace L {
  1559. export interface LeafletPopupEvent extends LeafletEvent {
  1560. /**
  1561. * The popup that was opened or closed.
  1562. */
  1563. popup: Popup;
  1564. }
  1565. }
  1566. declare namespace L {
  1567. export interface LeafletDragEndEvent extends LeafletEvent {
  1568. /**
  1569. * The distance in pixels the draggable element was moved by.
  1570. */
  1571. distance: number;
  1572. }
  1573. }
  1574. declare namespace L {
  1575. export interface LeafletResizeEvent extends LeafletEvent {
  1576. /**
  1577. * The old size before resize event.
  1578. */
  1579. oldSize: Point;
  1580. /**
  1581. * The new size after the resize event.
  1582. */
  1583. newSize: Point;
  1584. }
  1585. }
  1586. declare namespace L {
  1587. export interface LeafletTileEvent extends LeafletEvent {
  1588. /**
  1589. * The tile element (image).
  1590. */
  1591. tile: HTMLElement;
  1592. /**
  1593. * The source URL of the tile.
  1594. */
  1595. url: string;
  1596. }
  1597. }
  1598. declare namespace L {
  1599. namespace LineUtil {
  1600. /**
  1601. * Dramatically reduces the number of points in a polyline while retaining
  1602. * its shape and returns a new array of simplified points. Used for a huge performance
  1603. * boost when processing/displaying Leaflet polylines for each zoom level
  1604. * and also reducing visual noise. tolerance affects the amount of simplification
  1605. * (lesser value means higher quality but slower and with more points). Also
  1606. * released as a separated micro-library Simplify.js.
  1607. */
  1608. export function simplify(points: Point[], tolerance: number): Point[];
  1609. /**
  1610. * Returns the distance between point p and segment p1 to p2.
  1611. */
  1612. export function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number;
  1613. /**
  1614. * Returns the closest point from a point p on a segment p1 to p2.
  1615. */
  1616. export function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point;
  1617. /**
  1618. * Clips the segment a to b by rectangular bounds. Used by Leaflet to only show
  1619. * polyline points that are on the screen or near, increasing performance. Returns
  1620. * either false or a length-2 array of clipped points.
  1621. */
  1622. export function clipSegment(a: Point, b: Point, bounds: Bounds): Point[] | boolean;
  1623. }
  1624. }
  1625. declare namespace L {
  1626. export interface LocateOptions {
  1627. /**
  1628. * If true, starts continous watching of location changes (instead of detecting
  1629. * it once) using W3C watchPosition method. You can later stop watching using
  1630. * map.stopLocate() method.
  1631. *
  1632. * Default value: false.
  1633. */
  1634. watch?: boolean;
  1635. /**
  1636. * If true, automatically sets the map view to the user location with respect
  1637. * to detection accuracy, or to world view if geolocation failed.
  1638. *
  1639. * Default value: false.
  1640. */
  1641. setView?: boolean;
  1642. /**
  1643. * The maximum zoom for automatic view setting when using `setView` option.
  1644. *
  1645. * Default value: Infinity.
  1646. */
  1647. maxZoom?: number;
  1648. /**
  1649. * Number of millisecond to wait for a response from geolocation before firing
  1650. * a locationerror event.
  1651. *
  1652. * Default value: 10000.
  1653. */
  1654. timeout?: number;
  1655. /**
  1656. * Maximum age of detected location. If less than this amount of milliseconds
  1657. * passed since last geolocation response, locate will return a cached location.
  1658. *
  1659. * Default value: 0.
  1660. */
  1661. maximumAge?: number;
  1662. /**
  1663. * Enables high accuracy, see description in the W3C spec.
  1664. *
  1665. * Default value: false.
  1666. */
  1667. enableHighAccuracy?: boolean;
  1668. }
  1669. }
  1670. declare namespace L {
  1671. /**
  1672. * Instantiates a map object given a div element and optionally an
  1673. * object literal with map options described below.
  1674. */
  1675. function map(id: HTMLElement, options?: Map.MapOptions): Map;
  1676. /**
  1677. * Instantiates a map object given a div element id and optionally an
  1678. * object literal with map options described below.
  1679. */
  1680. function map(id: string, options?: Map.MapOptions): Map;
  1681. export interface MapStatic extends ClassStatic {
  1682. /**
  1683. * Instantiates a map object given a div element and optionally an
  1684. * object literal with map options described below.
  1685. *
  1686. * @constructor
  1687. */
  1688. new(id: HTMLElement, options?: Map.MapOptions): Map;
  1689. /**
  1690. * Instantiates a map object given a div element id and optionally an
  1691. * object literal with map options described below.
  1692. *
  1693. * @constructor
  1694. */
  1695. new(id: string, options?: Map.MapOptions): Map;
  1696. }
  1697. export var Map: MapStatic;
  1698. export interface Map extends IEventPowered<Map> {
  1699. // Methods for Modifying Map State
  1700. /**
  1701. * Sets the view of the map (geographical center and zoom) with the given
  1702. * animation options.
  1703. */
  1704. setView(center: LatLngExpression, zoom?: number, options?: Map.ZoomPanOptions): Map;
  1705. /**
  1706. * Sets the zoom of the map.
  1707. */
  1708. setZoom(zoom: number, options?: Map.ZoomPanOptions): Map;
  1709. /**
  1710. * Increases the zoom of the map by delta (1 by default).
  1711. */
  1712. zoomIn(delta?: number, options?: Map.ZoomPanOptions): Map;
  1713. /**
  1714. * Decreases the zoom of the map by delta (1 by default).
  1715. */
  1716. zoomOut(delta?: number, options?: Map.ZoomPanOptions): Map;
  1717. /**
  1718. * Zooms the map while keeping a specified point on the map stationary
  1719. * (e.g. used internally for scroll zoom and double-click zoom).
  1720. */
  1721. setZoomAround(latlng: LatLngExpression, zoom: number, options?: Map.ZoomPanOptions): Map;
  1722. /**
  1723. * Sets a map view that contains the given geographical bounds with the maximum
  1724. * zoom level possible.
  1725. */
  1726. fitBounds(bounds: LatLngBounds, options?: Map.FitBoundsOptions): Map;
  1727. /**
  1728. * Sets a map view that mostly contains the whole world with the maximum zoom
  1729. * level possible.
  1730. */
  1731. fitWorld(options?: Map.FitBoundsOptions): Map;
  1732. /**
  1733. * Pans the map to a given center. Makes an animated pan if new center is not more
  1734. * than one screen away from the current one.
  1735. */
  1736. panTo(latlng: LatLngExpression, options?: PanOptions): Map;
  1737. /**
  1738. * Pans the map to the closest view that would lie inside the given bounds (if
  1739. * it's not already).
  1740. */
  1741. panInsideBounds(bounds: LatLngBounds): Map;
  1742. /**
  1743. * Pans the map by a given number of pixels (animated).
  1744. */
  1745. panBy(point: Point, options?: PanOptions): Map;
  1746. /**
  1747. * Checks if the map container size changed and updates the map if so — call it
  1748. * after you've changed the map size dynamically, also animating pan by default.
  1749. * If options.pan is false, panning will not occur.
  1750. */
  1751. invalidateSize(options: Map.ZoomPanOptions): Map;
  1752. /**
  1753. * Checks if the map container size changed and updates the map if so — call it
  1754. * after you've changed the map size dynamically, also animating pan by default.
  1755. */
  1756. invalidateSize(animate: boolean): Map;
  1757. /**
  1758. * Restricts the map view to the given bounds (see map maxBounds option),
  1759. * passing the given animation options through to `setView`, if required.
  1760. */
  1761. setMaxBounds(bounds: LatLngBounds, options?: Map.ZoomPanOptions): Map;
  1762. /**
  1763. * Tries to locate the user using Geolocation API, firing locationfound event
  1764. * with location data on success or locationerror event on failure, and optionally
  1765. * sets the map view to the user location with respect to detection accuracy
  1766. * (or to the world view if geolocation failed). See Locate options for more
  1767. * details.
  1768. */
  1769. locate(options?: LocateOptions): Map;
  1770. /**
  1771. * Stops watching location previously initiated by map.locate({watch: true})
  1772. * and aborts resetting the map view if map.locate was called with {setView: true}.
  1773. */
  1774. stopLocate(): Map;
  1775. /**
  1776. * Destroys the map and clears all related event listeners.
  1777. */
  1778. remove(): Map;
  1779. // Methods for Getting Map State
  1780. /**
  1781. * Returns the geographical center of the map view.
  1782. */
  1783. getCenter(): LatLng;
  1784. /**
  1785. * Returns the current zoom of the map view.
  1786. */
  1787. getZoom(): number;
  1788. /**
  1789. * Returns the minimum zoom level of the map.
  1790. */
  1791. getMinZoom(): number;
  1792. /**
  1793. * Returns the maximum zoom level of the map.
  1794. */
  1795. getMaxZoom(): number;
  1796. /**
  1797. * Returns the LatLngBounds of the current map view.
  1798. */
  1799. getBounds(): LatLngBounds;
  1800. /**
  1801. * Returns the maximum zoom level on which the given bounds fit to the map view
  1802. * in its entirety. If inside (optional) is set to true, the method instead returns
  1803. * the minimum zoom level on which the map view fits into the given bounds in its
  1804. * entirety.
  1805. */
  1806. getBoundsZoom(bounds: LatLngBounds, inside?: boolean): number;
  1807. /**
  1808. * Returns the current size of the map container.
  1809. */
  1810. getSize(): Point;
  1811. /**
  1812. * Returns the bounds of the current map view in projected pixel coordinates
  1813. * (sometimes useful in layer and overlay implementations).
  1814. */
  1815. getPixelBounds(): Bounds;
  1816. /**
  1817. * Returns the projected pixel coordinates of the top left point of the map layer
  1818. * (useful in custom layer and overlay implementations).
  1819. */
  1820. getPixelOrigin(): Point;
  1821. // Methods for Layers and Controls
  1822. /**
  1823. * Adds the given layer to the map. If optional insertAtTheBottom is set to true,
  1824. * the layer is inserted under all others (useful when switching base tile layers).
  1825. */
  1826. addLayer(layer: ILayer, insertAtTheBottom?: boolean): Map;
  1827. /**
  1828. * Removes the given layer from the map.
  1829. */
  1830. removeLayer(layer: ILayer): Map;
  1831. /**
  1832. * Returns true if the given layer is currently added to the map.
  1833. */
  1834. hasLayer(layer: ILayer): boolean;
  1835. /**
  1836. * Opens the specified popup while closing the previously opened (to make sure
  1837. * only one is opened at one time for usability).
  1838. */
  1839. openPopup(popup: Popup): Map;
  1840. /**
  1841. * Creates a popup with the specified options and opens it in the given point
  1842. * on a map.
  1843. */
  1844. openPopup(html: string, latlng: LatLngExpression, options?: PopupOptions): Map;
  1845. /**
  1846. * Creates a popup with the specified options and opens it in the given point
  1847. * on a map.
  1848. */
  1849. openPopup(el: HTMLElement, latlng: LatLngExpression, options?: PopupOptions): Map;
  1850. /**
  1851. * Closes the popup previously opened with openPopup (or the given one).
  1852. */
  1853. closePopup(popup?: Popup): Map;
  1854. /**
  1855. * Adds the given control to the map.
  1856. */
  1857. addControl(control: IControl): Map;
  1858. /**
  1859. * Removes the given control from the map.
  1860. */
  1861. removeControl(control: IControl): Map;
  1862. // Conversion Methods
  1863. /**
  1864. * Returns the map layer point that corresponds to the given geographical coordinates
  1865. * (useful for placing overlays on the map).
  1866. */
  1867. latLngToLayerPoint(latlng: LatLngExpression): Point;
  1868. /**
  1869. * Returns the geographical coordinates of a given map layer point.
  1870. */
  1871. layerPointToLatLng(point: Point): LatLng;
  1872. /**
  1873. * Converts the point relative to the map container to a point relative to the
  1874. * map layer.
  1875. */
  1876. containerPointToLayerPoint(point: Point): Point;
  1877. /**
  1878. * Converts the point relative to the map layer to a point relative to the map
  1879. * container.
  1880. */
  1881. layerPointToContainerPoint(point: Point): Point;
  1882. /**
  1883. * Returns the map container point that corresponds to the given geographical
  1884. * coordinates.
  1885. */
  1886. latLngToContainerPoint(latlng: LatLngExpression): Point;
  1887. /**
  1888. * Returns the geographical coordinates of a given map container point.
  1889. */
  1890. containerPointToLatLng(point: Point): LatLng;
  1891. /**
  1892. * Projects the given geographical coordinates to absolute pixel coordinates
  1893. * for the given zoom level (current zoom level by default).
  1894. */
  1895. project(latlng: LatLngExpression, zoom?: number): Point;
  1896. /**
  1897. * Projects the given absolute pixel coordinates to geographical coordinates
  1898. * for the given zoom level (current zoom level by default).
  1899. */
  1900. unproject(point: Point, zoom?: number): LatLng;
  1901. /**
  1902. * Returns the pixel coordinates of a mouse click (relative to the top left corner
  1903. * of the map) given its event object.
  1904. */
  1905. mouseEventToContainerPoint(event: LeafletMouseEvent): Point;
  1906. /**
  1907. * Returns the pixel coordinates of a mouse click relative to the map layer given
  1908. * its event object.
  1909. */
  1910. mouseEventToLayerPoint(event: LeafletMouseEvent): Point;
  1911. /**
  1912. * Returns the geographical coordinates of the point the mouse clicked on given
  1913. * the click's event object.
  1914. */
  1915. mouseEventToLatLng(event: LeafletMouseEvent): LatLng;
  1916. // Other Methods
  1917. /**
  1918. * Returns the container element of the map.
  1919. */
  1920. getContainer(): HTMLElement;
  1921. /**
  1922. * Returns an object with different map panes (to render overlays in).
  1923. */
  1924. getPanes(): MapPanes;
  1925. // REVIEW: Should we make it more flexible declaring parameter 'fn' as Function?
  1926. /**
  1927. * Runs the given callback when the map gets initialized with a place and zoom,
  1928. * or immediately if it happened already, optionally passing a function context.
  1929. */
  1930. whenReady(fn: (map: Map) => void, context?: any): Map;
  1931. // Properties
  1932. /**
  1933. * Map dragging handler (by both mouse and touch).
  1934. */
  1935. dragging: IHandler;
  1936. /**
  1937. * Touch zoom handler.
  1938. */
  1939. touchZoom: IHandler;
  1940. /**
  1941. * Double click zoom handler.
  1942. */
  1943. doubleClickZoom: IHandler;
  1944. /**
  1945. * Scroll wheel zoom handler.
  1946. */
  1947. scrollWheelZoom: IHandler;
  1948. /**
  1949. * Box (shift-drag with mouse) zoom handler.
  1950. */
  1951. boxZoom: IHandler;
  1952. /**
  1953. * Keyboard navigation handler.
  1954. */
  1955. keyboard: IHandler;
  1956. /**
  1957. * Mobile touch hacks (quick tap and touch hold) handler.
  1958. */
  1959. tap: IHandler;
  1960. /**
  1961. * Zoom control.
  1962. */
  1963. zoomControl: Control.Zoom;
  1964. /**
  1965. * Attribution control.
  1966. */
  1967. attributionControl: Control.Attribution;
  1968. /**
  1969. * Map state options
  1970. */
  1971. options: Map.MapOptions;
  1972. /**
  1973. * Iterates over the layers of the map, optionally specifying context
  1974. * of the iterator function.
  1975. */
  1976. eachLayer(fn: (layer: ILayer) => void, context?: any): Map;
  1977. ////////////////
  1978. ////////////////
  1979. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Map;
  1980. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Map;
  1981. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Map;
  1982. hasEventListeners(type: string): boolean;
  1983. fireEvent(type: string, data?: any): Map;
  1984. on(type: string, fn: (e: LeafletEvent) => void, context?: any): Map;
  1985. once(type: string, fn: (e: LeafletEvent) => void, context?: any): Map;
  1986. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Map;
  1987. fire(type: string, data?: any): Map;addEventListener(eventMap: any, context?: any): Map;
  1988. removeEventListener(eventMap?: any, context?: any): Map;
  1989. clearAllEventListeners(): Map;
  1990. on(eventMap: any, context?: any): Map;
  1991. off(eventMap?: any, context?: any): Map;
  1992. }
  1993. }
  1994. declare namespace L.Map {
  1995. export interface MapOptions {
  1996. // Map State Options
  1997. /**
  1998. * Initial geographical center of the map.
  1999. */
  2000. center?: LatLng;
  2001. /**
  2002. * Initial map zoom.
  2003. */
  2004. zoom?: number;
  2005. /**
  2006. * Layers that will be added to the map initially.
  2007. */
  2008. layers?: ILayer[];
  2009. /**
  2010. * Minimum zoom level of the map. Overrides any minZoom set on map layers.
  2011. */
  2012. minZoom?: number;
  2013. /**
  2014. * Maximum zoom level of the map. This overrides any maxZoom set on map layers.
  2015. */
  2016. maxZoom?: number;
  2017. /**
  2018. * When this option is set, the map restricts the view to the given geographical
  2019. * bounds, bouncing the user back when he tries to pan outside the view, and also
  2020. * not allowing to zoom out to a view that's larger than the given bounds (depending
  2021. * on the map size). To set the restriction dynamically, use setMaxBounds method
  2022. */
  2023. maxBounds?: LatLngBounds;
  2024. /**
  2025. * Coordinate Reference System to use. Don't change this if you're not sure
  2026. * what it means.
  2027. *
  2028. * Default value: L.CRS.EPSG3857.
  2029. */
  2030. crs?: ICRS;
  2031. // Interaction Options
  2032. /**
  2033. * Whether the map be draggable with mouse/touch or not.
  2034. *
  2035. * Default value: true.
  2036. */
  2037. dragging?: boolean;
  2038. /**
  2039. * Whether the map can be zoomed by touch-dragging with two fingers.
  2040. *
  2041. * Default value: true.
  2042. */
  2043. touchZoom?: boolean;
  2044. /**
  2045. * Whether the map can be zoomed by using the mouse wheel.
  2046. * If passed 'center', it will zoom to the center of the view regardless of
  2047. * where the mouse was.
  2048. *
  2049. * Default value: true.
  2050. */
  2051. scrollWheelZoom?: boolean;
  2052. /**
  2053. * Whether the map can be zoomed in by double clicking on it and zoomed out
  2054. * by double clicking while holding shift.
  2055. * If passed 'center', double-click zoom will zoom to the center of the view
  2056. * regardless of where the mouse was.
  2057. *
  2058. * Default value: true.
  2059. */
  2060. doubleClickZoom?: boolean;
  2061. /**
  2062. * Whether the map can be zoomed to a rectangular area specified by dragging
  2063. * the mouse while pressing shift.
  2064. *
  2065. * Default value: true.
  2066. */
  2067. boxZoom?: boolean;
  2068. /**
  2069. * Enables mobile hacks for supporting instant taps (fixing 200ms click delay
  2070. * on iOS/Android) and touch holds (fired as contextmenu events).
  2071. *
  2072. * Default value: true.
  2073. */
  2074. tap?: boolean;
  2075. /**
  2076. * The max number of pixels a user can shift his finger during touch for it
  2077. * to be considered a valid tap.
  2078. *
  2079. * Default value: 15.
  2080. */
  2081. tapTolerance?: number;
  2082. /**
  2083. * Whether the map automatically handles browser window resize to update itself.
  2084. *
  2085. * Default value: true.
  2086. */
  2087. trackResize?: boolean;
  2088. /**
  2089. * With this option enabled, the map tracks when you pan to another "copy" of
  2090. * the world and seamlessly jumps to the original one so that all overlays like
  2091. * markers and vector layers are still visible.
  2092. *
  2093. * Default value: false.
  2094. */
  2095. worldCopyJump?: boolean;
  2096. /**
  2097. * Set it to false if you don't want popups to close when user clicks the map.
  2098. *
  2099. * Default value: true.
  2100. */
  2101. closePopupOnClick?: boolean;
  2102. // Keyboard Navigation Options
  2103. /**
  2104. * Makes the map focusable and allows users to navigate the map with keyboard
  2105. * arrows and +/- keys.
  2106. *
  2107. * Default value: true.
  2108. */
  2109. keyboard?: boolean;
  2110. /**
  2111. * Amount of pixels to pan when pressing an arrow key.
  2112. *
  2113. * Default value: 80.
  2114. */
  2115. keyboardPanOffset?: number;
  2116. /**
  2117. * Number of zoom levels to change when pressing + or - key.
  2118. *
  2119. * Default value: 1.
  2120. */
  2121. keyboardZoomOffset?: number;
  2122. // Panning Inertia Options
  2123. /**
  2124. * If enabled, panning of the map will have an inertia effect where the map builds
  2125. * momentum while dragging and continues moving in the same direction for some
  2126. * time. Feels especially nice on touch devices.
  2127. *
  2128. * Default value: true.
  2129. */
  2130. inertia?: boolean;
  2131. /**
  2132. * The rate with which the inertial movement slows down, in pixels/second2.
  2133. *
  2134. * Default value: 3000.
  2135. */
  2136. inertiaDeceleration?: number;
  2137. /**
  2138. * Max speed of the inertial movement, in pixels/second.
  2139. *
  2140. * Default value: 1500.
  2141. */
  2142. inertiaMaxSpeed?: number;
  2143. /**
  2144. * Amount of milliseconds that should pass between stopping the movement and
  2145. * releasing the mouse or touch to prevent inertial movement.
  2146. *
  2147. * Default value: 32 for touch devices and 14 for the rest.
  2148. */
  2149. inertiaThreshold?: number;
  2150. // Control options
  2151. /**
  2152. * Whether the zoom control is added to the map by default.
  2153. *
  2154. * Default value: true.
  2155. */
  2156. zoomControl?: boolean;
  2157. /**
  2158. * Whether the attribution control is added to the map by default.
  2159. *
  2160. * Default value: true.
  2161. */
  2162. attributionControl?: boolean;
  2163. // Animation options
  2164. /**
  2165. * Whether the tile fade animation is enabled. By default it's enabled in all
  2166. * browsers that support CSS3 Transitions except Android.
  2167. */
  2168. fadeAnimation?: boolean;
  2169. /**
  2170. * Whether the tile zoom animation is enabled. By default it's enabled in all
  2171. * browsers that support CSS3 Transitions except Android.
  2172. */
  2173. zoomAnimation?: boolean;
  2174. /**
  2175. * Won't animate zoom if the zoom difference exceeds this value.
  2176. *
  2177. * Default value: 4.
  2178. */
  2179. zoomAnimationThreshold?: number;
  2180. /**
  2181. * Whether markers animate their zoom with the zoom animation, if disabled
  2182. * they will disappear for the length of the animation. By default it's enabled
  2183. * in all browsers that support CSS3 Transitions except Android.
  2184. */
  2185. markerZoomAnimation?: boolean;
  2186. /**
  2187. * Set it to false if you don't want the map to zoom beyond min/max zoom
  2188. * and then bounce back when pinch-zooming.
  2189. *
  2190. * Default value: true.
  2191. */
  2192. bounceAtZoomLimits?: boolean;
  2193. }
  2194. export interface ZoomOptions {
  2195. /**
  2196. * If not specified, zoom animation will happen if the zoom origin is inside the current view.
  2197. * If true, the map will attempt animating zoom disregarding where zoom origin is.
  2198. * Setting false will make it always reset the view completely without animation.
  2199. */
  2200. animate?: boolean;
  2201. }
  2202. export interface ZoomPanOptions {
  2203. /**
  2204. * If true, the map view will be completely reset (without any animations).
  2205. *
  2206. * Default value: false.
  2207. */
  2208. reset?: boolean;
  2209. /**
  2210. * Sets the options for the panning (without the zoom change) if it occurs.
  2211. */
  2212. pan?: PanOptions;
  2213. /**
  2214. * Sets the options for the zoom change if it occurs.
  2215. */
  2216. zoom?: ZoomOptions;
  2217. /**
  2218. * An equivalent of passing animate to both zoom and pan options (see below).
  2219. */
  2220. animate?: boolean;
  2221. /**
  2222. * If true, it will delay moveend event so that it doesn't happen many times in a row.
  2223. */
  2224. debounceMoveend?: boolean;
  2225. /**
  2226. * Duration of animated panning, in seconds.
  2227. */
  2228. duration?: number;
  2229. /**
  2230. * The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve).
  2231. * 1.0 means linear animation, the less the more bowed the curve.
  2232. */
  2233. easeLinearity?: number;
  2234. /**
  2235. * If true, panning won't fire movestart event on start (used internally for panning inertia).
  2236. */
  2237. noMoveStart?: boolean;
  2238. }
  2239. export interface FitBoundsOptions extends ZoomPanOptions {
  2240. /**
  2241. * Sets the amount of padding in the top left corner of a map container that
  2242. * shouldn't be accounted for when setting the view to fit bounds. Useful if
  2243. * you have some control overlays on the map like a sidebar and you don't
  2244. * want them to obscure objects you're zooming to.
  2245. *
  2246. * Default value: [0, 0].
  2247. */
  2248. paddingTopLeft?: Point;
  2249. /**
  2250. * The same for bottom right corner of the map.
  2251. *
  2252. * Default value: [0, 0].
  2253. */
  2254. paddingBottomRight?: Point;
  2255. /**
  2256. * Equivalent of setting both top left and bottom right padding to the same value.
  2257. *
  2258. * Default value: [0, 0].
  2259. */
  2260. padding?: Point;
  2261. /**
  2262. * The maximum possible zoom to use.
  2263. *
  2264. * Default value: null
  2265. */
  2266. maxZoom?: number;
  2267. }
  2268. }
  2269. declare namespace L {
  2270. export interface MapPanes {
  2271. /**
  2272. * Pane that contains all other map panes.
  2273. */
  2274. mapPane: HTMLElement;
  2275. /**
  2276. * Pane for tile layers.
  2277. */
  2278. tilePane: HTMLElement;
  2279. /**
  2280. * Pane that contains all the panes except tile pane.
  2281. */
  2282. objectsPane: HTMLElement;
  2283. /**
  2284. * Pane for overlay shadows (e.g. marker shadows).
  2285. */
  2286. shadowPane: HTMLElement;
  2287. /**
  2288. * Pane for overlays like polylines and polygons.
  2289. */
  2290. overlayPane: HTMLElement;
  2291. /**
  2292. * Pane for marker icons.
  2293. */
  2294. markerPane: HTMLElement;
  2295. /**
  2296. * Pane for popups.
  2297. */
  2298. popupPane: HTMLElement;
  2299. }
  2300. }
  2301. declare namespace L {
  2302. /**
  2303. * Instantiates a Marker object given a geographical point and optionally
  2304. * an options object.
  2305. */
  2306. function marker(latlng: LatLngExpression, options?: MarkerOptions): Marker;
  2307. var Marker: {
  2308. /**
  2309. * Instantiates a Marker object given a geographical point and optionally
  2310. * an options object.
  2311. */
  2312. new(latlng: LatLngExpression, options?: MarkerOptions): Marker;
  2313. };
  2314. export interface Marker extends ILayer, IEventPowered<Marker> {
  2315. /**
  2316. * Adds the marker to the map.
  2317. */
  2318. addTo(map: Map): Marker;
  2319. /**
  2320. * Returns the current geographical position of the marker.
  2321. */
  2322. getLatLng(): LatLng;
  2323. /**
  2324. * Changes the marker position to the given point.
  2325. */
  2326. setLatLng(latlng: LatLngExpression): Marker;
  2327. /**
  2328. * Changes the marker icon.
  2329. */
  2330. setIcon(icon: Icon): Marker;
  2331. /**
  2332. * Changes the zIndex offset of the marker.
  2333. */
  2334. setZIndexOffset(offset: number): Marker;
  2335. /**
  2336. * Changes the opacity of the marker.
  2337. */
  2338. setOpacity(opacity: number): Marker;
  2339. /**
  2340. * Updates the marker position, useful if coordinates of its latLng object
  2341. * were changed directly.
  2342. */
  2343. update(): Marker;
  2344. /**
  2345. * Binds a popup with a particular HTML content to a click on this marker. You
  2346. * can also open the bound popup with the Marker openPopup method.
  2347. */
  2348. bindPopup(html: string, options?: PopupOptions): Marker;
  2349. /**
  2350. * Binds a popup with a particular HTML content to a click on this marker. You
  2351. * can also open the bound popup with the Marker openPopup method.
  2352. */
  2353. bindPopup(el: HTMLElement, options?: PopupOptions): Marker;
  2354. /**
  2355. * Binds a popup with a particular HTML content to a click on this marker. You
  2356. * can also open the bound popup with the Marker openPopup method.
  2357. */
  2358. bindPopup(popup: Popup, options?: PopupOptions): Marker;
  2359. /**
  2360. * Unbinds the popup previously bound to the marker with bindPopup.
  2361. */
  2362. unbindPopup(): Marker;
  2363. /**
  2364. * Opens the popup previously bound by the bindPopup method.
  2365. */
  2366. openPopup(): Marker;
  2367. /**
  2368. * Returns the popup previously bound by the bindPopup method.
  2369. */
  2370. getPopup(): Popup;
  2371. /**
  2372. * Closes the bound popup of the marker if it's opened.
  2373. */
  2374. closePopup(): Marker;
  2375. /**
  2376. * Toggles the popup previously bound by the bindPopup method.
  2377. */
  2378. togglePopup(): Marker;
  2379. /**
  2380. * Sets an HTML content of the popup of this marker.
  2381. */
  2382. setPopupContent(html: string, options?: PopupOptions): Marker;
  2383. /**
  2384. * Sets an HTML content of the popup of this marker.
  2385. */
  2386. setPopupContent(el: HTMLElement, options?: PopupOptions): Marker;
  2387. /**
  2388. * Returns a GeoJSON representation of the marker (GeoJSON Point Feature).
  2389. */
  2390. toGeoJSON(): GeoJSON.Feature<GeoJSON.Point>;
  2391. /**
  2392. * Marker dragging handler (by both mouse and touch).
  2393. */
  2394. dragging: IHandler;
  2395. ////////////
  2396. ////////////
  2397. /**
  2398. * Should contain code that creates DOM elements for the overlay, adds them
  2399. * to map panes where they should belong and puts listeners on relevant map events.
  2400. * Called on map.addLayer(layer).
  2401. */
  2402. onAdd(map: Map): void;
  2403. /**
  2404. * Should contain all clean up code that removes the overlay's elements from
  2405. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  2406. */
  2407. onRemove(map: Map): void;
  2408. ////////////////
  2409. ////////////////
  2410. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker;
  2411. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker;
  2412. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Marker;
  2413. hasEventListeners(type: string): boolean;
  2414. fireEvent(type: string, data?: any): Marker;
  2415. on(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker;
  2416. once(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker;
  2417. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Marker;
  2418. fire(type: string, data?: any): Marker;
  2419. addEventListener(eventMap: any, context?: any): Marker;
  2420. removeEventListener(eventMap?: any, context?: any): Marker;
  2421. clearAllEventListeners(): Marker;
  2422. on(eventMap: any, context?: any): Marker;
  2423. off(eventMap?: any, context?: any): Marker;
  2424. }
  2425. }
  2426. declare namespace L {
  2427. export interface MarkerOptions {
  2428. /**
  2429. * Icon class to use for rendering the marker. See Icon documentation for details
  2430. * on how to customize the marker icon.
  2431. *
  2432. * Default value: new L.Icon.Default().
  2433. */
  2434. icon?: Icon;
  2435. /**
  2436. * If false, the marker will not emit mouse events and will act as a part of the
  2437. * underlying map.
  2438. *
  2439. * Default value: true.
  2440. */
  2441. clickable?: boolean;
  2442. /**
  2443. * Whether the marker is draggable with mouse/touch or not.
  2444. *
  2445. * Default value: false.
  2446. */
  2447. draggable?: boolean;
  2448. /**
  2449. * Whether the marker can be tabbed to with a keyboard and clicked by pressing enter.
  2450. *
  2451. * Default value: true.
  2452. */
  2453. keyboard?: boolean;
  2454. /**
  2455. * Text for the browser tooltip that appear on marker hover (no tooltip by default).
  2456. *
  2457. * Default value: ''.
  2458. */
  2459. title?: string;
  2460. /**
  2461. * Text for the alt attribute of the icon image (useful for accessibility).
  2462. *
  2463. * Default value: ''.
  2464. */
  2465. alt?: string;
  2466. /**
  2467. * By default, marker images zIndex is set automatically based on its latitude.
  2468. * You this option if you want to put the marker on top of all others (or below),
  2469. * specifying a high value like 1000 (or high negative value, respectively).
  2470. *
  2471. * Default value: 0.
  2472. */
  2473. zIndexOffset?: number;
  2474. /**
  2475. * The opacity of the marker.
  2476. *
  2477. * Default value: 1.0.
  2478. */
  2479. opacity?: number;
  2480. /**
  2481. * If true, the marker will get on top of others when you hover the mouse over it.
  2482. *
  2483. * Default value: false.
  2484. */
  2485. riseOnHover?: boolean;
  2486. /**
  2487. * The z-index offset used for the riseOnHover feature.
  2488. *
  2489. * Default value: 250.
  2490. */
  2491. riseOffset?: number;
  2492. }
  2493. }
  2494. declare namespace L {
  2495. /**
  2496. * Instantiates a multi-polyline object given an array of latlngs arrays (one
  2497. * for each individual polygon) and optionally an options object (the same
  2498. * as for MultiPolyline).
  2499. */
  2500. function multiPolygon(latlngs: LatLng[][], options?: PolylineOptions): MultiPolygon;
  2501. export interface MultiPolygonStatic extends ClassStatic {
  2502. /**
  2503. * Instantiates a multi-polyline object given an array of latlngs arrays (one
  2504. * for each individual polygon) and optionally an options object (the same
  2505. * as for MultiPolyline).
  2506. */
  2507. new(latlngs: LatLng[][], options?: PolylineOptions): MultiPolygon;
  2508. }
  2509. export var MultiPolygon: MultiPolygonStatic;
  2510. export interface MultiPolygon extends FeatureGroup<Polygon> {
  2511. /**
  2512. * Replace all polygons and their paths with the given array of arrays
  2513. * of geographical points.
  2514. */
  2515. setLatLngs(latlngs: LatLng[][]): MultiPolygon;
  2516. /**
  2517. * Returns an array of arrays of geographical points in each polygon.
  2518. */
  2519. getLatLngs(): LatLng[][];
  2520. /**
  2521. * Opens the popup previously bound by bindPopup.
  2522. */
  2523. openPopup(): MultiPolygon;
  2524. /**
  2525. * Returns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature).
  2526. */
  2527. toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPolygon>;
  2528. }
  2529. }
  2530. declare namespace L {
  2531. /**
  2532. * Instantiates a multi-polyline object given an array of arrays of geographical
  2533. * points (one for each individual polyline) and optionally an options object.
  2534. */
  2535. function multiPolyline(latlngs: LatLng[][], options?: PolylineOptions): MultiPolyline;
  2536. export interface MultiPolylineStatic extends ClassStatic {
  2537. /**
  2538. * Instantiates a multi-polyline object given an array of arrays of geographical
  2539. * points (one for each individual polyline) and optionally an options object.
  2540. */
  2541. new(latlngs: LatLng[][], options?: PolylineOptions): MultiPolyline;
  2542. }
  2543. export var MultiPolyline: MultiPolylineStatic;
  2544. export interface MultiPolyline extends FeatureGroup<Polyline> {
  2545. /**
  2546. * Replace all polygons and their paths with the given array of arrays
  2547. * of geographical points.
  2548. */
  2549. setLatLngs(latlngs: LatLng[][]): MultiPolyline;
  2550. /**
  2551. * Returns an array of arrays of geographical points in each polygon.
  2552. */
  2553. getLatLngs(): LatLng[][];
  2554. /**
  2555. * Opens the popup previously bound by bindPopup.
  2556. */
  2557. openPopup(): MultiPolyline;
  2558. /**
  2559. * Returns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature).
  2560. */
  2561. toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiLineString>;
  2562. }
  2563. }
  2564. declare namespace L {
  2565. export interface PanOptions {
  2566. /**
  2567. * If true, panning will always be animated if possible. If false, it will not
  2568. * animate panning, either resetting the map view if panning more than a screen
  2569. * away, or just setting a new offset for the map pane (except for `panBy`
  2570. * which always does the latter).
  2571. */
  2572. animate?: boolean;
  2573. /**
  2574. * Duration of animated panning.
  2575. *
  2576. * Default value: 0.25.
  2577. */
  2578. duration?: number;
  2579. /**
  2580. * The curvature factor of panning animation easing (third parameter of the Cubic
  2581. * Bezier curve). 1.0 means linear animation, the less the more bowed the curve.
  2582. *
  2583. * Default value: 0.25.
  2584. */
  2585. easeLinearity?: number;
  2586. /**
  2587. * If true, panning won't fire movestart event on start (used internally for panning inertia).
  2588. *
  2589. * Default value: false.
  2590. */
  2591. noMoveStart?: boolean;
  2592. }
  2593. }
  2594. declare namespace L {
  2595. export interface Path extends ILayer, IEventPowered<Path> {
  2596. /**
  2597. * Adds the layer to the map.
  2598. */
  2599. addTo(map: Map): Path;
  2600. /**
  2601. * Binds a popup with a particular HTML content to a click on this path.
  2602. */
  2603. bindPopup(html: string, options?: PopupOptions): Path;
  2604. /**
  2605. * Binds a popup with a particular HTML content to a click on this path.
  2606. */
  2607. bindPopup(el: HTMLElement, options?: PopupOptions): Path;
  2608. /**
  2609. * Binds a popup with a particular HTML content to a click on this path.
  2610. */
  2611. bindPopup(popup: Popup, options?: PopupOptions): Path;
  2612. /**
  2613. * Unbinds the popup previously bound to the path with bindPopup.
  2614. */
  2615. unbindPopup(): Path;
  2616. /**
  2617. * Opens the popup previously bound by the bindPopup method in the given point,
  2618. * or in one of the path's points if not specified.
  2619. */
  2620. openPopup(latlng?: LatLngExpression): Path;
  2621. /**
  2622. * Closes the path's bound popup if it is opened.
  2623. */
  2624. closePopup(): Path;
  2625. /**
  2626. * Changes the appearance of a Path based on the options in the Path options object.
  2627. */
  2628. setStyle(object: PathOptions): Path;
  2629. /**
  2630. * Returns the LatLngBounds of the path.
  2631. */
  2632. getBounds(): LatLngBounds;
  2633. /**
  2634. * Brings the layer to the top of all path layers.
  2635. */
  2636. bringToFront(): Path;
  2637. /**
  2638. * Brings the layer to the bottom of all path layers.
  2639. */
  2640. bringToBack(): Path;
  2641. /**
  2642. * Redraws the layer. Sometimes useful after you changed the coordinates that
  2643. * the path uses.
  2644. */
  2645. redraw(): Path;
  2646. ////////////
  2647. ////////////
  2648. /**
  2649. * Should contain code that creates DOM elements for the overlay, adds them
  2650. * to map panes where they should belong and puts listeners on relevant map events.
  2651. * Called on map.addLayer(layer).
  2652. */
  2653. onAdd(map: Map): void;
  2654. /**
  2655. * Should contain all clean up code that removes the overlay's elements from
  2656. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  2657. */
  2658. onRemove(map: Map): void;
  2659. ////////////////
  2660. ////////////////
  2661. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Path;
  2662. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Path;
  2663. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Path;
  2664. hasEventListeners(type: string): boolean;
  2665. fireEvent(type: string, data?: any): Path;
  2666. on(type: string, fn: (e: LeafletEvent) => void, context?: any): Path;
  2667. once(type: string, fn: (e: LeafletEvent) => void, context?: any): Path;
  2668. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Path;
  2669. fire(type: string, data?: any): Path;
  2670. addEventListener(eventMap: any, context?: any): Path;
  2671. removeEventListener(eventMap?: any, context?: any): Path;
  2672. clearAllEventListeners(): Path;
  2673. on(eventMap: any, context?: any): Path;
  2674. off(eventMap?: any, context?: any): Path;
  2675. }
  2676. export namespace Path {
  2677. /**
  2678. * True if SVG is used for vector rendering (true for most modern browsers).
  2679. */
  2680. export var SVG: boolean;
  2681. /**
  2682. * True if VML is used for vector rendering (IE 6-8).
  2683. */
  2684. export var VML: boolean;
  2685. /**
  2686. * True if Canvas is used for vector rendering (Android 2). You can also force
  2687. * this by setting global variable L_PREFER_CANVAS to true before the Leaflet
  2688. * include on your page — sometimes it can increase performance dramatically
  2689. * when rendering thousands of circle markers, but currently suffers from
  2690. * a bug that causes removing such layers to be extremely slow.
  2691. */
  2692. export var CANVAS: boolean;
  2693. /**
  2694. * How much to extend the clip area around the map view (relative to its size,
  2695. * e.g. 0.5 is half the screen in each direction). Smaller values mean that you
  2696. * will see clipped ends of paths while you're dragging the map, and bigger values
  2697. * decrease drawing performance.
  2698. */
  2699. export var CLIP_PADDING: number;
  2700. }
  2701. }
  2702. declare namespace L {
  2703. export interface PathOptions {
  2704. /**
  2705. * Whether to draw stroke along the path. Set it to false to disable borders on
  2706. * polygons or circles.
  2707. *
  2708. * Default value: true.
  2709. */
  2710. stroke?: boolean;
  2711. /**
  2712. * Stroke color.
  2713. *
  2714. * Default value: '#03f'.
  2715. */
  2716. color?: string;
  2717. /**
  2718. * Stroke width in pixels.
  2719. *
  2720. * Default value: 5.
  2721. */
  2722. weight?: number;
  2723. /**
  2724. * Stroke opacity.
  2725. *
  2726. * Default value: 0.5.
  2727. */
  2728. opacity?: number;
  2729. /**
  2730. * Whether to fill the path with color. Set it to false to disable filling on polygons
  2731. * or circles.
  2732. */
  2733. fill?: boolean;
  2734. /**
  2735. * Fill color.
  2736. *
  2737. * Default value: same as color.
  2738. */
  2739. fillColor?: string;
  2740. /**
  2741. * Fill opacity.
  2742. *
  2743. * Default value: 0.2.
  2744. */
  2745. fillOpacity?: number;
  2746. /**
  2747. * A string that defines the stroke dash pattern. Doesn't work on canvas-powered
  2748. * layers (e.g. Android 2).
  2749. */
  2750. dashArray?: string;
  2751. /**
  2752. * A string that defines shape to be used at the end of the stroke.
  2753. *
  2754. * Default: null.
  2755. */
  2756. lineCap?: string;
  2757. /**
  2758. * A string that defines shape to be used at the corners of the stroke.
  2759. *
  2760. * Default: null.
  2761. */
  2762. lineJoin?: string;
  2763. /**
  2764. * If false, the vector will not emit mouse events and will act as a part of the
  2765. * underlying map.
  2766. *
  2767. * Default value: true.
  2768. */
  2769. clickable?: boolean;
  2770. /**
  2771. * Sets the pointer-events attribute on the path if SVG backend is used.
  2772. */
  2773. pointerEvents?: string;
  2774. /**
  2775. * Custom class name set on an element.
  2776. *
  2777. * Default value: ''.
  2778. */
  2779. className?: string;
  2780. /**
  2781. * Sets the radius of a circle marker.
  2782. */
  2783. radius?: number;
  2784. }
  2785. }
  2786. declare namespace L {
  2787. /**
  2788. * Creates a Point object with the given x and y coordinates. If optional round
  2789. * is set to true, rounds the x and y values.
  2790. */
  2791. function point(x: number, y: number, round?: boolean): Point;
  2792. export interface PointStatic {
  2793. /**
  2794. * Creates a Point object with the given x and y coordinates. If optional round
  2795. * is set to true, rounds the x and y values.
  2796. */
  2797. new(x: number, y: number, round?: boolean): Point;
  2798. }
  2799. export var Point: PointStatic;
  2800. export interface Point {
  2801. /**
  2802. * Returns the result of addition of the current and the given points.
  2803. */
  2804. add(otherPoint: Point): Point;
  2805. /**
  2806. * Returns the result of subtraction of the given point from the current.
  2807. */
  2808. subtract(otherPoint: Point): Point;
  2809. /**
  2810. * Returns the result of multiplication of the current point by the given number.
  2811. */
  2812. multiplyBy(number: number): Point;
  2813. /**
  2814. * Returns the result of division of the current point by the given number. If
  2815. * optional round is set to true, returns a rounded result.
  2816. */
  2817. divideBy(number: number, round?: boolean): Point;
  2818. /**
  2819. * Returns the distance between the current and the given points.
  2820. */
  2821. distanceTo(otherPoint: Point): number;
  2822. /**
  2823. * Returns a copy of the current point.
  2824. */
  2825. clone(): Point;
  2826. /**
  2827. * Returns a copy of the current point with rounded coordinates.
  2828. */
  2829. round(): Point;
  2830. /**
  2831. * Returns true if the given point has the same coordinates.
  2832. */
  2833. equals(otherPoint: Point): boolean;
  2834. /**
  2835. * Returns a string representation of the point for debugging purposes.
  2836. */
  2837. toString(): string;
  2838. /**
  2839. * The x coordinate.
  2840. */
  2841. x: number;
  2842. /**
  2843. * The y coordinate.
  2844. */
  2845. y: number;
  2846. }
  2847. }
  2848. declare namespace L {
  2849. /**
  2850. * Instantiates a polygon object given an array of geographical points and
  2851. * optionally an options object (the same as for Polyline). You can also create
  2852. * a polygon with holes by passing an array of arrays of latlngs, with the first
  2853. * latlngs array representing the exterior ring while the remaining represent
  2854. * the holes inside.
  2855. */
  2856. function polygon(latlngs: LatLngBoundsExpression, options?: PolylineOptions): Polygon;
  2857. export interface PolygonStatic extends ClassStatic {
  2858. /**
  2859. * Instantiates a polygon object given an array of geographical points and
  2860. * optionally an options object (the same as for Polyline). You can also create
  2861. * a polygon with holes by passing an array of arrays of latlngs, with the first
  2862. * latlngs array representing the exterior ring while the remaining represent
  2863. * the holes inside.
  2864. */
  2865. new(latlngs: LatLngBoundsExpression, options?: PolylineOptions): Polygon;
  2866. }
  2867. export var Polygon: PolygonStatic;
  2868. export interface Polygon extends Polyline {
  2869. }
  2870. }
  2871. declare namespace L {
  2872. /**
  2873. * Instantiates a polyline object given an array of geographical points and
  2874. * optionally an options object.
  2875. */
  2876. function polyline(latlngs: LatLngBoundsExpression, options?: PolylineOptions): Polyline;
  2877. export interface PolylineStatic extends ClassStatic {
  2878. /**
  2879. * Instantiates a polyline object given an array of geographical points and
  2880. * optionally an options object.
  2881. */
  2882. new(latlngs: LatLngBoundsExpression, options?: PolylineOptions): Polyline;
  2883. }
  2884. export var Polyline: PolylineStatic;
  2885. export interface Polyline extends Path {
  2886. /**
  2887. * Adds a given point to the polyline.
  2888. */
  2889. addLatLng(latlng: LatLngExpression): Polyline;
  2890. /**
  2891. * Replaces all the points in the polyline with the given array of geographical
  2892. * points.
  2893. */
  2894. setLatLngs(latlngs: LatLngBoundsExpression): Polyline;
  2895. /**
  2896. * Returns an array of the points in the path.
  2897. */
  2898. getLatLngs(): LatLng[];
  2899. /**
  2900. * Allows adding, removing or replacing points in the polyline. Syntax is the
  2901. * same as in Array#splice. Returns the array of removed points (if any).
  2902. */
  2903. spliceLatLngs(index: number, pointsToRemove: number, ...latlngs: LatLng[]): LatLng[];
  2904. /**
  2905. * Returns the LatLngBounds of the polyline.
  2906. */
  2907. getBounds(): LatLngBounds;
  2908. /**
  2909. * Returns a GeoJSON representation of the polyline (GeoJSON LineString Feature).
  2910. */
  2911. toGeoJSON(): GeoJSON.Feature<GeoJSON.LineString>;
  2912. }
  2913. }
  2914. declare namespace L {
  2915. export interface PolylineOptions extends PathOptions {
  2916. /**
  2917. * How much to simplify the polyline on each zoom level. More means better performance
  2918. * and smoother look, and less means more accurate representation.
  2919. *
  2920. * Default value: 1.0.
  2921. */
  2922. smoothFactor?: number;
  2923. /**
  2924. * Disabled polyline clipping.
  2925. *
  2926. * Default value: false.
  2927. */
  2928. noClip?: boolean;
  2929. }
  2930. }
  2931. declare namespace L {
  2932. namespace PolyUtil {
  2933. /**
  2934. * Clips the polygon geometry defined by the given points by rectangular bounds.
  2935. * Used by Leaflet to only show polygon points that are on the screen or near,
  2936. * increasing performance. Note that polygon points needs different algorithm
  2937. * for clipping than polyline, so there's a seperate method for it.
  2938. */
  2939. export function clipPolygon(points: Point[], bounds: Bounds): Point[];
  2940. }
  2941. }
  2942. declare namespace L {
  2943. /**
  2944. * Instantiates a Popup object given an optional options object that describes
  2945. * its appearance and location and an optional object that is used to tag the
  2946. * popup with a reference to the source object to which it refers.
  2947. */
  2948. function popup(options?: PopupOptions, source?: any): Popup;
  2949. export interface PopupStatic extends ClassStatic {
  2950. /**
  2951. * Instantiates a Popup object given an optional options object that describes
  2952. * its appearance and location and an optional object that is used to tag the
  2953. * popup with a reference to the source object to which it refers.
  2954. */
  2955. new(options?: PopupOptions, source?: any): Popup;
  2956. }
  2957. export var Popup: PopupStatic;
  2958. export interface Popup extends ILayer {
  2959. /**
  2960. * Adds the popup to the map.
  2961. */
  2962. addTo(map: Map): Popup;
  2963. /**
  2964. * Adds the popup to the map and closes the previous one. The same as map.openPopup(popup).
  2965. */
  2966. openOn(map: Map): Popup;
  2967. /**
  2968. * Sets the geographical point where the popup will open.
  2969. */
  2970. setLatLng(latlng: LatLngExpression): Popup;
  2971. /**
  2972. * Returns the geographical point of popup.
  2973. */
  2974. getLatLng(): LatLng;
  2975. /**
  2976. * Sets the HTML content of the popup.
  2977. */
  2978. setContent(html: string): Popup;
  2979. /**
  2980. * Sets the HTML content of the popup.
  2981. */
  2982. setContent(el: HTMLElement): Popup;
  2983. /**
  2984. * Returns the content of the popup.
  2985. */
  2986. getContent(): HTMLElement;
  2987. //getContent(): string;
  2988. ////////////
  2989. ////////////
  2990. /**
  2991. * Should contain code that creates DOM elements for the overlay, adds them
  2992. * to map panes where they should belong and puts listeners on relevant map events.
  2993. * Called on map.addLayer(layer).
  2994. */
  2995. onAdd(map: Map): void;
  2996. /**
  2997. * Should contain all clean up code that removes the overlay's elements from
  2998. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  2999. */
  3000. onRemove(map: Map): void;
  3001. /**
  3002. * Updates the popup content, layout and position. Useful for updating the popup after
  3003. * something inside changed, e.g. image loaded.
  3004. */
  3005. update(): Popup;
  3006. }
  3007. }
  3008. declare namespace L {
  3009. export interface PopupOptions {
  3010. /**
  3011. * Max width of the popup.
  3012. *
  3013. * Default value: 300.
  3014. */
  3015. maxWidth?: number;
  3016. /**
  3017. * Min width of the popup.
  3018. *
  3019. * Default value: 50.
  3020. */
  3021. minWidth?: number;
  3022. /**
  3023. * If set, creates a scrollable container of the given height inside a popup
  3024. * if its content exceeds it.
  3025. */
  3026. maxHeight?: number;
  3027. /**
  3028. * Set it to false if you don't want the map to do panning animation to fit the opened
  3029. * popup.
  3030. *
  3031. * Default value: true.
  3032. */
  3033. autoPan?: boolean;
  3034. /**
  3035. * Set it to true if you want to prevent users from panning the popup off of the screen while it is open.
  3036. */
  3037. keepInView?: boolean;
  3038. /**
  3039. * Controls the presense of a close button in the popup.
  3040. *
  3041. * Default value: true.
  3042. */
  3043. closeButton?: boolean;
  3044. /**
  3045. * The offset of the popup position. Useful to control the anchor of the popup
  3046. * when opening it on some overlays.
  3047. *
  3048. * Default value: new Point(0, 6).
  3049. */
  3050. offset?: Point;
  3051. /**
  3052. * The margin between the popup and the top left corner of the map view after
  3053. * autopanning was performed.
  3054. *
  3055. * Default value: null.
  3056. */
  3057. autoPanPaddingTopLeft?: Point;
  3058. /**
  3059. * The margin between the popup and the bottom right corner of the map view after
  3060. * autopanning was performed.
  3061. *
  3062. * Default value: null.
  3063. */
  3064. autoPanPaddingBottomRight?: Point;
  3065. /**
  3066. * The margin between the popup and the edges of the map view after autopanning
  3067. * was performed.
  3068. *
  3069. * Default value: new Point(5, 5).
  3070. */
  3071. autoPanPadding?: Point;
  3072. /**
  3073. * Whether to animate the popup on zoom. Disable it if you have problems with
  3074. * Flash content inside popups.
  3075. *
  3076. * Default value: true.
  3077. */
  3078. zoomAnimation?: boolean;
  3079. /**
  3080. * Set it to false if you want to override the default behavior of the popup
  3081. * closing when user clicks the map (set globally by the Map closePopupOnClick
  3082. * option).
  3083. */
  3084. closeOnClick?: boolean;
  3085. /**
  3086. * A custom class name to assign to the popup.
  3087. */
  3088. className?: string;
  3089. }
  3090. }
  3091. declare namespace L {
  3092. export interface PosAnimationStatic extends ClassStatic {
  3093. /**
  3094. * Creates a PosAnimation object.
  3095. */
  3096. new(): PosAnimation;
  3097. }
  3098. export var PosAnimation: PosAnimationStatic;
  3099. export interface PosAnimation extends IEventPowered<PosAnimation> {
  3100. /**
  3101. * Run an animation of a given element to a new position, optionally setting
  3102. * duration in seconds (0.25 by default) and easing linearity factor (3rd argument
  3103. * of the cubic bezier curve, 0.5 by default)
  3104. */
  3105. run(element: HTMLElement, newPos: Point, duration?: number, easeLinearity?: number): PosAnimation;
  3106. ////////////////
  3107. ////////////////
  3108. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation;
  3109. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation;
  3110. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): PosAnimation;
  3111. hasEventListeners(type: string): boolean;
  3112. fireEvent(type: string, data?: any): PosAnimation;
  3113. on(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation;
  3114. once(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation;
  3115. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): PosAnimation;
  3116. fire(type: string, data?: any): PosAnimation;
  3117. addEventListener(eventMap: any, context?: any): PosAnimation;
  3118. removeEventListener(eventMap?: any, context?: any): PosAnimation;
  3119. clearAllEventListeners(): PosAnimation;
  3120. on(eventMap: any, context?: any): PosAnimation;
  3121. off(eventMap?: any, context?: any): PosAnimation;
  3122. }
  3123. }
  3124. declare namespace L {
  3125. namespace Projection {
  3126. /**
  3127. * Spherical Mercator projection — the most common projection for online maps,
  3128. * used by almost all free and commercial tile providers. Assumes that Earth
  3129. * is a sphere. Used by the EPSG:3857 CRS.
  3130. */
  3131. export var SphericalMercator: IProjection;
  3132. /**
  3133. * Elliptical Mercator projection — more complex than Spherical Mercator.
  3134. * Takes into account that Earth is a geoid, not a perfect sphere. Used by the
  3135. * EPSG:3395 CRS.
  3136. */
  3137. export var Mercator: IProjection;
  3138. /**
  3139. * Equirectangular, or Plate Carree projection — the most simple projection,
  3140. * mostly used by GIS enthusiasts. Directly maps x as longitude, and y as latitude.
  3141. * Also suitable for flat worlds, e.g. game maps. Used by the EPSG:3395 and Simple
  3142. * CRS.
  3143. */
  3144. export var LonLat: IProjection;
  3145. }
  3146. }
  3147. declare namespace L {
  3148. /**
  3149. * Instantiates a rectangle object with the given geographical bounds and
  3150. * optionally an options object.
  3151. */
  3152. function rectangle(bounds: LatLngBounds, options?: PathOptions): Rectangle;
  3153. export interface RectangleStatic extends ClassStatic {
  3154. /**
  3155. * Instantiates a rectangle object with the given geographical bounds and
  3156. * optionally an options object.
  3157. */
  3158. new(bounds: LatLngBounds, options?: PathOptions): Rectangle;
  3159. }
  3160. export var Rectangle: RectangleStatic;
  3161. export interface Rectangle extends Polygon {
  3162. /**
  3163. * Redraws the rectangle with the passed bounds.
  3164. */
  3165. setBounds(bounds: LatLngBounds): Rectangle;
  3166. }
  3167. }
  3168. declare namespace L {
  3169. export interface ScaleOptions {
  3170. /**
  3171. * The position of the control (one of the map corners). See control positions.
  3172. * Default value: 'bottomleft'.
  3173. */
  3174. position?: PositionString;
  3175. /**
  3176. * Maximum width of the control in pixels. The width is set dynamically to show
  3177. * round values (e.g. 100, 200, 500).
  3178. * Default value: 100.
  3179. */
  3180. maxWidth?: number;
  3181. /**
  3182. * Whether to show the metric scale line (m/km).
  3183. * Default value: true.
  3184. */
  3185. metric?: boolean;
  3186. /**
  3187. * Whether to show the imperial scale line (mi/ft).
  3188. * Default value: true.
  3189. */
  3190. imperial?: boolean;
  3191. /**
  3192. * If true, the control is updated on moveend, otherwise it's always up-to-date
  3193. * (updated on move).
  3194. * Default value: false.
  3195. */
  3196. updateWhenIdle?: boolean;
  3197. }
  3198. }
  3199. declare namespace L {
  3200. export interface TileLayerStatic extends ClassStatic {
  3201. /**
  3202. * Instantiates a tile layer object given a URL template and optionally an options
  3203. * object.
  3204. */
  3205. new(urlTemplate: string, options?: TileLayerOptions): TileLayer;
  3206. WMS: {
  3207. /**
  3208. * Instantiates a WMS tile layer object given a base URL of the WMS service and
  3209. * a WMS parameters/options object.
  3210. */
  3211. new(baseUrl: string, options: WMSOptions): TileLayer.WMS;
  3212. };
  3213. Canvas: {
  3214. /**
  3215. * Instantiates a Canvas tile layer object given an options object (optionally).
  3216. */
  3217. new(options?: TileLayerOptions): TileLayer.Canvas;
  3218. };
  3219. }
  3220. export var TileLayer: TileLayerStatic;
  3221. export interface TileLayer extends ILayer, IEventPowered<TileLayer> {
  3222. /**
  3223. * Adds the layer to the map.
  3224. */
  3225. addTo(map: Map): TileLayer;
  3226. /**
  3227. * Brings the tile layer to the top of all tile layers.
  3228. */
  3229. bringToFront(): TileLayer;
  3230. /**
  3231. * Brings the tile layer to the bottom of all tile layers.
  3232. */
  3233. bringToBack(): TileLayer;
  3234. /**
  3235. * Changes the opacity of the tile layer.
  3236. */
  3237. setOpacity(opacity: number): TileLayer;
  3238. /**
  3239. * Sets the zIndex of the tile layer.
  3240. */
  3241. setZIndex(zIndex: number): TileLayer;
  3242. /**
  3243. * Causes the layer to clear all the tiles and request them again.
  3244. */
  3245. redraw(): TileLayer;
  3246. /**
  3247. * Updates the layer's URL template and redraws it.
  3248. */
  3249. setUrl(urlTemplate: string): TileLayer;
  3250. /**
  3251. * Returns the HTML element that contains the tiles for this layer.
  3252. */
  3253. getContainer(): HTMLElement;
  3254. ////////////
  3255. ////////////
  3256. /**
  3257. * Should contain code that creates DOM elements for the overlay, adds them
  3258. * to map panes where they should belong and puts listeners on relevant map events.
  3259. * Called on map.addLayer(layer).
  3260. */
  3261. onAdd(map: Map): void;
  3262. /**
  3263. * Should contain all clean up code that removes the overlay's elements from
  3264. * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
  3265. */
  3266. onRemove(map: Map): void;
  3267. ////////////////
  3268. ////////////////
  3269. addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer;
  3270. addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer;
  3271. removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): TileLayer;
  3272. hasEventListeners(type: string): boolean;
  3273. fireEvent(type: string, data?: any): TileLayer;
  3274. on(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer;
  3275. once(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer;
  3276. off(type: string, fn?: (e: LeafletEvent) => void, context?: any): TileLayer;
  3277. fire(type: string, data?: any): TileLayer;
  3278. addEventListener(eventMap: any, context?: any): TileLayer;
  3279. removeEventListener(eventMap?: any, context?: any): TileLayer;
  3280. clearAllEventListeners(): TileLayer;
  3281. on(eventMap: any, context?: any): TileLayer;
  3282. off(eventMap?: any, context?: any): TileLayer;
  3283. }
  3284. namespace TileLayer {
  3285. export interface WMS extends TileLayer {
  3286. /**
  3287. * Merges an object with the new parameters and re-requests tiles on the current
  3288. * screen (unless noRedraw was set to true).
  3289. */
  3290. setParams(params: WMS, noRedraw?: boolean): WMS;
  3291. }
  3292. export interface Canvas extends TileLayer {
  3293. /**
  3294. * You need to define this method after creating the instance to draw tiles;
  3295. * canvas is the actual canvas tile on which you can draw, tilePoint represents
  3296. * the tile numbers, and zoom is the current zoom.
  3297. */
  3298. drawTile(canvas: HTMLCanvasElement, tilePoint: Point, zoom: number): Canvas;
  3299. /**
  3300. * Calling redraw will cause the drawTile method to be called for all tiles.
  3301. * May be used for updating dynamic content drawn on the Canvas
  3302. */
  3303. redraw(): Canvas;
  3304. }
  3305. }
  3306. export interface TileLayerFactory {
  3307. /**
  3308. * Instantiates a tile layer object given a URL template and optionally an options
  3309. * object.
  3310. */
  3311. (urlTemplate: string, options?: TileLayerOptions): TileLayer;
  3312. /**
  3313. * Instantiates a WMS tile layer object given a base URL of the WMS service and
  3314. * a WMS parameters/options object.
  3315. */
  3316. wms(baseUrl: string, options: WMSOptions): L.TileLayer.WMS;
  3317. /**
  3318. * Instantiates a Canvas tile layer object given an options object (optionally).
  3319. */
  3320. canvas(options?: TileLayerOptions): L.TileLayer.Canvas;
  3321. }
  3322. export var tileLayer: TileLayerFactory;
  3323. }
  3324. declare namespace L {
  3325. export interface TileLayerOptions {
  3326. /**
  3327. * Minimum zoom number.
  3328. *
  3329. * Default value: 0.
  3330. */
  3331. minZoom?: number;
  3332. /**
  3333. * Maximum zoom number.
  3334. *
  3335. * Default value: 18.
  3336. */
  3337. maxZoom?: number;
  3338. /**
  3339. * Maximum zoom number the tiles source has available. If it is specified,
  3340. * the tiles on all zoom levels higher than maxNativeZoom will be loaded from
  3341. * maxZoom level and auto-scaled.
  3342. *
  3343. * Default value: null.
  3344. */
  3345. maxNativeZoom?: number;
  3346. /**
  3347. * Tile size (width and height in pixels, assuming tiles are square).
  3348. *
  3349. * Default value: 256.
  3350. */
  3351. tileSize?: number;
  3352. /**
  3353. * Subdomains of the tile service. Can be passed in the form of one string (where
  3354. * each letter is a subdomain name) or an array of strings.
  3355. *
  3356. * Default value: 'abc'.
  3357. */
  3358. subdomains?: string|string[];
  3359. /**
  3360. * URL to the tile image to show in place of the tile that failed to load.
  3361. *
  3362. * Default value: ''.
  3363. */
  3364. errorTileUrl?: string;
  3365. /**
  3366. * e.g. "© CloudMade" — the string used by the attribution control, describes
  3367. * the layer data.
  3368. *
  3369. * Default value: ''.
  3370. */
  3371. attribution?: string;
  3372. /**
  3373. * If true, inverses Y axis numbering for tiles (turn this on for TMS services).
  3374. *
  3375. * Default value: false.
  3376. */
  3377. tms?: boolean;
  3378. /**
  3379. * If set to true, the tile coordinates won't be wrapped by world width (-180
  3380. * to 180 longitude) or clamped to lie within world height (-90 to 90). Use this
  3381. * if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor
  3382. * or photo maps).
  3383. *
  3384. * Default value: false.
  3385. */
  3386. continuousWorld?: boolean;
  3387. /**
  3388. * If set to true, the tiles just won't load outside the world width (-180 to 180
  3389. * longitude) instead of repeating.
  3390. *
  3391. * Default value: false.
  3392. */
  3393. noWrap?: boolean;
  3394. /**
  3395. * The zoom number used in tile URLs will be offset with this value.
  3396. *
  3397. * Default value: 0.
  3398. */
  3399. zoomOffset?: number;
  3400. /**
  3401. * If set to true, the zoom number used in tile URLs will be reversed (maxZoom
  3402. * - zoom instead of zoom)
  3403. *
  3404. * Default value: false.
  3405. */
  3406. zoomReverse?: boolean;
  3407. /**
  3408. * The opacity of the tile layer.
  3409. *
  3410. * Default value: 1.0.
  3411. */
  3412. opacity?: number;
  3413. /**
  3414. * The explicit zIndex of the tile layer. Not set by default.
  3415. */
  3416. zIndex?: number;
  3417. /**
  3418. * If true, all the tiles that are not visible after panning are removed (for
  3419. * better performance). true by default on mobile WebKit, otherwise false.
  3420. */
  3421. unloadInvisibleTiles?: boolean;
  3422. /**
  3423. * If false, new tiles are loaded during panning, otherwise only after it (for
  3424. * better performance). true by default on mobile WebKit, otherwise false.
  3425. */
  3426. updateWhenIdle?: boolean;
  3427. /**
  3428. * If true and user is on a retina display, it will request four tiles of half the
  3429. * specified size and a bigger zoom level in place of one to utilize the high resolution.
  3430. *
  3431. * Default value: false.
  3432. */
  3433. detectRetina?: boolean;
  3434. /**
  3435. * If true, all the tiles that are not visible after panning are placed in a reuse
  3436. * queue from which they will be fetched when new tiles become visible (as opposed
  3437. * to dynamically creating new ones). This will in theory keep memory usage
  3438. * low and eliminate the need for reserving new memory whenever a new tile is
  3439. * needed.
  3440. *
  3441. * Default value: false.
  3442. */
  3443. reuseTiles?: boolean;
  3444. /**
  3445. * When this option is set, the TileLayer only loads tiles that are in the given geographical bounds.
  3446. */
  3447. bounds?: LatLngBounds;
  3448. /**
  3449. * Custom keys may be specified in TileLayerOptions so they can be used in a provided URL template.
  3450. */
  3451. [additionalKeys: string]: any;
  3452. }
  3453. }
  3454. declare namespace L {
  3455. export interface TransformationStatic {
  3456. /**
  3457. * Creates a transformation object with the given coefficients.
  3458. */
  3459. new(a: number, b: number, c: number, d: number): Transformation;
  3460. }
  3461. export var Transformation: TransformationStatic;
  3462. export interface Transformation {
  3463. /**
  3464. * Returns a transformed point, optionally multiplied by the given scale.
  3465. * Only accepts real L.Point instances, not arrays.
  3466. */
  3467. transform(point: Point, scale?: number): Point;
  3468. /**
  3469. * Returns the reverse transformation of the given point, optionally divided
  3470. * by the given scale. Only accepts real L.Point instances, not arrays.
  3471. */
  3472. untransform(point: Point, scale?: number): Point;
  3473. }
  3474. }
  3475. declare namespace L {
  3476. namespace Util {
  3477. /**
  3478. * Merges the properties of the src object (or multiple objects) into dest object
  3479. * and returns the latter. Has an L.extend shortcut.
  3480. */
  3481. export function extend(dest: any, ...sources: any[]): any;
  3482. /**
  3483. * Returns a function which executes function fn with the given scope obj (so
  3484. * that this keyword refers to obj inside the function code). Has an L.bind shortcut.
  3485. */
  3486. export function bind<T extends Function>(fn: T, obj: any): T;
  3487. /**
  3488. * Applies a unique key to the object and returns that key. Has an L.stamp shortcut.
  3489. */
  3490. export function stamp(obj: any): string;
  3491. /**
  3492. * Returns a wrapper around the function fn that makes sure it's called not more
  3493. * often than a certain time interval time, but as fast as possible otherwise
  3494. * (for example, it is used for checking and requesting new tiles while dragging
  3495. * the map), optionally passing the scope (context) in which the function will
  3496. * be called.
  3497. */
  3498. export function limitExecByInterval<T extends Function>(fn: T, time: number, context?: any): T;
  3499. /**
  3500. * Returns a function which always returns false.
  3501. */
  3502. export function falseFn(): () => boolean;
  3503. /**
  3504. * Returns the number num rounded to digits decimals.
  3505. */
  3506. export function formatNum(num: number, digits: number): number;
  3507. /**
  3508. * Trims and splits the string on whitespace and returns the array of parts.
  3509. */
  3510. export function splitWords(str: string): string[];
  3511. /**
  3512. * Merges the given properties to the options of the obj object, returning the
  3513. * resulting options. See Class options. Has an L.setOptions shortcut.
  3514. */
  3515. export function setOptions(obj: any, options: any): any;
  3516. /**
  3517. * Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"}
  3518. * translates to '?a=foo&b=bar'.
  3519. */
  3520. export function getParamString(obj: any): string;
  3521. /**
  3522. * Simple templating facility, creates a string by applying the values of the
  3523. * data object of a form {a: 'foo', b: 'bar', …} to a template string of the form
  3524. * 'Hello {a}, {b}' — in this example you will get 'Hello foo, bar'.
  3525. */
  3526. export function template(str: string, data: any): string;
  3527. /**
  3528. * Returns true if the given object is an array.
  3529. */
  3530. export function isArray(obj: any): boolean;
  3531. /**
  3532. * Trims the whitespace from both ends of the string and returns the result.
  3533. */
  3534. export function trim(str: string): string;
  3535. /**
  3536. * Data URI string containing a base64-encoded empty GIF image. Used as a hack
  3537. * to free memory from unused images on WebKit-powered mobile devices (by setting
  3538. * image src to this string).
  3539. */
  3540. export var emptyImageUrl: string;
  3541. }
  3542. }
  3543. declare namespace L {
  3544. export interface WMSOptions {
  3545. /**
  3546. * (required) Comma-separated list of WMS layers to show.
  3547. *
  3548. * Default value: ''.
  3549. */
  3550. layers?: string;
  3551. /**
  3552. * Comma-separated list of WMS styles.
  3553. *
  3554. * Default value: 'image/jpeg'.
  3555. */
  3556. styles?: string;
  3557. /**
  3558. * WMS image format (use 'image/png' for layers with transparency).
  3559. *
  3560. * Default value: false.
  3561. */
  3562. format?: string;
  3563. /**
  3564. * If true, the WMS service will return images with transparency.
  3565. *
  3566. * Default value: '1.1.1'.
  3567. */
  3568. transparent?: boolean;
  3569. /**
  3570. * Version of the WMS service to use.
  3571. */
  3572. version?: string;
  3573. }
  3574. }
  3575. /**
  3576. * Forces Leaflet to use the Canvas back-end (if available) for vector layers
  3577. * instead of SVG. This can increase performance considerably in some cases
  3578. * (e.g. many thousands of circle markers on the map).
  3579. */
  3580. declare var L_PREFER_CANVAS: boolean;
  3581. /**
  3582. * Forces Leaflet to not use touch events even if it detects them.
  3583. */
  3584. declare var L_NO_TOUCH: boolean;
  3585. /**
  3586. * Forces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning
  3587. * (which may cause glitches in some rare environments) even if they're supported.
  3588. */
  3589. declare var L_DISABLE_3D: boolean;
  3590. declare module "leaflet" {
  3591. export = L;
  3592. }
  3593. // vim: et ts=4 sw=4