esri-leaflet.js 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352
  1. /* esri-leaflet - v3.0.4 - Mon Dec 06 2021 15:19:56 GMT-0600 (Central Standard Time)
  2. * Copyright (c) 2021 Environmental Systems Research Institute, Inc.
  3. * Apache-2.0 */
  4. !(function (t, e) {
  5. "object" == typeof exports && "undefined" != typeof module
  6. ? e(exports, require("leaflet"))
  7. : "function" == typeof define && define.amd
  8. ? define(["exports", "leaflet"], e)
  9. : e(
  10. (((t = "undefined" != typeof globalThis ? globalThis : t || self).L =
  11. t.L || {}),
  12. (t.L.esri = {})),
  13. t.L
  14. );
  15. })(this, function (t, g) {
  16. "use strict";
  17. var e = "3.0.4",
  18. i =
  19. window.XMLHttpRequest && "withCredentials" in new window.XMLHttpRequest(),
  20. s = "" === document.documentElement.style.pointerEvents,
  21. a = { cors: i, pointerEvents: s },
  22. r = { attributionWidthOffset: 55 },
  23. n = 0;
  24. function l(t) {
  25. var e,
  26. i,
  27. s,
  28. r = "";
  29. for (var o in ((t.f = t.f || "json"), t)) {
  30. t.hasOwnProperty(o) &&
  31. ((e = t[o]),
  32. (i = Object.prototype.toString.call(e)),
  33. r.length && (r += "&"),
  34. (s =
  35. "[object Array]" === i
  36. ? "[object Object]" === Object.prototype.toString.call(e[0])
  37. ? JSON.stringify(e)
  38. : e.join(",")
  39. : "[object Object]" === i
  40. ? JSON.stringify(e)
  41. : "[object Date]" === i
  42. ? e.valueOf()
  43. : e),
  44. (r += encodeURIComponent(o) + "=" + encodeURIComponent(s)));
  45. }
  46. return r;
  47. }
  48. function u(s, r) {
  49. var o = new window.XMLHttpRequest();
  50. return (
  51. (o.onerror = function (t) {
  52. (o.onreadystatechange = g.Util.falseFn),
  53. s.call(
  54. r,
  55. { error: { code: 500, message: "XMLHttpRequest error" } },
  56. null
  57. );
  58. }),
  59. (o.onreadystatechange = function () {
  60. var e, i;
  61. if (4 === o.readyState) {
  62. try {
  63. e = JSON.parse(o.responseText);
  64. } catch (t) {
  65. (e = null),
  66. (i = {
  67. code: 500,
  68. message:
  69. "Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.",
  70. });
  71. }
  72. !i && e.error && ((i = e.error), (e = null)),
  73. (o.onerror = g.Util.falseFn),
  74. s.call(r, i, e);
  75. }
  76. }),
  77. (o.ontimeout = function () {
  78. this.onerror();
  79. }),
  80. o
  81. );
  82. }
  83. function o(t, e, i, s) {
  84. var r = u(i, s);
  85. return (
  86. r.open("POST", t),
  87. null != s && void 0 !== s.options && (r.timeout = s.options.timeout),
  88. r.setRequestHeader(
  89. "Content-Type",
  90. "application/x-www-form-urlencoded; charset=UTF-8"
  91. ),
  92. r.send(l(e)),
  93. r
  94. );
  95. }
  96. function h(t, e, i, s) {
  97. var r = u(i, s);
  98. return (
  99. r.open("GET", t + "?" + l(e), !0),
  100. null != s &&
  101. void 0 !== s.options &&
  102. ((r.timeout = s.options.timeout),
  103. s.options.withCredentials && (r.withCredentials = !0)),
  104. r.send(null),
  105. r
  106. );
  107. }
  108. function c(t, e, i, s) {
  109. var r = l(e),
  110. o = u(i, s),
  111. n = (t + "?" + r).length;
  112. if (
  113. (n <= 2e3 && a.cors
  114. ? o.open("GET", t + "?" + r)
  115. : 2e3 < n &&
  116. a.cors &&
  117. (o.open("POST", t),
  118. o.setRequestHeader(
  119. "Content-Type",
  120. "application/x-www-form-urlencoded; charset=UTF-8"
  121. )),
  122. null != s &&
  123. void 0 !== s.options &&
  124. ((o.timeout = s.options.timeout),
  125. s.options.withCredentials && (o.withCredentials = !0)),
  126. n <= 2e3 && a.cors)
  127. )
  128. o.send(null);
  129. else {
  130. if (!(2e3 < n && a.cors))
  131. return n <= 2e3 && !a.cors
  132. ? p(t, e, i, s)
  133. : void m(
  134. "a request to " +
  135. t +
  136. " was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html"
  137. );
  138. o.send(r);
  139. }
  140. return o;
  141. }
  142. function p(t, e, s, r) {
  143. window._EsriLeafletCallbacks = window._EsriLeafletCallbacks || {};
  144. var o = "c" + n;
  145. (e.callback = "window._EsriLeafletCallbacks." + o),
  146. (window._EsriLeafletCallbacks[o] = function (t) {
  147. var e, i;
  148. !0 !== window._EsriLeafletCallbacks[o] &&
  149. ("[object Object]" !== (i = Object.prototype.toString.call(t)) &&
  150. "[object Array]" !== i &&
  151. ((e = {
  152. error: {
  153. code: 500,
  154. message: "Expected array or object as JSONP response",
  155. },
  156. }),
  157. (t = null)),
  158. !e && t.error && ((e = t), (t = null)),
  159. s.call(r, e, t),
  160. (window._EsriLeafletCallbacks[o] = !0));
  161. });
  162. var i = g.DomUtil.create("script", null, document.body);
  163. return (
  164. (i.type = "text/javascript"),
  165. (i.src = t + "?" + l(e)),
  166. (i.id = o),
  167. (i.onerror = function (t) {
  168. t &&
  169. !0 !== window._EsriLeafletCallbacks[o] &&
  170. (s.call(r, {
  171. error: { code: 500, message: "An unknown error occurred" },
  172. }),
  173. (window._EsriLeafletCallbacks[o] = !0));
  174. }),
  175. g.DomUtil.addClass(i, "esri-leaflet-jsonp"),
  176. n++,
  177. {
  178. id: o,
  179. url: i.src,
  180. abort: function () {
  181. window._EsriLeafletCallbacks._callback[o]({
  182. code: 0,
  183. message: "Request aborted.",
  184. });
  185. },
  186. }
  187. );
  188. }
  189. var d = a.cors ? h : p;
  190. function m() {
  191. console && console.warn && console.warn.apply(console, arguments);
  192. }
  193. (d.CORS = h), (d.JSONP = p);
  194. function y(t, e) {
  195. for (var i = 0; i < t.length - 1; i++)
  196. for (var s = 0; s < e.length - 1; s++)
  197. if (
  198. (function (t, e, i, s) {
  199. var r =
  200. (s[0] - i[0]) * (t[1] - i[1]) - (s[1] - i[1]) * (t[0] - i[0]),
  201. o = (e[0] - t[0]) * (t[1] - i[1]) - (e[1] - t[1]) * (t[0] - i[0]),
  202. n = (s[1] - i[1]) * (e[0] - t[0]) - (s[0] - i[0]) * (e[1] - t[1]);
  203. if (0 != n) {
  204. var a = r / n,
  205. l = o / n;
  206. if (0 <= a && a <= 1 && 0 <= l && l <= 1) return !0;
  207. }
  208. return !1;
  209. })(t[i], t[i + 1], e[s], e[s + 1])
  210. )
  211. return !0;
  212. return !1;
  213. }
  214. function _(t) {
  215. return (
  216. (function (t, e) {
  217. for (var i = 0; i < t.length; i++) if (t[i] !== e[i]) return !1;
  218. return !0;
  219. })(t[0], t[t.length - 1]) || t.push(t[0]),
  220. t
  221. );
  222. }
  223. function v(t) {
  224. for (var e, i = 0, s = 0, r = t.length, o = t[s]; s < r - 1; s++)
  225. (i += ((e = t[s + 1])[0] - o[0]) * (e[1] + o[1])), (o = e);
  226. return 0 <= i;
  227. }
  228. function f(t) {
  229. var e = {};
  230. for (var i in t) t.hasOwnProperty(i) && (e[i] = t[i]);
  231. return e;
  232. }
  233. function b(t) {
  234. for (var e, i, s = [], r = [], o = 0; o < t.length; o++) {
  235. var n,
  236. a = _(t[o].slice(0));
  237. a.length < 4 ||
  238. (v(a)
  239. ? ((n = [a.slice().reverse()]), s.push(n))
  240. : r.push(a.slice().reverse()));
  241. }
  242. for (var l, u, h, c, p = []; r.length; ) {
  243. i = r.pop();
  244. for (var d = !1, m = s.length - 1; 0 <= m; m--)
  245. if (
  246. ((e = s[m][0]),
  247. (h = void 0),
  248. (h = y((l = e), (u = i))),
  249. (c = (function (t, e) {
  250. for (var i = !1, s = -1, r = t.length, o = r - 1; ++s < r; o = s)
  251. ((t[s][1] <= e[1] && e[1] < t[o][1]) ||
  252. (t[o][1] <= e[1] && e[1] < t[s][1])) &&
  253. e[0] <
  254. ((t[o][0] - t[s][0]) * (e[1] - t[s][1])) /
  255. (t[o][1] - t[s][1]) +
  256. t[s][0] &&
  257. (i = !i);
  258. return i;
  259. })(l, u[0])),
  260. !h && c)
  261. ) {
  262. s[m].push(i), (d = !0);
  263. break;
  264. }
  265. d || p.push(i);
  266. }
  267. for (; p.length; ) {
  268. i = p.pop();
  269. var f = !1;
  270. for (m = s.length - 1; 0 <= m; m--)
  271. if (((e = s[m][0]), y(e, i))) {
  272. s[m].push(i), (f = !0);
  273. break;
  274. }
  275. f || s.push([i.reverse()]);
  276. }
  277. return 1 === s.length
  278. ? { type: "Polygon", coordinates: s[0] }
  279. : { type: "MultiPolygon", coordinates: s };
  280. }
  281. function x(t) {
  282. var e = [],
  283. i = t.slice(0),
  284. s = _(i.shift().slice(0));
  285. if (4 <= s.length) {
  286. v(s) || s.reverse(), e.push(s);
  287. for (var r = 0; r < i.length; r++) {
  288. var o = _(i[r].slice(0));
  289. 4 <= o.length && (v(o) && o.reverse(), e.push(o));
  290. }
  291. }
  292. return e;
  293. }
  294. var S = { request: c, get: d, post: o },
  295. L = function t(e, i) {
  296. var s = {};
  297. if (e.features) {
  298. (s.type = "FeatureCollection"), (s.features = []);
  299. for (var r = 0; r < e.features.length; r++)
  300. s.features.push(t(e.features[r], i));
  301. }
  302. if (
  303. ("number" == typeof e.x &&
  304. "number" == typeof e.y &&
  305. ((s.type = "Point"),
  306. (s.coordinates = [e.x, e.y]),
  307. "number" == typeof e.z && s.coordinates.push(e.z)),
  308. e.points &&
  309. ((s.type = "MultiPoint"), (s.coordinates = e.points.slice(0))),
  310. e.paths &&
  311. (1 === e.paths.length
  312. ? ((s.type = "LineString"), (s.coordinates = e.paths[0].slice(0)))
  313. : ((s.type = "MultiLineString"),
  314. (s.coordinates = e.paths.slice(0)))),
  315. e.rings && (s = b(e.rings.slice(0))),
  316. "number" == typeof e.xmin &&
  317. "number" == typeof e.ymin &&
  318. "number" == typeof e.xmax &&
  319. "number" == typeof e.ymax &&
  320. ((s.type = "Polygon"),
  321. (s.coordinates = [
  322. [
  323. [e.xmax, e.ymax],
  324. [e.xmin, e.ymax],
  325. [e.xmin, e.ymin],
  326. [e.xmax, e.ymin],
  327. [e.xmax, e.ymax],
  328. ],
  329. ])),
  330. (e.geometry || e.attributes) &&
  331. ((s.type = "Feature"),
  332. (s.geometry = e.geometry ? t(e.geometry) : null),
  333. (s.properties = e.attributes ? f(e.attributes) : null),
  334. e.attributes))
  335. )
  336. try {
  337. s.id = (function (t, e) {
  338. for (
  339. var i = e ? [e, "OBJECTID", "FID"] : ["OBJECTID", "FID"], s = 0;
  340. s < i.length;
  341. s++
  342. ) {
  343. var r = i[s];
  344. if (
  345. r in t &&
  346. ("string" == typeof t[r] || "number" == typeof t[r])
  347. )
  348. return t[r];
  349. }
  350. throw Error("No valid id attribute found");
  351. })(e.attributes, i);
  352. } catch (t) {}
  353. return (
  354. JSON.stringify(s.geometry) === JSON.stringify({}) &&
  355. (s.geometry = null),
  356. e.spatialReference &&
  357. e.spatialReference.wkid &&
  358. 4326 !== e.spatialReference.wkid &&
  359. console.warn(
  360. "Object converted in non-standard crs - " +
  361. JSON.stringify(e.spatialReference)
  362. ),
  363. s
  364. );
  365. },
  366. A = function t(e, i) {
  367. i = i || "OBJECTID";
  368. var s,
  369. r = { wkid: 4326 },
  370. o = {};
  371. switch (e.type) {
  372. case "Point":
  373. (o.x = e.coordinates[0]),
  374. (o.y = e.coordinates[1]),
  375. (o.spatialReference = r);
  376. break;
  377. case "MultiPoint":
  378. (o.points = e.coordinates.slice(0)), (o.spatialReference = r);
  379. break;
  380. case "LineString":
  381. (o.paths = [e.coordinates.slice(0)]), (o.spatialReference = r);
  382. break;
  383. case "MultiLineString":
  384. (o.paths = e.coordinates.slice(0)), (o.spatialReference = r);
  385. break;
  386. case "Polygon":
  387. (o.rings = x(e.coordinates.slice(0))), (o.spatialReference = r);
  388. break;
  389. case "MultiPolygon":
  390. (o.rings = (function (t) {
  391. for (var e = [], i = 0; i < t.length; i++)
  392. for (var s = x(t[i]), r = s.length - 1; 0 <= r; r--) {
  393. var o = s[r].slice(0);
  394. e.push(o);
  395. }
  396. return e;
  397. })(e.coordinates.slice(0))),
  398. (o.spatialReference = r);
  399. break;
  400. case "Feature":
  401. e.geometry && (o.geometry = t(e.geometry, i)),
  402. (o.attributes = e.properties ? f(e.properties) : {}),
  403. e.id && (o.attributes[i] = e.id);
  404. break;
  405. case "FeatureCollection":
  406. for (o = [], s = 0; s < e.features.length; s++)
  407. o.push(t(e.features[s], i));
  408. break;
  409. case "GeometryCollection":
  410. for (o = [], s = 0; s < e.geometries.length; s++)
  411. o.push(t(e.geometries[s], i));
  412. }
  413. return o;
  414. },
  415. I =
  416. '<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>';
  417. /* @preserve
  418. * @terraformer/arcgis - v2.0.6 - MIT
  419. * Copyright (c) 2012-2020 Environmental Systems Research Institute, Inc.
  420. * Mon May 18 2020 14:30:35 GMT-0700 (Pacific Daylight Time)
  421. */
  422. /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.
  423. * Apache-2.0 */ function T(t, e) {
  424. return A(t, e);
  425. }
  426. function C(t, e) {
  427. return L(t, e);
  428. }
  429. function w(t) {
  430. if (
  431. "NaN" === t.xmin ||
  432. "NaN" === t.ymin ||
  433. "NaN" === t.xmax ||
  434. "NaN" === t.ymax
  435. )
  436. return null;
  437. var e = g.latLng(t.ymin, t.xmin),
  438. i = g.latLng(t.ymax, t.xmax);
  439. return g.latLngBounds(e, i);
  440. }
  441. function R(t) {
  442. return {
  443. xmin: (t = g.latLngBounds(t)).getSouthWest().lng,
  444. ymin: t.getSouthWest().lat,
  445. xmax: t.getNorthEast().lng,
  446. ymax: t.getNorthEast().lat,
  447. spatialReference: { wkid: 4326 },
  448. };
  449. }
  450. var P = /^(OBJECTID|FID|OID|ID)$/i;
  451. function F(t) {
  452. var e;
  453. if (t.objectIdFieldName) e = t.objectIdFieldName;
  454. else if (t.fields) {
  455. for (var i = 0; i <= t.fields.length - 1; i++)
  456. if ("esriFieldTypeOID" === t.fields[i].type) {
  457. e = t.fields[i].name;
  458. break;
  459. }
  460. if (!e)
  461. for (i = 0; i <= t.fields.length - 1; i++)
  462. if (t.fields[i].name.match(P)) {
  463. e = t.fields[i].name;
  464. break;
  465. }
  466. }
  467. return e;
  468. }
  469. function O(t) {
  470. for (var e in t.attributes) if (e.match(P)) return e;
  471. }
  472. function k(t, e) {
  473. var i = t.features || t.results,
  474. s = i && i.length,
  475. r = e || F(t),
  476. o = { type: "FeatureCollection", features: [] };
  477. if (s)
  478. for (var n = i.length - 1; 0 <= n; n--) {
  479. var a = C(i[n], r || O(i[n]));
  480. o.features.push(a);
  481. }
  482. return o;
  483. }
  484. function M(t) {
  485. return "/" !== (t = g.Util.trim(t))[t.length - 1] && (t += "/"), t;
  486. }
  487. function U(t) {
  488. var e;
  489. return (
  490. -1 !== t.url.indexOf("?") &&
  491. ((t.requestParams = t.requestParams || {}),
  492. (e = t.url.substring(t.url.indexOf("?") + 1)),
  493. (t.url = t.url.split("?")[0]),
  494. (t.requestParams = JSON.parse(
  495. '{"' +
  496. decodeURI(e)
  497. .replace(/"/g, '\\"')
  498. .replace(/&/g, '","')
  499. .replace(/=/g, '":"') +
  500. '"}'
  501. ))),
  502. (t.url = M(t.url.split("?")[0])),
  503. t
  504. );
  505. }
  506. function G(t) {
  507. return /^(?!.*utility\.arcgis\.com).*\.arcgis\.com.*FeatureServer/i.test(t);
  508. }
  509. function D(t) {
  510. var e;
  511. switch (t) {
  512. case "Point":
  513. e = "esriGeometryPoint";
  514. break;
  515. case "MultiPoint":
  516. e = "esriGeometryMultipoint";
  517. break;
  518. case "LineString":
  519. case "MultiLineString":
  520. e = "esriGeometryPolyline";
  521. break;
  522. case "Polygon":
  523. case "MultiPolygon":
  524. e = "esriGeometryPolygon";
  525. }
  526. return e;
  527. }
  528. function q(t) {
  529. return t.getSize().x - r.attributionWidthOffset + "px";
  530. }
  531. function E(e) {
  532. var t, i;
  533. e.attributionControl &&
  534. (e.attributionControl._esriAttributionLayerCount ||
  535. (e.attributionControl._esriAttributionLayerCount = 0),
  536. 0 === e.attributionControl._esriAttributionLayerCount &&
  537. (e.attributionControl._esriAttributionAddedOnce ||
  538. (((t = document.createElement("style")).type = "text/css"),
  539. (t.innerHTML =
  540. ".esri-truncated-attribution:hover {white-space: normal;}"),
  541. document.getElementsByTagName("head")[0].appendChild(t),
  542. ((i = document.createElement("style")).type = "text/css"),
  543. (i.innerHTML =
  544. ".esri-truncated-attribution {vertical-align: -3px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: inline-block;transition: 0s white-space;transition-delay: 1s;max-width: " +
  545. q(e) +
  546. ";}"),
  547. document.getElementsByTagName("head")[0].appendChild(i),
  548. e.on("resize", function (t) {
  549. e.attributionControl &&
  550. (e.attributionControl._container.style.maxWidth = q(t.target));
  551. }),
  552. (e.attributionControl._esriAttributionAddedOnce = !0)),
  553. e.attributionControl.setPrefix(
  554. I + ' | Powered by <a href="https://www.esri.com">Esri</a>'
  555. ),
  556. g.DomUtil.addClass(
  557. e.attributionControl._container,
  558. "esri-truncated-attribution:hover"
  559. ),
  560. g.DomUtil.addClass(
  561. e.attributionControl._container,
  562. "esri-truncated-attribution"
  563. )),
  564. (e.attributionControl._esriAttributionLayerCount =
  565. e.attributionControl._esriAttributionLayerCount + 1));
  566. }
  567. function B(t) {
  568. t.attributionControl &&
  569. (t.attributionControl._esriAttributionLayerCount &&
  570. 1 === t.attributionControl._esriAttributionLayerCount &&
  571. (t.attributionControl.setPrefix(I),
  572. g.DomUtil.removeClass(
  573. t.attributionControl._container,
  574. "esri-truncated-attribution:hover"
  575. ),
  576. g.DomUtil.removeClass(
  577. t.attributionControl._container,
  578. "esri-truncated-attribution"
  579. )),
  580. (t.attributionControl._esriAttributionLayerCount =
  581. t.attributionControl._esriAttributionLayerCount - 1));
  582. }
  583. function z(t) {
  584. var e = { geometry: null, geometryType: null };
  585. return t instanceof g.LatLngBounds
  586. ? ((e.geometry = R(t)), (e.geometryType = "esriGeometryEnvelope"), e)
  587. : (t.getLatLng && (t = t.getLatLng()),
  588. t instanceof g.LatLng &&
  589. (t = { type: "Point", coordinates: [t.lng, t.lat] }),
  590. t instanceof g.GeoJSON &&
  591. ((t = t.getLayers()[0].feature.geometry),
  592. (e.geometry = T(t)),
  593. (e.geometryType = D(t.type))),
  594. t.toGeoJSON && (t = t.toGeoJSON()),
  595. "Feature" === t.type && (t = t.geometry),
  596. "Point" === t.type ||
  597. "LineString" === t.type ||
  598. "Polygon" === t.type ||
  599. "MultiPolygon" === t.type
  600. ? ((e.geometry = T(t)), (e.geometryType = D(t.type)), e)
  601. : void m(
  602. "invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object"
  603. ));
  604. }
  605. function Z(t, l) {
  606. a.cors &&
  607. c(
  608. t,
  609. {},
  610. g.Util.bind(function (t, e) {
  611. if (!t) {
  612. l._esriAttributions = [];
  613. for (var i = 0; i < e.contributors.length; i++)
  614. for (
  615. var s = e.contributors[i], r = 0;
  616. r < s.coverageAreas.length;
  617. r++
  618. ) {
  619. var o = s.coverageAreas[r],
  620. n = g.latLng(o.bbox[0], o.bbox[1]),
  621. a = g.latLng(o.bbox[2], o.bbox[3]);
  622. l._esriAttributions.push({
  623. attribution: s.attribution,
  624. score: o.score,
  625. bounds: g.latLngBounds(n, a),
  626. minZoom: o.zoomMin,
  627. maxZoom: o.zoomMax,
  628. });
  629. }
  630. l._esriAttributions.sort(function (t, e) {
  631. return e.score - t.score;
  632. }),
  633. N({ target: l });
  634. }
  635. }, this)
  636. );
  637. }
  638. function N(t) {
  639. var e = t.target,
  640. i = e._esriAttributions;
  641. if (e && e.attributionControl) {
  642. var s = e.attributionControl._container.querySelector(
  643. ".esri-dynamic-attribution"
  644. );
  645. if (s && i) {
  646. for (
  647. var r = "",
  648. o = e.getBounds(),
  649. n = g.latLngBounds(
  650. o.getSouthWest().wrap(),
  651. o.getNorthEast().wrap()
  652. ),
  653. a = e.getZoom(),
  654. l = 0;
  655. l < i.length;
  656. l++
  657. ) {
  658. var u = i[l],
  659. h = u.attribution;
  660. !r.match(h) &&
  661. u.bounds.intersects(n) &&
  662. a >= u.minZoom &&
  663. a <= u.maxZoom &&
  664. (r += ", " + h);
  665. }
  666. (r = r.substr(2)),
  667. (s.innerHTML = r),
  668. (s.style.maxWidth = q(e)),
  669. e.fire("attributionupdated", { attribution: r });
  670. }
  671. }
  672. }
  673. var j = {
  674. warn: m,
  675. cleanUrl: M,
  676. getUrlParams: U,
  677. isArcgisOnline: G,
  678. geojsonTypeToArcGIS: D,
  679. responseToFeatureCollection: k,
  680. geojsonToArcGIS: T,
  681. arcgisToGeoJSON: C,
  682. boundsToExtent: R,
  683. extentToBounds: w,
  684. calcAttributionWidth: q,
  685. setEsriAttribution: E,
  686. _setGeometry: z,
  687. _getAttributionData: Z,
  688. _updateMapAttribution: N,
  689. _findIdAttributeFromFeature: O,
  690. _findIdAttributeFromResponse: F,
  691. },
  692. W = g.Class.extend({
  693. options: { proxy: !1, useCors: i },
  694. generateSetter: function (e, t) {
  695. return g.Util.bind(function (t) {
  696. return (this.params[e] = t), this;
  697. }, t);
  698. },
  699. initialize: function (t) {
  700. if (
  701. (t.request && t.options
  702. ? ((this._service = t), g.Util.setOptions(this, t.options))
  703. : (g.Util.setOptions(this, t), (this.options.url = M(t.url))),
  704. (this.params = g.Util.extend({}, this.params || {})),
  705. this.setters)
  706. )
  707. for (var e in this.setters) {
  708. var i = this.setters[e];
  709. this[e] = this.generateSetter(i, this);
  710. }
  711. },
  712. token: function (t) {
  713. return (
  714. this._service
  715. ? this._service.authenticate(t)
  716. : (this.params.token = t),
  717. this
  718. );
  719. },
  720. apikey: function (t) {
  721. return this.token(t);
  722. },
  723. format: function (t) {
  724. return (this.params.returnUnformattedValues = !t), this;
  725. },
  726. request: function (t, e) {
  727. return (
  728. this.options.requestParams &&
  729. g.Util.extend(this.params, this.options.requestParams),
  730. this._service
  731. ? this._service.request(this.path, this.params, t, e)
  732. : this._request("request", this.path, this.params, t, e)
  733. );
  734. },
  735. _request: function (t, e, i, s, r) {
  736. var o = this.options.proxy
  737. ? this.options.proxy + "?" + this.options.url + e
  738. : this.options.url + e;
  739. return ("get" !== t && "request" !== t) || this.options.useCors
  740. ? S[t](o, i, s, r)
  741. : S.get.JSONP(o, i, s, r);
  742. },
  743. });
  744. var J = W.extend({
  745. setters: {
  746. offset: "resultOffset",
  747. limit: "resultRecordCount",
  748. fields: "outFields",
  749. precision: "geometryPrecision",
  750. featureIds: "objectIds",
  751. returnGeometry: "returnGeometry",
  752. returnM: "returnM",
  753. transform: "datumTransformation",
  754. token: "token",
  755. },
  756. path: "query",
  757. params: { returnGeometry: !0, where: "1=1", outSR: 4326, outFields: "*" },
  758. within: function (t) {
  759. return (
  760. this._setGeometryParams(t),
  761. (this.params.spatialRel = "esriSpatialRelContains"),
  762. this
  763. );
  764. },
  765. intersects: function (t) {
  766. return (
  767. this._setGeometryParams(t),
  768. (this.params.spatialRel = "esriSpatialRelIntersects"),
  769. this
  770. );
  771. },
  772. contains: function (t) {
  773. return (
  774. this._setGeometryParams(t),
  775. (this.params.spatialRel = "esriSpatialRelWithin"),
  776. this
  777. );
  778. },
  779. crosses: function (t) {
  780. return (
  781. this._setGeometryParams(t),
  782. (this.params.spatialRel = "esriSpatialRelCrosses"),
  783. this
  784. );
  785. },
  786. touches: function (t) {
  787. return (
  788. this._setGeometryParams(t),
  789. (this.params.spatialRel = "esriSpatialRelTouches"),
  790. this
  791. );
  792. },
  793. overlaps: function (t) {
  794. return (
  795. this._setGeometryParams(t),
  796. (this.params.spatialRel = "esriSpatialRelOverlaps"),
  797. this
  798. );
  799. },
  800. bboxIntersects: function (t) {
  801. return (
  802. this._setGeometryParams(t),
  803. (this.params.spatialRel = "esriSpatialRelEnvelopeIntersects"),
  804. this
  805. );
  806. },
  807. indexIntersects: function (t) {
  808. return (
  809. this._setGeometryParams(t),
  810. (this.params.spatialRel = "esriSpatialRelIndexIntersects"),
  811. this
  812. );
  813. },
  814. nearby: function (t, e) {
  815. return (
  816. (t = g.latLng(t)),
  817. (this.params.geometry = [t.lng, t.lat]),
  818. (this.params.geometryType = "esriGeometryPoint"),
  819. (this.params.spatialRel = "esriSpatialRelIntersects"),
  820. (this.params.units = "esriSRUnit_Meter"),
  821. (this.params.distance = e),
  822. (this.params.inSR = 4326),
  823. this
  824. );
  825. },
  826. where: function (t) {
  827. return (this.params.where = t), this;
  828. },
  829. between: function (t, e) {
  830. return (this.params.time = [t.valueOf(), e.valueOf()]), this;
  831. },
  832. simplify: function (t, e) {
  833. var i = Math.abs(t.getBounds().getWest() - t.getBounds().getEast());
  834. return (this.params.maxAllowableOffset = (i / t.getSize().y) * e), this;
  835. },
  836. orderBy: function (t, e) {
  837. return (
  838. (e = e || "ASC"),
  839. (this.params.orderByFields = this.params.orderByFields
  840. ? this.params.orderByFields + ","
  841. : ""),
  842. (this.params.orderByFields += [t, e].join(" ")),
  843. this
  844. );
  845. },
  846. run: function (i, s) {
  847. return (
  848. this._cleanParams(),
  849. this.options.isModern ||
  850. (G(this.options.url) && void 0 === this.options.isModern)
  851. ? ((this.params.f = "geojson"),
  852. this.request(function (t, e) {
  853. this._trapSQLerrors(t), i.call(s, t, e, e);
  854. }, this))
  855. : this.request(function (t, e) {
  856. this._trapSQLerrors(t), i.call(s, t, e && k(e), e);
  857. }, this)
  858. );
  859. },
  860. count: function (i, t) {
  861. return (
  862. this._cleanParams(),
  863. (this.params.returnCountOnly = !0),
  864. this.request(function (t, e) {
  865. i.call(this, t, e && e.count, e);
  866. }, t)
  867. );
  868. },
  869. ids: function (i, t) {
  870. return (
  871. this._cleanParams(),
  872. (this.params.returnIdsOnly = !0),
  873. this.request(function (t, e) {
  874. i.call(this, t, e && e.objectIds, e);
  875. }, t)
  876. );
  877. },
  878. bounds: function (i, s) {
  879. return (
  880. this._cleanParams(),
  881. (this.params.returnExtentOnly = !0),
  882. this.request(function (t, e) {
  883. e && e.extent && w(e.extent)
  884. ? i.call(s, t, w(e.extent), e)
  885. : ((t = { message: "Invalid Bounds" }), i.call(s, t, null, e));
  886. }, s)
  887. );
  888. },
  889. distinct: function () {
  890. return (
  891. (this.params.returnGeometry = !1),
  892. (this.params.returnDistinctValues = !0),
  893. this
  894. );
  895. },
  896. pixelSize: function (t) {
  897. var e = g.point(t);
  898. return (this.params.pixelSize = [e.x, e.y]), this;
  899. },
  900. layer: function (t) {
  901. return (this.path = t + "/query"), this;
  902. },
  903. _trapSQLerrors: function (t) {
  904. t &&
  905. "400" === t.code &&
  906. m(
  907. "one common syntax error in query requests is encasing string values in double quotes instead of single quotes"
  908. );
  909. },
  910. _cleanParams: function () {
  911. delete this.params.returnIdsOnly,
  912. delete this.params.returnExtentOnly,
  913. delete this.params.returnCountOnly;
  914. },
  915. _setGeometryParams: function (t) {
  916. this.params.inSR = 4326;
  917. var e = z(t);
  918. (this.params.geometry = e.geometry),
  919. (this.params.geometryType = e.geometryType);
  920. },
  921. });
  922. function V(t) {
  923. return new J(t);
  924. }
  925. var Q = W.extend({
  926. setters: {
  927. contains: "contains",
  928. text: "searchText",
  929. fields: "searchFields",
  930. spatialReference: "sr",
  931. sr: "sr",
  932. layers: "layers",
  933. returnGeometry: "returnGeometry",
  934. maxAllowableOffset: "maxAllowableOffset",
  935. precision: "geometryPrecision",
  936. dynamicLayers: "dynamicLayers",
  937. returnZ: "returnZ",
  938. returnM: "returnM",
  939. gdbVersion: "gdbVersion",
  940. token: "token",
  941. },
  942. path: "find",
  943. params: {
  944. sr: 4326,
  945. contains: !0,
  946. returnGeometry: !0,
  947. returnZ: !0,
  948. returnM: !1,
  949. },
  950. layerDefs: function (t, e) {
  951. return (
  952. (this.params.layerDefs = this.params.layerDefs
  953. ? this.params.layerDefs + ";"
  954. : ""),
  955. (this.params.layerDefs += [t, e].join(":")),
  956. this
  957. );
  958. },
  959. simplify: function (t, e) {
  960. var i = Math.abs(t.getBounds().getWest() - t.getBounds().getEast());
  961. return (this.params.maxAllowableOffset = (i / t.getSize().y) * e), this;
  962. },
  963. run: function (i, s) {
  964. return this.request(function (t, e) {
  965. i.call(s, t, e && k(e), e);
  966. }, s);
  967. },
  968. });
  969. function K(t) {
  970. return new Q(t);
  971. }
  972. var H = W.extend({
  973. path: "identify",
  974. between: function (t, e) {
  975. return (this.params.time = [t.valueOf(), e.valueOf()]), this;
  976. },
  977. });
  978. var X = H.extend({
  979. setters: {
  980. layers: "layers",
  981. precision: "geometryPrecision",
  982. tolerance: "tolerance",
  983. returnGeometry: "returnGeometry",
  984. },
  985. params: { sr: 4326, layers: "all", tolerance: 3, returnGeometry: !0 },
  986. on: function (t) {
  987. var e = R(t.getBounds()),
  988. i = t.getSize();
  989. return (
  990. (this.params.imageDisplay = [i.x, i.y, 96]),
  991. (this.params.mapExtent = [e.xmin, e.ymin, e.xmax, e.ymax]),
  992. this
  993. );
  994. },
  995. at: function (t) {
  996. return (
  997. 2 === t.length && (t = g.latLng(t)), this._setGeometryParams(t), this
  998. );
  999. },
  1000. layerDef: function (t, e) {
  1001. return (
  1002. (this.params.layerDefs = this.params.layerDefs
  1003. ? this.params.layerDefs + ";"
  1004. : ""),
  1005. (this.params.layerDefs += [t, e].join(":")),
  1006. this
  1007. );
  1008. },
  1009. simplify: function (t, e) {
  1010. var i = Math.abs(t.getBounds().getWest() - t.getBounds().getEast());
  1011. return (this.params.maxAllowableOffset = (i / t.getSize().y) * e), this;
  1012. },
  1013. run: function (r, o) {
  1014. return this.request(function (t, e) {
  1015. if (t) r.call(o, t, void 0, e);
  1016. else {
  1017. var i = k(e);
  1018. e.results = e.results.reverse();
  1019. for (var s = 0; s < i.features.length; s++) {
  1020. i.features[s].layerId = e.results[s].layerId;
  1021. }
  1022. r.call(o, void 0, i, e);
  1023. }
  1024. });
  1025. },
  1026. _setGeometryParams: function (t) {
  1027. var e = z(t);
  1028. (this.params.geometry = e.geometry),
  1029. (this.params.geometryType = e.geometryType);
  1030. },
  1031. });
  1032. function Y(t) {
  1033. return new X(t);
  1034. }
  1035. var $ = H.extend({
  1036. setters: {
  1037. setMosaicRule: "mosaicRule",
  1038. setRenderingRule: "renderingRule",
  1039. setPixelSize: "pixelSize",
  1040. returnCatalogItems: "returnCatalogItems",
  1041. returnGeometry: "returnGeometry",
  1042. },
  1043. params: { returnGeometry: !1 },
  1044. at: function (t) {
  1045. return (
  1046. (t = g.latLng(t)),
  1047. (this.params.geometry = JSON.stringify({
  1048. x: t.lng,
  1049. y: t.lat,
  1050. spatialReference: { wkid: 4326 },
  1051. })),
  1052. (this.params.geometryType = "esriGeometryPoint"),
  1053. this
  1054. );
  1055. },
  1056. getMosaicRule: function () {
  1057. return this.params.mosaicRule;
  1058. },
  1059. getRenderingRule: function () {
  1060. return this.params.renderingRule;
  1061. },
  1062. getPixelSize: function () {
  1063. return this.params.pixelSize;
  1064. },
  1065. run: function (i, s) {
  1066. return this.request(function (t, e) {
  1067. i.call(s, t, e && this._responseToGeoJSON(e), e);
  1068. }, this);
  1069. },
  1070. _responseToGeoJSON: function (t) {
  1071. var e = t.location,
  1072. i = t.catalogItems,
  1073. s = t.catalogItemVisibilities,
  1074. r = {
  1075. pixel: {
  1076. type: "Feature",
  1077. geometry: { type: "Point", coordinates: [e.x, e.y] },
  1078. crs: {
  1079. type: "EPSG",
  1080. properties: { code: e.spatialReference.wkid },
  1081. },
  1082. properties: { OBJECTID: t.objectId, name: t.name, value: t.value },
  1083. id: t.objectId,
  1084. },
  1085. };
  1086. if (
  1087. (t.properties &&
  1088. t.properties.Values &&
  1089. (r.pixel.properties.values = t.properties.Values),
  1090. i &&
  1091. i.features &&
  1092. ((r.catalogItems = k(i)),
  1093. s && s.length === r.catalogItems.features.length))
  1094. )
  1095. for (var o = s.length - 1; 0 <= o; o--)
  1096. r.catalogItems.features[o].properties.catalogItemVisibility = s[o];
  1097. return r;
  1098. },
  1099. });
  1100. function tt(t) {
  1101. return new $(t);
  1102. }
  1103. var et = g.Evented.extend({
  1104. options: { proxy: !1, useCors: i, timeout: 0 },
  1105. initialize: function (t) {
  1106. (t = t || {}),
  1107. (this._requestQueue = []),
  1108. (this._authenticating = !1),
  1109. g.Util.setOptions(this, t),
  1110. (this.options.url = M(this.options.url));
  1111. },
  1112. get: function (t, e, i, s) {
  1113. return this._request("get", t, e, i, s);
  1114. },
  1115. post: function (t, e, i, s) {
  1116. return this._request("post", t, e, i, s);
  1117. },
  1118. request: function (t, e, i, s) {
  1119. return this._request("request", t, e, i, s);
  1120. },
  1121. metadata: function (t, e) {
  1122. return this._request("get", "", {}, t, e);
  1123. },
  1124. authenticate: function (t) {
  1125. return (
  1126. (this._authenticating = !1),
  1127. (this.options.token = t),
  1128. this._runQueue(),
  1129. this
  1130. );
  1131. },
  1132. getTimeout: function () {
  1133. return this.options.timeout;
  1134. },
  1135. setTimeout: function (t) {
  1136. this.options.timeout = t;
  1137. },
  1138. _request: function (t, e, i, s, r) {
  1139. this.fire(
  1140. "requeststart",
  1141. { url: this.options.url + e, params: i, method: t },
  1142. !0
  1143. );
  1144. var o = this._createServiceCallback(t, e, i, s, r);
  1145. if (
  1146. (this.options.token && (i.token = this.options.token),
  1147. this.options.requestParams &&
  1148. g.Util.extend(i, this.options.requestParams),
  1149. !this._authenticating)
  1150. ) {
  1151. var n = this.options.proxy
  1152. ? this.options.proxy + "?" + this.options.url + e
  1153. : this.options.url + e;
  1154. return ("get" !== t && "request" !== t) || this.options.useCors
  1155. ? S[t](n, i, o, r)
  1156. : S.get.JSONP(n, i, o, r);
  1157. }
  1158. this._requestQueue.push([t, e, i, s, r]);
  1159. },
  1160. _createServiceCallback: function (i, s, r, o, n) {
  1161. return g.Util.bind(function (t, e) {
  1162. !t ||
  1163. (499 !== t.code && 498 !== t.code) ||
  1164. ((this._authenticating = !0),
  1165. this._requestQueue.push([i, s, r, o, n]),
  1166. this.fire(
  1167. "authenticationrequired",
  1168. { authenticate: g.Util.bind(this.authenticate, this) },
  1169. !0
  1170. ),
  1171. (t.authenticate = g.Util.bind(this.authenticate, this))),
  1172. o.call(n, t, e),
  1173. t
  1174. ? this.fire(
  1175. "requesterror",
  1176. {
  1177. url: this.options.url + s,
  1178. params: r,
  1179. message: t.message,
  1180. code: t.code,
  1181. method: i,
  1182. },
  1183. !0
  1184. )
  1185. : this.fire(
  1186. "requestsuccess",
  1187. {
  1188. url: this.options.url + s,
  1189. params: r,
  1190. response: e,
  1191. method: i,
  1192. },
  1193. !0
  1194. ),
  1195. this.fire(
  1196. "requestend",
  1197. { url: this.options.url + s, params: r, method: i },
  1198. !0
  1199. );
  1200. }, this);
  1201. },
  1202. _runQueue: function () {
  1203. for (var t = this._requestQueue.length - 1; 0 <= t; t--) {
  1204. var e = this._requestQueue[t];
  1205. this[e.shift()].apply(this, e);
  1206. }
  1207. this._requestQueue = [];
  1208. },
  1209. });
  1210. var it = et.extend({
  1211. identify: function () {
  1212. return Y(this);
  1213. },
  1214. find: function () {
  1215. return K(this);
  1216. },
  1217. query: function () {
  1218. return V(this);
  1219. },
  1220. });
  1221. function st(t) {
  1222. return new it(t);
  1223. }
  1224. var rt = et.extend({
  1225. query: function () {
  1226. return V(this);
  1227. },
  1228. identify: function () {
  1229. return tt(this);
  1230. },
  1231. });
  1232. function ot(t) {
  1233. return new rt(t);
  1234. }
  1235. var nt = et.extend({
  1236. options: { idAttribute: "OBJECTID" },
  1237. query: function () {
  1238. return V(this);
  1239. },
  1240. addFeature: function (t, e, i) {
  1241. this.addFeatures(t, e, i);
  1242. },
  1243. addFeatures: function (t, s, r) {
  1244. for (var e = t.features ? t.features : [t], i = e.length - 1; 0 <= i; i--)
  1245. delete e[i].id;
  1246. return (
  1247. (t = T(t)),
  1248. (t = 1 < e.length ? t : [t]),
  1249. this.post(
  1250. "addFeatures",
  1251. { features: t },
  1252. function (t, e) {
  1253. var i =
  1254. e && e.addResults
  1255. ? 1 < e.addResults.length
  1256. ? e.addResults
  1257. : e.addResults[0]
  1258. : void 0;
  1259. s && s.call(r, t || e.addResults[0].error, i);
  1260. },
  1261. r
  1262. )
  1263. );
  1264. },
  1265. updateFeature: function (t, e, i) {
  1266. this.updateFeatures(t, e, i);
  1267. },
  1268. updateFeatures: function (t, s, r) {
  1269. var e = t.features ? t.features : [t];
  1270. return (
  1271. (t = T(t, this.options.idAttribute)),
  1272. (t = 1 < e.length ? t : [t]),
  1273. this.post(
  1274. "updateFeatures",
  1275. { features: t },
  1276. function (t, e) {
  1277. var i =
  1278. e && e.updateResults
  1279. ? 1 < e.updateResults.length
  1280. ? e.updateResults
  1281. : e.updateResults[0]
  1282. : void 0;
  1283. s && s.call(r, t || e.updateResults[0].error, i);
  1284. },
  1285. r
  1286. )
  1287. );
  1288. },
  1289. deleteFeature: function (t, e, i) {
  1290. this.deleteFeatures(t, e, i);
  1291. },
  1292. deleteFeatures: function (t, s, r) {
  1293. return this.post(
  1294. "deleteFeatures",
  1295. { objectIds: t },
  1296. function (t, e) {
  1297. var i =
  1298. e && e.deleteResults
  1299. ? 1 < e.deleteResults.length
  1300. ? e.deleteResults
  1301. : e.deleteResults[0]
  1302. : void 0;
  1303. s && s.call(r, t || e.deleteResults[0].error, i);
  1304. },
  1305. r
  1306. );
  1307. },
  1308. });
  1309. function at(t) {
  1310. return new nt(t);
  1311. }
  1312. var lt = "https:" !== window.location.protocol ? "http:" : "https:",
  1313. ut = g.TileLayer.extend({
  1314. statics: {
  1315. TILES: {
  1316. Streets: {
  1317. urlTemplate:
  1318. lt +
  1319. "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",
  1320. options: {
  1321. minZoom: 1,
  1322. maxZoom: 19,
  1323. subdomains: ["server", "services"],
  1324. attribution: "USGS, NOAA",
  1325. attributionUrl:
  1326. "https://static.arcgis.com/attribution/World_Street_Map",
  1327. },
  1328. },
  1329. Topographic: {
  1330. urlTemplate:
  1331. lt +
  1332. "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",
  1333. options: {
  1334. minZoom: 1,
  1335. maxZoom: 19,
  1336. subdomains: ["server", "services"],
  1337. attribution: "USGS, NOAA",
  1338. attributionUrl:
  1339. "https://static.arcgis.com/attribution/World_Topo_Map",
  1340. },
  1341. },
  1342. Oceans: {
  1343. urlTemplate:
  1344. lt +
  1345. "//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}",
  1346. options: {
  1347. minZoom: 1,
  1348. maxZoom: 16,
  1349. subdomains: ["server", "services"],
  1350. attribution: "USGS, NOAA",
  1351. attributionUrl:
  1352. "https://static.arcgis.com/attribution/Ocean_Basemap",
  1353. },
  1354. },
  1355. OceansLabels: {
  1356. urlTemplate:
  1357. lt +
  1358. "//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}",
  1359. options: {
  1360. minZoom: 1,
  1361. maxZoom: 16,
  1362. subdomains: ["server", "services"],
  1363. pane: s ? "esri-labels" : "tilePane",
  1364. attribution: "",
  1365. },
  1366. },
  1367. NationalGeographic: {
  1368. urlTemplate:
  1369. lt +
  1370. "//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",
  1371. options: {
  1372. minZoom: 1,
  1373. maxZoom: 16,
  1374. subdomains: ["server", "services"],
  1375. attribution:
  1376. "National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp.",
  1377. },
  1378. },
  1379. DarkGray: {
  1380. urlTemplate:
  1381. lt +
  1382. "//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",
  1383. options: {
  1384. minZoom: 1,
  1385. maxZoom: 16,
  1386. subdomains: ["server", "services"],
  1387. attribution:
  1388. "HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors",
  1389. },
  1390. },
  1391. DarkGrayLabels: {
  1392. urlTemplate:
  1393. lt +
  1394. "//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}",
  1395. options: {
  1396. minZoom: 1,
  1397. maxZoom: 16,
  1398. subdomains: ["server", "services"],
  1399. pane: s ? "esri-labels" : "tilePane",
  1400. attribution: "",
  1401. },
  1402. },
  1403. Gray: {
  1404. urlTemplate:
  1405. lt +
  1406. "//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",
  1407. options: {
  1408. minZoom: 1,
  1409. maxZoom: 16,
  1410. subdomains: ["server", "services"],
  1411. attribution:
  1412. "HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors",
  1413. },
  1414. },
  1415. GrayLabels: {
  1416. urlTemplate:
  1417. lt +
  1418. "//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",
  1419. options: {
  1420. minZoom: 1,
  1421. maxZoom: 16,
  1422. subdomains: ["server", "services"],
  1423. pane: s ? "esri-labels" : "tilePane",
  1424. attribution: "",
  1425. },
  1426. },
  1427. Imagery: {
  1428. urlTemplate:
  1429. lt +
  1430. "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
  1431. options: {
  1432. minZoom: 1,
  1433. maxZoom: 19,
  1434. subdomains: ["server", "services"],
  1435. attribution:
  1436. "DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community",
  1437. attributionUrl:
  1438. "https://static.arcgis.com/attribution/World_Imagery",
  1439. },
  1440. },
  1441. ImageryLabels: {
  1442. urlTemplate:
  1443. lt +
  1444. "//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",
  1445. options: {
  1446. minZoom: 1,
  1447. maxZoom: 19,
  1448. subdomains: ["server", "services"],
  1449. pane: s ? "esri-labels" : "tilePane",
  1450. attribution: "",
  1451. },
  1452. },
  1453. ImageryTransportation: {
  1454. urlTemplate:
  1455. lt +
  1456. "//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",
  1457. options: {
  1458. minZoom: 1,
  1459. maxZoom: 19,
  1460. subdomains: ["server", "services"],
  1461. pane: s ? "esri-labels" : "tilePane",
  1462. attribution: "",
  1463. },
  1464. },
  1465. ShadedRelief: {
  1466. urlTemplate:
  1467. lt +
  1468. "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",
  1469. options: {
  1470. minZoom: 1,
  1471. maxZoom: 13,
  1472. subdomains: ["server", "services"],
  1473. attribution: "USGS",
  1474. },
  1475. },
  1476. ShadedReliefLabels: {
  1477. urlTemplate:
  1478. lt +
  1479. "//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}",
  1480. options: {
  1481. minZoom: 1,
  1482. maxZoom: 12,
  1483. subdomains: ["server", "services"],
  1484. pane: s ? "esri-labels" : "tilePane",
  1485. attribution: "",
  1486. },
  1487. },
  1488. Terrain: {
  1489. urlTemplate:
  1490. lt +
  1491. "//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",
  1492. options: {
  1493. minZoom: 1,
  1494. maxZoom: 13,
  1495. subdomains: ["server", "services"],
  1496. attribution: "USGS, NOAA",
  1497. },
  1498. },
  1499. TerrainLabels: {
  1500. urlTemplate:
  1501. lt +
  1502. "//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",
  1503. options: {
  1504. minZoom: 1,
  1505. maxZoom: 13,
  1506. subdomains: ["server", "services"],
  1507. pane: s ? "esri-labels" : "tilePane",
  1508. attribution: "",
  1509. },
  1510. },
  1511. USATopo: {
  1512. urlTemplate:
  1513. lt +
  1514. "//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}",
  1515. options: {
  1516. minZoom: 1,
  1517. maxZoom: 15,
  1518. subdomains: ["server", "services"],
  1519. attribution: "USGS, National Geographic Society, i-cubed",
  1520. },
  1521. },
  1522. ImageryClarity: {
  1523. urlTemplate:
  1524. lt +
  1525. "//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
  1526. options: {
  1527. minZoom: 1,
  1528. maxZoom: 19,
  1529. attribution:
  1530. "Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community",
  1531. },
  1532. },
  1533. Physical: {
  1534. urlTemplate:
  1535. lt +
  1536. "//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",
  1537. options: {
  1538. minZoom: 1,
  1539. maxZoom: 8,
  1540. subdomains: ["server", "services"],
  1541. attribution: "U.S. National Park Service",
  1542. },
  1543. },
  1544. ImageryFirefly: {
  1545. urlTemplate:
  1546. lt +
  1547. "//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}",
  1548. options: {
  1549. minZoom: 1,
  1550. maxZoom: 19,
  1551. attribution:
  1552. "Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community",
  1553. attributionUrl:
  1554. "https://static.arcgis.com/attribution/World_Imagery",
  1555. },
  1556. },
  1557. },
  1558. },
  1559. initialize: function (t, e) {
  1560. var i;
  1561. if ("object" == typeof t && t.urlTemplate && t.options) i = t;
  1562. else {
  1563. if ("string" != typeof t || !ut.TILES[t])
  1564. throw new Error(
  1565. 'L.esri.BasemapLayer: Invalid parameter. Use one of "Streets", "Topographic", "Oceans", "OceansLabels", "NationalGeographic", "Physical", "Gray", "GrayLabels", "DarkGray", "DarkGrayLabels", "Imagery", "ImageryLabels", "ImageryTransportation", "ImageryClarity", "ImageryFirefly", ShadedRelief", "ShadedReliefLabels", "Terrain", "TerrainLabels" or "USATopo"'
  1566. );
  1567. i = ut.TILES[t];
  1568. }
  1569. var s = g.Util.extend(i.options, e);
  1570. g.Util.setOptions(this, s),
  1571. this.options.ignoreDeprecationWarning ||
  1572. console.warn(
  1573. "WARNING: L.esri.BasemapLayer uses data services that are in mature support and are not being updated. Please use L.esri.Vector.vectorBasemapLayer instead. More info: https://esriurl.com/esri-leaflet-basemap"
  1574. ),
  1575. this.options.token &&
  1576. -1 === i.urlTemplate.indexOf("token=") &&
  1577. (i.urlTemplate += "?token=" + this.options.token),
  1578. this.options.proxy &&
  1579. (i.urlTemplate = this.options.proxy + "?" + i.urlTemplate),
  1580. g.TileLayer.prototype.initialize.call(this, i.urlTemplate, s);
  1581. },
  1582. onAdd: function (t) {
  1583. E(t),
  1584. "esri-labels" === this.options.pane && this._initPane(),
  1585. this.options.attributionUrl &&
  1586. Z(
  1587. (this.options.proxy ? this.options.proxy + "?" : "") +
  1588. this.options.attributionUrl,
  1589. t
  1590. ),
  1591. t.on("moveend", N),
  1592. g.TileLayer.prototype.onAdd.call(this, t);
  1593. },
  1594. onRemove: function (t) {
  1595. B(t), t.off("moveend", N), g.TileLayer.prototype.onRemove.call(this, t);
  1596. },
  1597. _initPane: function () {
  1598. var t;
  1599. this._map.getPane(this.options.pane) ||
  1600. (((t = this._map.createPane(this.options.pane)).style.pointerEvents =
  1601. "none"),
  1602. (t.style.zIndex = 500));
  1603. },
  1604. getAttribution: function () {
  1605. var t;
  1606. return (
  1607. this.options.attribution &&
  1608. (t =
  1609. '<span class="esri-dynamic-attribution">' +
  1610. this.options.attribution +
  1611. "</span>"),
  1612. t
  1613. );
  1614. },
  1615. });
  1616. var ht = g.TileLayer.extend({
  1617. options: {
  1618. zoomOffsetAllowance: 0.1,
  1619. errorTileUrl:
  1620. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEABAMAAACuXLVVAAAAA1BMVEUzNDVszlHHAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAAAAAAAAAB6mUWpAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7waBAAABw08RwAAAAABJRU5ErkJggg==",
  1621. },
  1622. statics: {
  1623. MercatorZoomLevels: {
  1624. 0: 156543.033928,
  1625. 1: 78271.5169639999,
  1626. 2: 39135.7584820001,
  1627. 3: 19567.8792409999,
  1628. 4: 9783.93962049996,
  1629. 5: 4891.96981024998,
  1630. 6: 2445.98490512499,
  1631. 7: 1222.99245256249,
  1632. 8: 611.49622628138,
  1633. 9: 305.748113140558,
  1634. 10: 152.874056570411,
  1635. 11: 76.4370282850732,
  1636. 12: 38.2185141425366,
  1637. 13: 19.1092570712683,
  1638. 14: 9.55462853563415,
  1639. 15: 4.77731426794937,
  1640. 16: 2.38865713397468,
  1641. 17: 1.19432856685505,
  1642. 18: 0.597164283559817,
  1643. 19: 0.298582141647617,
  1644. 20: 0.14929107082381,
  1645. 21: 0.07464553541191,
  1646. 22: 0.0373227677059525,
  1647. 23: 0.0186613838529763,
  1648. },
  1649. },
  1650. initialize: function (t) {
  1651. (t = U((t = g.Util.setOptions(this, t)))),
  1652. (this.tileUrl =
  1653. (t.proxy ? t.proxy + "?" : "") +
  1654. t.url +
  1655. "tile/{z}/{y}/{x}" +
  1656. (t.requestParams && 0 < Object.keys(t.requestParams).length
  1657. ? g.Util.getParamString(t.requestParams)
  1658. : "")),
  1659. -1 !== t.url.indexOf("{s}") &&
  1660. t.subdomains &&
  1661. (t.url = t.url.replace("{s}", t.subdomains[0])),
  1662. (this.service = st(t)),
  1663. this.service.addEventParent(this),
  1664. new RegExp(/tiles.arcgis(online)?\.com/g).test(t.url) &&
  1665. ((this.tileUrl = this.tileUrl.replace("://tiles", "://tiles{s}")),
  1666. (t.subdomains = ["1", "2", "3", "4"])),
  1667. this.options.token && (this.tileUrl += "?token=" + this.options.token),
  1668. g.TileLayer.prototype.initialize.call(this, this.tileUrl, t);
  1669. },
  1670. getTileUrl: function (t) {
  1671. var e = this._getZoomForUrl();
  1672. return g.Util.template(
  1673. this.tileUrl,
  1674. g.Util.extend(
  1675. {
  1676. s: this._getSubdomain(t),
  1677. x: t.x,
  1678. y: t.y,
  1679. z: this._lodMap && this._lodMap[e] ? this._lodMap[e] : e,
  1680. },
  1681. this.options
  1682. )
  1683. );
  1684. },
  1685. createTile: function (t, e) {
  1686. var i = document.createElement("img");
  1687. return (
  1688. g.DomEvent.on(i, "load", g.Util.bind(this._tileOnLoad, this, e, i)),
  1689. g.DomEvent.on(i, "error", g.Util.bind(this._tileOnError, this, e, i)),
  1690. this.options.crossOrigin && (i.crossOrigin = ""),
  1691. (i.alt = ""),
  1692. !this._lodMap || (this._lodMap && this._lodMap[this._getZoomForUrl()])
  1693. ? (i.src = this.getTileUrl(t))
  1694. : this.once(
  1695. "lodmap",
  1696. function () {
  1697. i.src = this.getTileUrl(t);
  1698. },
  1699. this
  1700. ),
  1701. i
  1702. );
  1703. },
  1704. onAdd: function (u) {
  1705. E(u),
  1706. this._lodMap ||
  1707. this.metadata(function (t, e) {
  1708. if (!t && e.spatialReference) {
  1709. var i = e.spatialReference.latestWkid || e.spatialReference.wkid;
  1710. if (
  1711. (!this.options.attribution &&
  1712. u.attributionControl &&
  1713. e.copyrightText &&
  1714. ((this.options.attribution = e.copyrightText),
  1715. u.attributionControl.addAttribution(this.getAttribution())),
  1716. u.options.crs !== g.CRS.EPSG3857 ||
  1717. (102100 !== i && 3857 !== i))
  1718. )
  1719. (u.options.crs &&
  1720. u.options.crs.code &&
  1721. -1 < u.options.crs.code.indexOf(i)) ||
  1722. m(
  1723. "L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html"
  1724. );
  1725. else {
  1726. this._lodMap = {};
  1727. for (
  1728. var s = e.tileInfo.lods, r = ht.MercatorZoomLevels, o = 0;
  1729. o < s.length;
  1730. o++
  1731. ) {
  1732. var n = s[o];
  1733. for (var a in r) {
  1734. var l = r[a];
  1735. if (
  1736. this._withinPercentage(
  1737. n.resolution,
  1738. l,
  1739. this.options.zoomOffsetAllowance
  1740. )
  1741. ) {
  1742. this._lodMap[a] = n.level;
  1743. break;
  1744. }
  1745. }
  1746. }
  1747. this.fire("lodmap");
  1748. }
  1749. }
  1750. }, this),
  1751. g.TileLayer.prototype.onAdd.call(this, u);
  1752. },
  1753. onRemove: function (t) {
  1754. B(t), g.TileLayer.prototype.onRemove.call(this, t);
  1755. },
  1756. metadata: function (t, e) {
  1757. return this.service.metadata(t, e), this;
  1758. },
  1759. identify: function () {
  1760. return this.service.identify();
  1761. },
  1762. find: function () {
  1763. return this.service.find();
  1764. },
  1765. query: function () {
  1766. return this.service.query();
  1767. },
  1768. authenticate: function (t) {
  1769. var e = "?token=" + t;
  1770. return (
  1771. (this.tileUrl = this.options.token
  1772. ? this.tileUrl.replace(/\?token=(.+)/g, e)
  1773. : this.tileUrl + e),
  1774. (this.options.token = t),
  1775. this.service.authenticate(t),
  1776. this
  1777. );
  1778. },
  1779. _withinPercentage: function (t, e, i) {
  1780. return Math.abs(t / e - 1) < i;
  1781. },
  1782. });
  1783. var ct = g.ImageOverlay.extend({
  1784. onAdd: function (t) {
  1785. (this._topLeft = t.getPixelBounds().min),
  1786. g.ImageOverlay.prototype.onAdd.call(this, t);
  1787. },
  1788. _reset: function () {
  1789. this._map.options.crs === g.CRS.EPSG3857
  1790. ? g.ImageOverlay.prototype._reset.call(this)
  1791. : g.DomUtil.setPosition(
  1792. this._image,
  1793. this._topLeft.subtract(this._map.getPixelOrigin())
  1794. );
  1795. },
  1796. }),
  1797. pt = g.Layer.extend({
  1798. options: {
  1799. opacity: 1,
  1800. position: "front",
  1801. f: "image",
  1802. useCors: i,
  1803. attribution: null,
  1804. interactive: !1,
  1805. alt: "",
  1806. },
  1807. onAdd: function (i) {
  1808. E(i),
  1809. this.options.zIndex && (this.options.position = null),
  1810. (this._update = g.Util.throttle(
  1811. this._update,
  1812. this.options.updateInterval,
  1813. this
  1814. )),
  1815. i.on("moveend", this._update, this),
  1816. this._currentImage &&
  1817. this._currentImage._bounds.equals(this._map.getBounds())
  1818. ? i.addLayer(this._currentImage)
  1819. : this._currentImage &&
  1820. (this._map.removeLayer(this._currentImage),
  1821. (this._currentImage = null)),
  1822. this._update(),
  1823. this._popup &&
  1824. (this._map.on("click", this._getPopupData, this),
  1825. this._map.on("dblclick", this._resetPopupState, this)),
  1826. this.metadata(function (t, e) {
  1827. !t &&
  1828. !this.options.attribution &&
  1829. i.attributionControl &&
  1830. e.copyrightText &&
  1831. ((this.options.attribution = e.copyrightText),
  1832. i.attributionControl.addAttribution(this.getAttribution()));
  1833. }, this);
  1834. },
  1835. onRemove: function (t) {
  1836. B(t),
  1837. this._currentImage && this._map.removeLayer(this._currentImage),
  1838. this._popup &&
  1839. (this._map.off("click", this._getPopupData, this),
  1840. this._map.off("dblclick", this._resetPopupState, this)),
  1841. this._map.off("moveend", this._update, this);
  1842. },
  1843. bindPopup: function (t, e) {
  1844. return (
  1845. (this._shouldRenderPopup = !1),
  1846. (this._lastClick = !1),
  1847. (this._popup = g.popup(e)),
  1848. (this._popupFunction = t),
  1849. this._map &&
  1850. (this._map.on("click", this._getPopupData, this),
  1851. this._map.on("dblclick", this._resetPopupState, this)),
  1852. this
  1853. );
  1854. },
  1855. unbindPopup: function () {
  1856. return (
  1857. this._map &&
  1858. (this._map.closePopup(this._popup),
  1859. this._map.off("click", this._getPopupData, this),
  1860. this._map.off("dblclick", this._resetPopupState, this)),
  1861. (this._popup = !1),
  1862. this
  1863. );
  1864. },
  1865. bringToFront: function () {
  1866. return (
  1867. (this.options.position = "front"),
  1868. this._currentImage &&
  1869. (this._currentImage.bringToFront(), this._setAutoZIndex(Math.max)),
  1870. this
  1871. );
  1872. },
  1873. bringToBack: function () {
  1874. return (
  1875. (this.options.position = "back"),
  1876. this._currentImage &&
  1877. (this._currentImage.bringToBack(), this._setAutoZIndex(Math.min)),
  1878. this
  1879. );
  1880. },
  1881. setZIndex: function (t) {
  1882. return (
  1883. (this.options.zIndex = t),
  1884. this._currentImage && this._currentImage.setZIndex(t),
  1885. this
  1886. );
  1887. },
  1888. _setAutoZIndex: function (t) {
  1889. if (this._currentImage) {
  1890. for (
  1891. var e,
  1892. i = this._currentImage.getPane().children,
  1893. s = -t(-1 / 0, 1 / 0),
  1894. r = 0,
  1895. o = i.length;
  1896. r < o;
  1897. r++
  1898. )
  1899. (e = i[r].style.zIndex),
  1900. i[r] !== this._currentImage._image && e && (s = t(s, +e));
  1901. isFinite(s) &&
  1902. ((this.options.zIndex = s + t(-1, 1)),
  1903. this.setZIndex(this.options.zIndex));
  1904. }
  1905. },
  1906. getAttribution: function () {
  1907. return this.options.attribution;
  1908. },
  1909. getOpacity: function () {
  1910. return this.options.opacity;
  1911. },
  1912. setOpacity: function (t) {
  1913. return (
  1914. (this.options.opacity = t),
  1915. this._currentImage && this._currentImage.setOpacity(t),
  1916. this
  1917. );
  1918. },
  1919. getTimeRange: function () {
  1920. return [this.options.from, this.options.to];
  1921. },
  1922. setTimeRange: function (t, e) {
  1923. return (
  1924. (this.options.from = t), (this.options.to = e), this._update(), this
  1925. );
  1926. },
  1927. metadata: function (t, e) {
  1928. return this.service.metadata(t, e), this;
  1929. },
  1930. authenticate: function (t) {
  1931. return this.service.authenticate(t), this;
  1932. },
  1933. redraw: function () {
  1934. this._update();
  1935. },
  1936. _renderImage: function (t, s, e) {
  1937. if (this._map) {
  1938. if ((e && (t = "data:" + e + ";base64," + t), !t)) return;
  1939. var r = new ct(t, s, {
  1940. opacity: 0,
  1941. crossOrigin: this.options.withCredentials
  1942. ? "use-credentials"
  1943. : this.options.useCors,
  1944. alt: this.options.alt,
  1945. pane: this.options.pane || this.getPane(),
  1946. interactive: this.options.interactive,
  1947. }).addTo(this._map),
  1948. o = function (t) {
  1949. var e, i;
  1950. r.off("error", o, this),
  1951. this._map &&
  1952. ((e = t.target),
  1953. (i = this._currentImage),
  1954. e._bounds.equals(s) && e._bounds.equals(this._map.getBounds())
  1955. ? ((this._currentImage = e),
  1956. "front" === this.options.position
  1957. ? this.bringToFront()
  1958. : "back" === this.options.position &&
  1959. this.bringToBack(),
  1960. this.options.zIndex &&
  1961. this.setZIndex(this.options.zIndex),
  1962. this._map && this._currentImage._map
  1963. ? this._currentImage.setOpacity(this.options.opacity)
  1964. : this._currentImage._map.removeLayer(
  1965. this._currentImage
  1966. ),
  1967. i && this._map && this._map.removeLayer(i),
  1968. i && i._map && i._map.removeLayer(i))
  1969. : this._map.removeLayer(e)),
  1970. this.fire("load", { bounds: s });
  1971. };
  1972. r.once(
  1973. "error",
  1974. function () {
  1975. this._map.removeLayer(r),
  1976. this.fire("error"),
  1977. r.off("load", o, this);
  1978. },
  1979. this
  1980. ),
  1981. r.once("load", o, this);
  1982. }
  1983. },
  1984. _update: function () {
  1985. var t, e, i;
  1986. this._map &&
  1987. ((t = this._map.getZoom()),
  1988. (e = this._map.getBounds()),
  1989. this._animatingZoom ||
  1990. (this._map._panTransition &&
  1991. this._map._panTransition._inProgress) ||
  1992. (t > this.options.maxZoom || t < this.options.minZoom
  1993. ? this._currentImage &&
  1994. (this._currentImage._map.removeLayer(this._currentImage),
  1995. (this._currentImage = null))
  1996. : ((i = this._buildExportParams()),
  1997. g.Util.extend(i, this.options.requestParams),
  1998. i
  1999. ? (this._requestExport(i, e),
  2000. this.fire("loading", { bounds: e }))
  2001. : this._currentImage &&
  2002. (this._currentImage._map.removeLayer(this._currentImage),
  2003. (this._currentImage = null)))));
  2004. },
  2005. _renderPopup: function (t, e, i, s) {
  2006. var r;
  2007. (t = g.latLng(t)),
  2008. this._shouldRenderPopup &&
  2009. this._lastClick.equals(t) &&
  2010. (r = this._popupFunction(e, i, s)) &&
  2011. this._popup.setLatLng(t).setContent(r).openOn(this._map);
  2012. },
  2013. _resetPopupState: function (t) {
  2014. (this._shouldRenderPopup = !1), (this._lastClick = t.latlng);
  2015. },
  2016. _calculateBbox: function () {
  2017. var t = this._map.getPixelBounds(),
  2018. e = this._map.unproject(t.getBottomLeft()),
  2019. i = this._map.unproject(t.getTopRight()),
  2020. s = this._map.options.crs.project(i),
  2021. r = this._map.options.crs.project(e),
  2022. o = g.bounds(s, r);
  2023. return [
  2024. o.getBottomLeft().x,
  2025. o.getBottomLeft().y,
  2026. o.getTopRight().x,
  2027. o.getTopRight().y,
  2028. ].join(",");
  2029. },
  2030. _calculateImageSize: function () {
  2031. var t = this._map.getPixelBounds(),
  2032. e = this._map.getSize(),
  2033. i = this._map.unproject(t.getBottomLeft()),
  2034. s = this._map.unproject(t.getTopRight()),
  2035. r = this._map.latLngToLayerPoint(s).y,
  2036. o = this._map.latLngToLayerPoint(i).y;
  2037. return (0 < r || o < e.y) && (e.y = o - r), e.x + "," + e.y;
  2038. },
  2039. }),
  2040. dt = pt.extend({
  2041. options: {
  2042. updateInterval: 150,
  2043. format: "jpgpng",
  2044. transparent: !0,
  2045. f: "image",
  2046. },
  2047. query: function () {
  2048. return this.service.query();
  2049. },
  2050. identify: function () {
  2051. return this.service.identify();
  2052. },
  2053. initialize: function (t) {
  2054. (t = U(t)),
  2055. (this.service = ot(t)),
  2056. this.service.addEventParent(this),
  2057. g.Util.setOptions(this, t);
  2058. },
  2059. setPixelType: function (t) {
  2060. return (this.options.pixelType = t), this._update(), this;
  2061. },
  2062. getPixelType: function () {
  2063. return this.options.pixelType;
  2064. },
  2065. setBandIds: function (t) {
  2066. return (
  2067. g.Util.isArray(t)
  2068. ? (this.options.bandIds = t.join(","))
  2069. : (this.options.bandIds = t.toString()),
  2070. this._update(),
  2071. this
  2072. );
  2073. },
  2074. getBandIds: function () {
  2075. return this.options.bandIds;
  2076. },
  2077. setNoData: function (t, e) {
  2078. return (
  2079. g.Util.isArray(t)
  2080. ? (this.options.noData = t.join(","))
  2081. : (this.options.noData = t.toString()),
  2082. e && (this.options.noDataInterpretation = e),
  2083. this._update(),
  2084. this
  2085. );
  2086. },
  2087. getNoData: function () {
  2088. return this.options.noData;
  2089. },
  2090. getNoDataInterpretation: function () {
  2091. return this.options.noDataInterpretation;
  2092. },
  2093. setRenderingRule: function (t) {
  2094. (this.options.renderingRule = t), this._update();
  2095. },
  2096. getRenderingRule: function () {
  2097. return this.options.renderingRule;
  2098. },
  2099. setMosaicRule: function (t) {
  2100. (this.options.mosaicRule = t), this._update();
  2101. },
  2102. getMosaicRule: function () {
  2103. return this.options.mosaicRule;
  2104. },
  2105. _getPopupData: function (s) {
  2106. var t = g.Util.bind(function (t, e, i) {
  2107. t ||
  2108. setTimeout(
  2109. g.Util.bind(function () {
  2110. this._renderPopup(s.latlng, t, e, i);
  2111. }, this),
  2112. 300
  2113. );
  2114. }, this),
  2115. e = this.identify().at(s.latlng);
  2116. this.options.mosaicRule && e.setMosaicRule(this.options.mosaicRule),
  2117. e.run(t),
  2118. (this._shouldRenderPopup = !0),
  2119. (this._lastClick = s.latlng);
  2120. },
  2121. _buildExportParams: function () {
  2122. var t = parseInt(this._map.options.crs.code.split(":")[1], 10),
  2123. e = {
  2124. bbox: this._calculateBbox(),
  2125. size: this._calculateImageSize(),
  2126. format: this.options.format,
  2127. transparent: this.options.transparent,
  2128. bboxSR: t,
  2129. imageSR: t,
  2130. };
  2131. return (
  2132. this.options.from &&
  2133. this.options.to &&
  2134. (e.time =
  2135. this.options.from.valueOf() + "," + this.options.to.valueOf()),
  2136. this.options.pixelType && (e.pixelType = this.options.pixelType),
  2137. this.options.interpolation &&
  2138. (e.interpolation = this.options.interpolation),
  2139. this.options.compressionQuality &&
  2140. (e.compressionQuality = this.options.compressionQuality),
  2141. this.options.bandIds && (e.bandIds = this.options.bandIds),
  2142. (0 !== this.options.noData && !this.options.noData) ||
  2143. (e.noData = this.options.noData),
  2144. this.options.noDataInterpretation &&
  2145. (e.noDataInterpretation = this.options.noDataInterpretation),
  2146. this.service.options.token && (e.token = this.service.options.token),
  2147. this.options.renderingRule &&
  2148. (e.renderingRule = JSON.stringify(this.options.renderingRule)),
  2149. this.options.mosaicRule &&
  2150. (e.mosaicRule = JSON.stringify(this.options.mosaicRule)),
  2151. e
  2152. );
  2153. },
  2154. _requestExport: function (t, i) {
  2155. var e;
  2156. "json" === this.options.f
  2157. ? this.service.request(
  2158. "exportImage",
  2159. t,
  2160. function (t, e) {
  2161. t ||
  2162. (this.options.token &&
  2163. (e.href += "?token=" + this.options.token),
  2164. this.options.proxy &&
  2165. (e.href = this.options.proxy + "?" + e.href),
  2166. this._renderImage(e.href, i));
  2167. },
  2168. this
  2169. )
  2170. : ((t.f = "image"),
  2171. (e = this.options.url + "exportImage" + g.Util.getParamString(t)),
  2172. this.options.proxy && (e = this.options.proxy + "?" + e),
  2173. this._renderImage(e, i));
  2174. },
  2175. });
  2176. var mt = pt.extend({
  2177. options: {
  2178. updateInterval: 150,
  2179. layers: !1,
  2180. layerDefs: !1,
  2181. timeOptions: !1,
  2182. format: "png32",
  2183. transparent: !0,
  2184. f: "json",
  2185. },
  2186. initialize: function (t) {
  2187. (t = U(t)),
  2188. (this.service = st(t)),
  2189. this.service.addEventParent(this),
  2190. g.Util.setOptions(this, t);
  2191. },
  2192. getDynamicLayers: function () {
  2193. return this.options.dynamicLayers;
  2194. },
  2195. setDynamicLayers: function (t) {
  2196. return (this.options.dynamicLayers = t), this._update(), this;
  2197. },
  2198. getLayers: function () {
  2199. return this.options.layers;
  2200. },
  2201. setLayers: function (t) {
  2202. return (this.options.layers = t), this._update(), this;
  2203. },
  2204. getLayerDefs: function () {
  2205. return this.options.layerDefs;
  2206. },
  2207. setLayerDefs: function (t) {
  2208. return (this.options.layerDefs = t), this._update(), this;
  2209. },
  2210. getTimeOptions: function () {
  2211. return this.options.timeOptions;
  2212. },
  2213. setTimeOptions: function (t) {
  2214. return (this.options.timeOptions = t), this._update(), this;
  2215. },
  2216. query: function () {
  2217. return this.service.query();
  2218. },
  2219. identify: function () {
  2220. return this.service.identify();
  2221. },
  2222. find: function () {
  2223. return this.service.find();
  2224. },
  2225. _getPopupData: function (s) {
  2226. var t = g.Util.bind(function (t, e, i) {
  2227. t ||
  2228. setTimeout(
  2229. g.Util.bind(function () {
  2230. this._renderPopup(s.latlng, t, e, i);
  2231. }, this),
  2232. 300
  2233. );
  2234. }, this),
  2235. e = this.options.popup
  2236. ? this.options.popup.on(this._map).at(s.latlng)
  2237. : this.identify().on(this._map).at(s.latlng);
  2238. if (
  2239. (e.params.maxAllowableOffset || e.simplify(this._map, 0.5),
  2240. (this.options.popup &&
  2241. this.options.popup.params &&
  2242. this.options.popup.params.layers) ||
  2243. (this.options.layers
  2244. ? e.layers("visible:" + this.options.layers.join(","))
  2245. : e.layers("visible")),
  2246. this.options.layerDefs &&
  2247. "string" != typeof this.options.layerDefs &&
  2248. !e.params.layerDefs)
  2249. )
  2250. for (var i in this.options.layerDefs)
  2251. this.options.layerDefs.hasOwnProperty(i) &&
  2252. e.layerDef(i, this.options.layerDefs[i]);
  2253. e.run(t), (this._shouldRenderPopup = !0), (this._lastClick = s.latlng);
  2254. },
  2255. _buildExportParams: function () {
  2256. var t = parseInt(this._map.options.crs.code.split(":")[1], 10),
  2257. e = {
  2258. bbox: this._calculateBbox(),
  2259. size: this._calculateImageSize(),
  2260. dpi: 96,
  2261. format: this.options.format,
  2262. transparent: this.options.transparent,
  2263. bboxSR: t,
  2264. imageSR: t,
  2265. };
  2266. if (
  2267. (this.options.dynamicLayers &&
  2268. (e.dynamicLayers = this.options.dynamicLayers),
  2269. this.options.layers)
  2270. ) {
  2271. if (0 === this.options.layers.length) return;
  2272. e.layers = "show:" + this.options.layers.join(",");
  2273. }
  2274. return (
  2275. this.options.layerDefs &&
  2276. (e.layerDefs =
  2277. "string" == typeof this.options.layerDefs
  2278. ? this.options.layerDefs
  2279. : JSON.stringify(this.options.layerDefs)),
  2280. this.options.timeOptions &&
  2281. (e.timeOptions = JSON.stringify(this.options.timeOptions)),
  2282. this.options.from &&
  2283. this.options.to &&
  2284. (e.time =
  2285. this.options.from.valueOf() + "," + this.options.to.valueOf()),
  2286. this.service.options.token && (e.token = this.service.options.token),
  2287. this.options.proxy && (e.proxy = this.options.proxy),
  2288. this.options.disableCache && (e._ts = Date.now()),
  2289. e
  2290. );
  2291. },
  2292. _requestExport: function (t, i) {
  2293. var e;
  2294. "json" === this.options.f
  2295. ? this.service.request(
  2296. "export",
  2297. t,
  2298. function (t, e) {
  2299. t ||
  2300. (this.options.token &&
  2301. e.href &&
  2302. (e.href += "?token=" + this.options.token),
  2303. this.options.proxy &&
  2304. e.href &&
  2305. (e.href = this.options.proxy + "?" + e.href),
  2306. e.href
  2307. ? this._renderImage(e.href, i)
  2308. : this._renderImage(e.imageData, i, e.contentType));
  2309. },
  2310. this
  2311. )
  2312. : ((t.f = "image"),
  2313. (e = this.options.url + "export" + g.Util.getParamString(t)),
  2314. this.options.proxy && (e = this.options.proxy + "?" + e),
  2315. this._renderImage(e, i));
  2316. },
  2317. });
  2318. var ft = g.Layer.extend({
  2319. options: {
  2320. cellSize: 512,
  2321. updateWhenIdle: g.Browser.mobile,
  2322. updateInterval: 150,
  2323. noWrap: !1,
  2324. keepBuffer: 1.5,
  2325. },
  2326. initialize: function (t) {
  2327. g.Util.setOptions(this, t);
  2328. },
  2329. onAdd: function (t) {
  2330. (this._cells = {}),
  2331. (this._activeCells = {}),
  2332. this._resetView(),
  2333. this._update();
  2334. },
  2335. onRemove: function (t) {
  2336. this._removeAllCells(), (this._cellZoom = void 0);
  2337. },
  2338. isLoading: function () {
  2339. return this._loading;
  2340. },
  2341. redraw: function () {
  2342. return this._map && (this._removeAllCells(), this._update()), this;
  2343. },
  2344. getEvents: function () {
  2345. var t = {
  2346. viewprereset: this._invalidateAll,
  2347. viewreset: this._resetView,
  2348. zoom: this._resetView,
  2349. moveend: this._onMoveEnd,
  2350. };
  2351. return (
  2352. this.options.updateWhenIdle ||
  2353. (this._onMove ||
  2354. (this._onMove = g.Util.throttle(
  2355. this._onMoveEnd,
  2356. this.options.updateInterval,
  2357. this
  2358. )),
  2359. (t.move = this._onMove)),
  2360. t
  2361. );
  2362. },
  2363. createCell: function () {
  2364. return document.createElement("div");
  2365. },
  2366. removeCell: function () {},
  2367. reuseCell: function () {},
  2368. cellLeave: function () {},
  2369. cellEnter: function () {},
  2370. getCellSize: function () {
  2371. var t = this.options.cellSize;
  2372. return t instanceof g.Point ? t : new g.Point(t, t);
  2373. },
  2374. _pruneCells: function () {
  2375. if (this._map) {
  2376. var t, e, i;
  2377. for (t in this._cells) (i = this._cells[t]).retain = i.current;
  2378. for (t in this._cells) {
  2379. (i = this._cells[t]).current &&
  2380. !i.active &&
  2381. ((e = i.coords),
  2382. this._retainParent(e.x, e.y, e.z, e.z - 5) ||
  2383. this._retainChildren(e.x, e.y, e.z, e.z + 2));
  2384. }
  2385. for (t in this._cells) this._cells[t].retain || this._removeCell(t);
  2386. }
  2387. },
  2388. _removeAllCells: function () {
  2389. for (var t in this._cells) this._removeCell(t);
  2390. },
  2391. _invalidateAll: function () {
  2392. this._removeAllCells(), (this._cellZoom = void 0);
  2393. },
  2394. _retainParent: function (t, e, i, s) {
  2395. var r = Math.floor(t / 2),
  2396. o = Math.floor(e / 2),
  2397. n = i - 1,
  2398. a = new g.Point(+r, +o);
  2399. a.z = +n;
  2400. var l = this._cellCoordsToKey(a),
  2401. u = this._cells[l];
  2402. return u && u.active
  2403. ? (u.retain = !0)
  2404. : (u && u.loaded && (u.retain = !0),
  2405. s < n && this._retainParent(r, o, n, s));
  2406. },
  2407. _retainChildren: function (t, e, i, s) {
  2408. for (var r = 2 * t; r < 2 * t + 2; r++)
  2409. for (var o = 2 * e; o < 2 * e + 2; o++) {
  2410. var n = new g.Point(r, o);
  2411. n.z = i + 1;
  2412. var a = this._cellCoordsToKey(n),
  2413. l = this._cells[a];
  2414. l && l.active
  2415. ? (l.retain = !0)
  2416. : (l && l.loaded && (l.retain = !0),
  2417. i + 1 < s && this._retainChildren(r, o, i + 1, s));
  2418. }
  2419. },
  2420. _resetView: function (t) {
  2421. var e = t && (t.pinch || t.flyTo);
  2422. e || this._setView(this._map.getCenter(), this._map.getZoom(), e, e);
  2423. },
  2424. _setView: function (t, e, i, s) {
  2425. var r = Math.round(e);
  2426. s ||
  2427. ((this._cellZoom = r),
  2428. this._abortLoading && this._abortLoading(),
  2429. this._resetGrid(),
  2430. void 0 !== r && this._update(t),
  2431. i || this._pruneCells(),
  2432. (this._noPrune = !!i));
  2433. },
  2434. _resetGrid: function () {
  2435. var t = this._map,
  2436. e = t.options.crs,
  2437. i = (this._cellSize = this.getCellSize()),
  2438. s = this._cellZoom,
  2439. r = this._map.getPixelWorldBounds(this._cellZoom);
  2440. r && (this._globalCellRange = this._pxBoundsToCellRange(r)),
  2441. (this._wrapX = e.wrapLng &&
  2442. !this.options.noWrap && [
  2443. Math.floor(t.project([0, e.wrapLng[0]], s).x / i.x),
  2444. Math.ceil(t.project([0, e.wrapLng[1]], s).x / i.y),
  2445. ]),
  2446. (this._wrapY = e.wrapLat &&
  2447. !this.options.noWrap && [
  2448. Math.floor(t.project([e.wrapLat[0], 0], s).y / i.x),
  2449. Math.ceil(t.project([e.wrapLat[1], 0], s).y / i.y),
  2450. ]);
  2451. },
  2452. _onMoveEnd: function (t) {
  2453. (t && (t.pinch || t.flyTo)) ||
  2454. !this._map ||
  2455. this._map._animatingZoom ||
  2456. this._update();
  2457. },
  2458. _getCelldPixelBounds: function (t) {
  2459. var e = this._map,
  2460. i = e._animatingZoom
  2461. ? Math.max(e._animateToZoom, e.getZoom())
  2462. : e.getZoom(),
  2463. s = e.getZoomScale(i, this._cellZoom),
  2464. r = e.project(t, this._cellZoom).floor(),
  2465. o = e.getSize().divideBy(2 * s);
  2466. return new g.Bounds(r.subtract(o), r.add(o));
  2467. },
  2468. _update: function (t) {
  2469. var e = this._map;
  2470. if (e) {
  2471. var i = Math.round(e.getZoom());
  2472. void 0 === t && (t = e.getCenter());
  2473. var s = this._getCelldPixelBounds(t),
  2474. r = this._pxBoundsToCellRange(s),
  2475. o = r.getCenter(),
  2476. n = [],
  2477. a = this.options.keepBuffer,
  2478. l = new g.Bounds(
  2479. r.getBottomLeft().subtract([a, -a]),
  2480. r.getTopRight().add([a, -a])
  2481. );
  2482. if (
  2483. !(
  2484. isFinite(r.min.x) &&
  2485. isFinite(r.min.y) &&
  2486. isFinite(r.max.x) &&
  2487. isFinite(r.max.y)
  2488. )
  2489. )
  2490. throw new Error("Attempted to load an infinite number of cells");
  2491. for (var u in this._cells) {
  2492. var h = this._cells[u].coords;
  2493. (h.z === this._cellZoom && l.contains(new g.Point(h.x, h.y))) ||
  2494. (this._cells[u].current = !1);
  2495. }
  2496. if (1 < Math.abs(i - this._cellZoom)) this._setView(t, i);
  2497. else {
  2498. for (var c = r.min.y; c <= r.max.y; c++)
  2499. for (var p = r.min.x; p <= r.max.x; p++) {
  2500. var d,
  2501. m = new g.Point(p, c);
  2502. (m.z = this._cellZoom),
  2503. this._isValidCell(m) &&
  2504. ((d = this._cells[this._cellCoordsToKey(m)])
  2505. ? (d.current = !0)
  2506. : n.push(m));
  2507. }
  2508. if (
  2509. (n.sort(function (t, e) {
  2510. return t.distanceTo(o) - e.distanceTo(o);
  2511. }),
  2512. 0 !== n.length)
  2513. )
  2514. for (
  2515. this._loading || (this._loading = !0), p = 0;
  2516. p < n.length;
  2517. p++
  2518. ) {
  2519. var f = this._cellCoordsToKey(n[p]),
  2520. y = this._keyToCellCoords(f);
  2521. this._activeCells[y]
  2522. ? this._reuseCell(n[p])
  2523. : this._createCell(n[p]);
  2524. }
  2525. }
  2526. }
  2527. },
  2528. _isValidCell: function (t) {
  2529. var e = this._map.options.crs;
  2530. if (!e.infinite) {
  2531. var i = this._globalCellRange;
  2532. if (
  2533. (!e.wrapLng && (t.x < i.min.x || t.x > i.max.x)) ||
  2534. (!e.wrapLat && (t.y < i.min.y || t.y > i.max.y))
  2535. )
  2536. return !1;
  2537. }
  2538. if (!this.options.bounds) return !0;
  2539. var s = this._cellCoordsToBounds(t);
  2540. return g.toLatLngBounds(this.options.bounds).overlaps(s);
  2541. },
  2542. _keyToBounds: function (t) {
  2543. return this._cellCoordsToBounds(this._keyToCellCoords(t));
  2544. },
  2545. _cellCoordsToNwSe: function (t) {
  2546. var e = this._map,
  2547. i = this.getCellSize(),
  2548. s = t.scaleBy(i),
  2549. r = s.add(i);
  2550. return [e.unproject(s, t.z), e.unproject(r, t.z)];
  2551. },
  2552. _cellCoordsToBounds: function (t) {
  2553. var e = this._cellCoordsToNwSe(t),
  2554. i = new g.LatLngBounds(e[0], e[1]);
  2555. return this.options.noWrap || (i = this._map.wrapLatLngBounds(i)), i;
  2556. },
  2557. _cellCoordsToKey: function (t) {
  2558. return t.x + ":" + t.y + ":" + t.z;
  2559. },
  2560. _keyToCellCoords: function (t) {
  2561. var e = t.split(":"),
  2562. i = new g.Point(+e[0], +e[1]);
  2563. return (i.z = +e[2]), i;
  2564. },
  2565. _removeCell: function (t) {
  2566. var e,
  2567. i,
  2568. s,
  2569. r = this._cells[t];
  2570. r &&
  2571. ((e = this._keyToCellCoords(t)),
  2572. (i = this._wrapCoords(e)),
  2573. (s = this._cellCoordsToBounds(this._wrapCoords(e))),
  2574. (r.current = !1),
  2575. delete this._cells[t],
  2576. (this._activeCells[t] = r),
  2577. this.cellLeave(s, i, t),
  2578. this.fire("cellleave", { key: t, coords: i, bounds: s }));
  2579. },
  2580. _reuseCell: function (t) {
  2581. var e = this._cellCoordsToKey(t);
  2582. (this._cells[e] = this._activeCells[e]), (this._cells[e].current = !0);
  2583. var i = this._wrapCoords(t),
  2584. s = this._cellCoordsToBounds(this._wrapCoords(t));
  2585. this.cellEnter(s, i, e),
  2586. this.fire("cellenter", { key: e, coords: i, bounds: s });
  2587. },
  2588. _createCell: function (t) {
  2589. var e = this._cellCoordsToKey(t),
  2590. i = this._wrapCoords(t),
  2591. s = this._cellCoordsToBounds(this._wrapCoords(t));
  2592. this.createCell(s, i, e),
  2593. this.fire("cellcreate", { key: e, coords: i, bounds: s }),
  2594. (this._cells[e] = { coords: t, current: !0 }),
  2595. g.Util.requestAnimFrame(this._pruneCells, this);
  2596. },
  2597. _cellReady: function (t, e, i) {
  2598. var s = this._cellCoordsToKey(t);
  2599. (i = this._cells[s]) && ((i.loaded = +new Date()), (i.active = !0));
  2600. },
  2601. _getCellPos: function (t) {
  2602. return t.scaleBy(this.getCellSize());
  2603. },
  2604. _wrapCoords: function (t) {
  2605. var e = new g.Point(
  2606. this._wrapX ? g.Util.wrapNum(t.x, this._wrapX) : t.x,
  2607. this._wrapY ? g.Util.wrapNum(t.y, this._wrapY) : t.y
  2608. );
  2609. return (e.z = t.z), e;
  2610. },
  2611. _pxBoundsToCellRange: function (t) {
  2612. var e = this.getCellSize();
  2613. return new g.Bounds(
  2614. t.min.unscaleBy(e).floor(),
  2615. t.max.unscaleBy(e).ceil().subtract([1, 1])
  2616. );
  2617. },
  2618. });
  2619. function yt(t) {
  2620. this.values = [].concat(t || []);
  2621. }
  2622. (yt.prototype.query = function (t) {
  2623. var e = this.getIndex(t);
  2624. return this.values[e];
  2625. }),
  2626. (yt.prototype.getIndex = function (t) {
  2627. this.dirty && this.sort();
  2628. for (var e, i, s = 0, r = this.values.length - 1; s <= r; )
  2629. if (
  2630. ((e = ((s + r) / 2) | 0),
  2631. +(i = this.values[Math.round(e)]).value < +t)
  2632. )
  2633. s = 1 + e;
  2634. else {
  2635. if (!(+i.value > +t)) return e;
  2636. r = e - 1;
  2637. }
  2638. return Math.abs(~r);
  2639. }),
  2640. (yt.prototype.between = function (t, e) {
  2641. var i = this.getIndex(t),
  2642. s = this.getIndex(e);
  2643. if (0 === i && 0 === s) return [];
  2644. for (; this.values[i - 1] && this.values[i - 1].value === t; ) i--;
  2645. for (; this.values[s + 1] && this.values[s + 1].value === e; ) s++;
  2646. return (
  2647. this.values[s] &&
  2648. this.values[s].value === e &&
  2649. this.values[s + 1] &&
  2650. s++,
  2651. this.values.slice(i, s)
  2652. );
  2653. }),
  2654. (yt.prototype.insert = function (t) {
  2655. return this.values.splice(this.getIndex(t.value), 0, t), this;
  2656. }),
  2657. (yt.prototype.bulkAdd = function (t, e) {
  2658. return (
  2659. (this.values = this.values.concat([].concat(t || []))),
  2660. e ? this.sort() : (this.dirty = !0),
  2661. this
  2662. );
  2663. }),
  2664. (yt.prototype.sort = function () {
  2665. return (
  2666. this.values
  2667. .sort(function (t, e) {
  2668. return e.value - t.value;
  2669. })
  2670. .reverse(),
  2671. (this.dirty = !1),
  2672. this
  2673. );
  2674. });
  2675. var gt = ft.extend({
  2676. options: {
  2677. attribution: null,
  2678. where: "1=1",
  2679. fields: ["*"],
  2680. from: !1,
  2681. to: !1,
  2682. timeField: !1,
  2683. timeFilterMode: "server",
  2684. simplifyFactor: 0,
  2685. precision: 6,
  2686. fetchAllFeatures: !1,
  2687. },
  2688. initialize: function (t) {
  2689. if (
  2690. (ft.prototype.initialize.call(this, t),
  2691. (t = U(t)),
  2692. (t = g.Util.setOptions(this, t)),
  2693. (this.service = at(t)),
  2694. this.service.addEventParent(this),
  2695. "*" !== this.options.fields[0])
  2696. ) {
  2697. for (var e = !1, i = 0; i < this.options.fields.length; i++)
  2698. this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i) &&
  2699. (e = !0);
  2700. !1 === e &&
  2701. m(
  2702. "no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly."
  2703. );
  2704. }
  2705. this.options.timeField.start && this.options.timeField.end
  2706. ? ((this._startTimeIndex = new yt()), (this._endTimeIndex = new yt()))
  2707. : this.options.timeField && (this._timeIndex = new yt()),
  2708. (this._cache = {}),
  2709. (this._currentSnapshot = []),
  2710. (this._activeRequests = 0);
  2711. },
  2712. onAdd: function (r) {
  2713. return (
  2714. E(r),
  2715. this.service.metadata(function (t, e) {
  2716. var i, s;
  2717. t ||
  2718. ((i = e.supportedQueryFormats),
  2719. ((s = !1) !== this.service.options.isModern &&
  2720. !this.options.fetchAllFeatures) ||
  2721. (s = !0),
  2722. !s &&
  2723. i &&
  2724. -1 !== i.indexOf("geoJSON") &&
  2725. (this.service.options.isModern = !0),
  2726. e.objectIdField &&
  2727. (this.service.options.idAttribute = e.objectIdField),
  2728. !this.options.attribution &&
  2729. r.attributionControl &&
  2730. e.copyrightText &&
  2731. ((this.options.attribution = e.copyrightText),
  2732. r.attributionControl.addAttribution(this.getAttribution())));
  2733. }, this),
  2734. r.on("zoomend", this._handleZoomChange, this),
  2735. ft.prototype.onAdd.call(this, r)
  2736. );
  2737. },
  2738. onRemove: function (t) {
  2739. return (
  2740. B(t),
  2741. t.off("zoomend", this._handleZoomChange, this),
  2742. ft.prototype.onRemove.call(this, t)
  2743. );
  2744. },
  2745. getAttribution: function () {
  2746. return this.options.attribution;
  2747. },
  2748. createCell: function (t, e) {
  2749. this._visibleZoom() && this._requestFeatures(t, e);
  2750. },
  2751. _requestFeatures: function (s, r, o, n) {
  2752. this._activeRequests++, (n = n || 0);
  2753. var a = this.options.where;
  2754. return (
  2755. 1 === this._activeRequests && this.fire("loading", { bounds: s }, !0),
  2756. this._buildQuery(s, n).run(function (t, e, i) {
  2757. i && i.exceededTransferLimit && this.fire("drawlimitexceeded"),
  2758. this.options.where === a &&
  2759. (!t &&
  2760. e &&
  2761. e.features.length &&
  2762. g.Util.requestAnimFrame(
  2763. g.Util.bind(function () {
  2764. this._addFeatures(e.features, r),
  2765. this._postProcessFeatures(s);
  2766. }, this)
  2767. ),
  2768. t || !e || e.features.length || this._postProcessFeatures(s),
  2769. t && this._postProcessFeatures(s),
  2770. o && o.call(this, t, e),
  2771. i &&
  2772. (i.exceededTransferLimit ||
  2773. (i.properties && i.properties.exceededTransferLimit)) &&
  2774. this.options.fetchAllFeatures &&
  2775. this._requestFeatures(s, r, o, n + e.features.length));
  2776. }, this)
  2777. );
  2778. },
  2779. _postProcessFeatures: function (t) {
  2780. this._activeRequests--,
  2781. this._activeRequests <= 0 && this.fire("load", { bounds: t });
  2782. },
  2783. _cacheKey: function (t) {
  2784. return t.z + ":" + t.x + ":" + t.y;
  2785. },
  2786. _addFeatures: function (t, e) {
  2787. var i;
  2788. e && ((i = this._cacheKey(e)), (this._cache[i] = this._cache[i] || []));
  2789. for (var s = t.length - 1; 0 <= s; s--) {
  2790. var r = t[s].id;
  2791. -1 === this._currentSnapshot.indexOf(r) &&
  2792. this._currentSnapshot.push(r),
  2793. void 0 !== i &&
  2794. -1 === this._cache[i].indexOf(r) &&
  2795. this._cache[i].push(r);
  2796. }
  2797. this.options.timeField && this._buildTimeIndexes(t),
  2798. this.createLayers(t);
  2799. },
  2800. _buildQuery: function (t, e) {
  2801. var i = this.service
  2802. .query()
  2803. .intersects(t)
  2804. .where(this.options.where)
  2805. .fields(this.options.fields)
  2806. .precision(this.options.precision);
  2807. return (
  2808. this.options.fetchAllFeatures &&
  2809. !isNaN(parseInt(e)) &&
  2810. (i = i.offset(e)),
  2811. (i.params.resultType = "tile"),
  2812. this.options.requestParams &&
  2813. g.Util.extend(i.params, this.options.requestParams),
  2814. this.options.simplifyFactor &&
  2815. i.simplify(this._map, this.options.simplifyFactor),
  2816. "server" === this.options.timeFilterMode &&
  2817. this.options.from &&
  2818. this.options.to &&
  2819. i.between(this.options.from, this.options.to),
  2820. i
  2821. );
  2822. },
  2823. setWhere: function (s, r, o) {
  2824. this.options.where = s && s.length ? s : "1=1";
  2825. for (
  2826. var n = [],
  2827. a = [],
  2828. l = 0,
  2829. u = null,
  2830. t = g.Util.bind(function (t, e) {
  2831. if ((t && (u = t), e))
  2832. for (var i = e.features.length - 1; 0 <= i; i--)
  2833. a.push(e.features[i].id);
  2834. --l <= 0 &&
  2835. this._visibleZoom() &&
  2836. s === this.options.where &&
  2837. ((this._currentSnapshot = a),
  2838. g.Util.requestAnimFrame(
  2839. g.Util.bind(function () {
  2840. this.removeLayers(n), this.addLayers(a), r && r.call(o, u);
  2841. }, this)
  2842. ));
  2843. }, this),
  2844. e = this._currentSnapshot.length - 1;
  2845. 0 <= e;
  2846. e--
  2847. )
  2848. n.push(this._currentSnapshot[e]);
  2849. for (var i in ((this._cache = {}), this._cells)) {
  2850. l++;
  2851. var h = this._keyToCellCoords(i),
  2852. c = this._cellCoordsToBounds(h);
  2853. this._requestFeatures(c, h, t);
  2854. }
  2855. return this;
  2856. },
  2857. getWhere: function () {
  2858. return this.options.where;
  2859. },
  2860. getTimeRange: function () {
  2861. return [this.options.from, this.options.to];
  2862. },
  2863. setTimeRange: function (e, i, s, r) {
  2864. var o = this.options.from,
  2865. n = this.options.to,
  2866. a = 0,
  2867. l = null,
  2868. t = g.Util.bind(function (t) {
  2869. t && (l = t),
  2870. this._filterExistingFeatures(o, n, e, i),
  2871. a--,
  2872. s && a <= 0 && s.call(r, l);
  2873. }, this);
  2874. if (
  2875. ((this.options.from = e),
  2876. (this.options.to = i),
  2877. this._filterExistingFeatures(o, n, e, i),
  2878. "server" === this.options.timeFilterMode)
  2879. )
  2880. for (var u in this._cells) {
  2881. a++;
  2882. var h = this._keyToCellCoords(u),
  2883. c = this._cellCoordsToBounds(h);
  2884. this._requestFeatures(c, h, t);
  2885. }
  2886. return this;
  2887. },
  2888. refresh: function () {
  2889. this.setWhere(this.options.where);
  2890. },
  2891. _filterExistingFeatures: function (t, e, i, s) {
  2892. var r =
  2893. t && e ? this._getFeaturesInTimeRange(t, e) : this._currentSnapshot,
  2894. o = this._getFeaturesInTimeRange(i, s);
  2895. if (o.indexOf)
  2896. for (var n = 0; n < o.length; n++) {
  2897. var a = r.indexOf(o[n]);
  2898. 0 <= a && r.splice(a, 1);
  2899. }
  2900. g.Util.requestAnimFrame(
  2901. g.Util.bind(function () {
  2902. this.removeLayers(r), this.addLayers(o);
  2903. }, this)
  2904. );
  2905. },
  2906. _getFeaturesInTimeRange: function (t, e) {
  2907. var i = [];
  2908. if (this.options.timeField.start && this.options.timeField.end)
  2909. var s = this._startTimeIndex.between(t, e),
  2910. r = this._endTimeIndex.between(t, e),
  2911. o = s.concat(r);
  2912. else {
  2913. if (!this._timeIndex)
  2914. return (
  2915. m(
  2916. "You must set timeField in the layer constructor in order to manipulate the start and end time filter."
  2917. ),
  2918. []
  2919. );
  2920. o = this._timeIndex.between(t, e);
  2921. }
  2922. for (var n = o.length - 1; 0 <= n; n--) i.push(o[n].id);
  2923. return i;
  2924. },
  2925. _buildTimeIndexes: function (t) {
  2926. var e;
  2927. if (this.options.timeField.start && this.options.timeField.end) {
  2928. for (var i = [], s = [], r = t.length - 1; 0 <= r; r--)
  2929. (e = t[r]),
  2930. i.push({
  2931. id: e.id,
  2932. value: new Date(e.properties[this.options.timeField.start]),
  2933. }),
  2934. s.push({
  2935. id: e.id,
  2936. value: new Date(e.properties[this.options.timeField.end]),
  2937. });
  2938. this._startTimeIndex.bulkAdd(i), this._endTimeIndex.bulkAdd(s);
  2939. } else {
  2940. var o = [];
  2941. for (r = t.length - 1; 0 <= r; r--)
  2942. (e = t[r]),
  2943. o.push({
  2944. id: e.id,
  2945. value: new Date(e.properties[this.options.timeField]),
  2946. });
  2947. this._timeIndex.bulkAdd(o);
  2948. }
  2949. },
  2950. _featureWithinTimeRange: function (t) {
  2951. if (!this.options.from || !this.options.to) return !0;
  2952. var e = +this.options.from.valueOf(),
  2953. i = +this.options.to.valueOf();
  2954. if ("string" == typeof this.options.timeField) {
  2955. var s = +t.properties[this.options.timeField];
  2956. return e <= s && s <= i;
  2957. }
  2958. if (this.options.timeField.start && this.options.timeField.end) {
  2959. var r = +t.properties[this.options.timeField.start],
  2960. o = +t.properties[this.options.timeField.end];
  2961. return (e <= r && r <= i) || (e <= o && o <= i) || (r <= e && i <= o);
  2962. }
  2963. },
  2964. _visibleZoom: function () {
  2965. if (!this._map) return !1;
  2966. var t = this._map.getZoom();
  2967. return !(t > this.options.maxZoom || t < this.options.minZoom);
  2968. },
  2969. _handleZoomChange: function () {
  2970. if (this._visibleZoom())
  2971. for (var t in this._cells) {
  2972. var e = this._cells[t].coords,
  2973. i = this._cacheKey(e);
  2974. this._cache[i] && this.addLayers(this._cache[i]);
  2975. }
  2976. else
  2977. this.removeLayers(this._currentSnapshot),
  2978. (this._currentSnapshot = []);
  2979. },
  2980. authenticate: function (t) {
  2981. return this.service.authenticate(t), this;
  2982. },
  2983. metadata: function (t, e) {
  2984. return this.service.metadata(t, e), this;
  2985. },
  2986. query: function () {
  2987. return this.service.query();
  2988. },
  2989. _getMetadata: function (i) {
  2990. this._metadata
  2991. ? i(void 0, this._metadata)
  2992. : this.metadata(
  2993. g.Util.bind(function (t, e) {
  2994. (this._metadata = e), i(t, this._metadata);
  2995. }, this)
  2996. );
  2997. },
  2998. addFeature: function (t, e, i) {
  2999. this.addFeatures(t, e, i);
  3000. },
  3001. addFeatures: function (e, o, n) {
  3002. this._getMetadata(
  3003. g.Util.bind(function (t, s) {
  3004. var r;
  3005. t
  3006. ? o && o.call(this, t, null)
  3007. : ((r = e.features ? e.features : [e]),
  3008. this.service.addFeatures(
  3009. e,
  3010. g.Util.bind(function (t, e) {
  3011. if (!t) {
  3012. for (var i = r.length - 1; 0 <= i; i--)
  3013. (r[i].properties[s.objectIdField] =
  3014. 1 < r.length ? e[i].objectId : e.objectId),
  3015. (r[i].id = 1 < r.length ? e[i].objectId : e.objectId);
  3016. this._addFeatures(r);
  3017. }
  3018. o && o.call(n, t, e);
  3019. }, this)
  3020. ));
  3021. }, this)
  3022. );
  3023. },
  3024. updateFeature: function (t, e, i) {
  3025. this.updateFeatures(t, e, i);
  3026. },
  3027. updateFeatures: function (t, s, r) {
  3028. var o = t.features ? t.features : [t];
  3029. this.service.updateFeatures(
  3030. t,
  3031. function (t, e) {
  3032. if (!t) {
  3033. for (var i = o.length - 1; 0 <= i; i--)
  3034. this.removeLayers([o[i].id], !0);
  3035. this._addFeatures(o);
  3036. }
  3037. s && s.call(r, t, e);
  3038. },
  3039. this
  3040. );
  3041. },
  3042. deleteFeature: function (t, e, i) {
  3043. this.deleteFeatures(t, e, i);
  3044. },
  3045. deleteFeatures: function (t, r, o) {
  3046. return this.service.deleteFeatures(
  3047. t,
  3048. function (t, e) {
  3049. var i = e.length ? e : [e];
  3050. if (!t && 0 < i.length)
  3051. for (var s = i.length - 1; 0 <= s; s--)
  3052. this.removeLayers([i[s].objectId], !0);
  3053. r && r.call(o, t, e);
  3054. },
  3055. this
  3056. );
  3057. },
  3058. }),
  3059. _t = gt.extend({
  3060. options: { cacheLayers: !0 },
  3061. initialize: function (t) {
  3062. t.apikey && (t.token = t.apikey),
  3063. gt.prototype.initialize.call(this, t),
  3064. (this._originalStyle = this.options.style),
  3065. (this._layers = {});
  3066. },
  3067. onRemove: function (t) {
  3068. for (var e in this._layers)
  3069. t.removeLayer(this._layers[e]),
  3070. this.fire(
  3071. "removefeature",
  3072. { feature: this._layers[e].feature, permanent: !1 },
  3073. !0
  3074. );
  3075. return gt.prototype.onRemove.call(this, t);
  3076. },
  3077. createNewLayer: function (t) {
  3078. var e = g.GeoJSON.geometryToLayer(t, this.options);
  3079. return e && (e.defaultOptions = e.options), e;
  3080. },
  3081. _updateLayer: function (t, e) {
  3082. var i = [],
  3083. s = this.options.coordsToLatLng || g.GeoJSON.coordsToLatLng;
  3084. switch (
  3085. (e.properties && (t.feature.properties = e.properties),
  3086. e.geometry.type)
  3087. ) {
  3088. case "Point":
  3089. (i = g.GeoJSON.coordsToLatLng(e.geometry.coordinates)),
  3090. t.setLatLng(i);
  3091. break;
  3092. case "LineString":
  3093. (i = g.GeoJSON.coordsToLatLngs(e.geometry.coordinates, 0, s)),
  3094. t.setLatLngs(i);
  3095. break;
  3096. case "MultiLineString":
  3097. case "Polygon":
  3098. (i = g.GeoJSON.coordsToLatLngs(e.geometry.coordinates, 1, s)),
  3099. t.setLatLngs(i);
  3100. break;
  3101. case "MultiPolygon":
  3102. (i = g.GeoJSON.coordsToLatLngs(e.geometry.coordinates, 2, s)),
  3103. t.setLatLngs(i);
  3104. }
  3105. },
  3106. createLayers: function (t) {
  3107. for (var e = t.length - 1; 0 <= e; e--) {
  3108. var i,
  3109. s = t[e],
  3110. r = this._layers[s.id];
  3111. !this._visibleZoom() ||
  3112. !r ||
  3113. this._map.hasLayer(r) ||
  3114. (this.options.timeField && !this._featureWithinTimeRange(s)) ||
  3115. (this._map.addLayer(r),
  3116. this.fire("addfeature", { feature: r.feature }, !0)),
  3117. r &&
  3118. 0 < this.options.simplifyFactor &&
  3119. (r.setLatLngs || r.setLatLng) &&
  3120. this._updateLayer(r, s),
  3121. r ||
  3122. ((i = this.createNewLayer(s))
  3123. ? ((i.feature = s),
  3124. i.addEventParent(this),
  3125. this.options.onEachFeature &&
  3126. this.options.onEachFeature(i.feature, i),
  3127. (this._layers[i.feature.id] = i),
  3128. this.setFeatureStyle(i.feature.id, this.options.style),
  3129. this.fire("createfeature", { feature: i.feature }, !0),
  3130. this._visibleZoom() &&
  3131. (!this.options.timeField ||
  3132. (this.options.timeField &&
  3133. this._featureWithinTimeRange(s))) &&
  3134. this._map.addLayer(i))
  3135. : m("invalid GeoJSON encountered"));
  3136. }
  3137. },
  3138. addLayers: function (t) {
  3139. for (var e = t.length - 1; 0 <= e; e--) {
  3140. var i = this._layers[t[e]];
  3141. !i ||
  3142. (this.options.timeField &&
  3143. !this._featureWithinTimeRange(i.feature)) ||
  3144. (this._map.addLayer(i),
  3145. this.fire("addfeature", { feature: i.feature }, !0));
  3146. }
  3147. },
  3148. removeLayers: function (t, e) {
  3149. for (var i = t.length - 1; 0 <= i; i--) {
  3150. var s = t[i],
  3151. r = this._layers[s];
  3152. r &&
  3153. (this.fire(
  3154. "removefeature",
  3155. { feature: r.feature, permanent: e },
  3156. !0
  3157. ),
  3158. this._map.removeLayer(r)),
  3159. r && e && delete this._layers[s];
  3160. }
  3161. },
  3162. cellEnter: function (t, s) {
  3163. this._visibleZoom() &&
  3164. !this._zooming &&
  3165. this._map &&
  3166. g.Util.requestAnimFrame(
  3167. g.Util.bind(function () {
  3168. var t = this._cacheKey(s),
  3169. e = this._cellCoordsToKey(s),
  3170. i = this._cache[t];
  3171. this._activeCells[e] && i && this.addLayers(i);
  3172. }, this)
  3173. );
  3174. },
  3175. cellLeave: function (t, a) {
  3176. this._zooming ||
  3177. g.Util.requestAnimFrame(
  3178. g.Util.bind(function () {
  3179. if (this._map) {
  3180. var t = this._cacheKey(a),
  3181. e = this._cellCoordsToKey(a),
  3182. i = this._cache[t],
  3183. s = this._map.getBounds();
  3184. if (!this._activeCells[e] && i) {
  3185. for (var r = !0, o = 0; o < i.length; o++) {
  3186. var n = this._layers[i[o]];
  3187. n && n.getBounds && s.intersects(n.getBounds()) && (r = !1);
  3188. }
  3189. r && this.removeLayers(i, !this.options.cacheLayers),
  3190. !this.options.cacheLayers &&
  3191. r &&
  3192. (delete this._cache[t],
  3193. delete this._cells[e],
  3194. delete this._activeCells[e]);
  3195. }
  3196. }
  3197. }, this)
  3198. );
  3199. },
  3200. resetStyle: function () {
  3201. return (
  3202. (this.options.style = this._originalStyle),
  3203. this.eachFeature(function (t) {
  3204. this.resetFeatureStyle(t.feature.id);
  3205. }, this),
  3206. this
  3207. );
  3208. },
  3209. setStyle: function (e) {
  3210. return (
  3211. (this.options.style = e),
  3212. this.eachFeature(function (t) {
  3213. this.setFeatureStyle(t.feature.id, e);
  3214. }, this),
  3215. this
  3216. );
  3217. },
  3218. resetFeatureStyle: function (t) {
  3219. var e = this._layers[t],
  3220. i = this._originalStyle || g.Path.prototype.options;
  3221. return (
  3222. e &&
  3223. (g.Util.extend(e.options, e.defaultOptions),
  3224. this.setFeatureStyle(t, i)),
  3225. this
  3226. );
  3227. },
  3228. setFeatureStyle: function (t, e) {
  3229. var i = this._layers[t];
  3230. return (
  3231. "function" == typeof e && (e = e(i.feature)),
  3232. i.setStyle && i.setStyle(e),
  3233. this
  3234. );
  3235. },
  3236. eachActiveFeature: function (t, e) {
  3237. if (this._map) {
  3238. var i = this._map.getBounds();
  3239. for (var s in this._layers)
  3240. -1 !== this._currentSnapshot.indexOf(this._layers[s].feature.id) &&
  3241. (("function" == typeof this._layers[s].getLatLng &&
  3242. i.contains(this._layers[s].getLatLng())) ||
  3243. ("function" == typeof this._layers[s].getBounds &&
  3244. i.intersects(this._layers[s].getBounds()))) &&
  3245. t.call(e, this._layers[s]);
  3246. }
  3247. return this;
  3248. },
  3249. eachFeature: function (t, e) {
  3250. for (var i in this._layers) t.call(e, this._layers[i]);
  3251. return this;
  3252. },
  3253. getFeature: function (t) {
  3254. return this._layers[t];
  3255. },
  3256. bringToBack: function () {
  3257. this.eachFeature(function (t) {
  3258. t.bringToBack && t.bringToBack();
  3259. });
  3260. },
  3261. bringToFront: function () {
  3262. this.eachFeature(function (t) {
  3263. t.bringToFront && t.bringToFront();
  3264. });
  3265. },
  3266. redraw: function (t) {
  3267. return t && this._redraw(t), this;
  3268. },
  3269. _redraw: function (t) {
  3270. var e,
  3271. i,
  3272. s = this._layers[t],
  3273. r = s.feature;
  3274. s &&
  3275. s.setIcon &&
  3276. this.options.pointToLayer &&
  3277. this.options.pointToLayer &&
  3278. ((e = this.options.pointToLayer(
  3279. r,
  3280. g.latLng(r.geometry.coordinates[1], r.geometry.coordinates[0])
  3281. ).options.icon),
  3282. s.setIcon(e)),
  3283. s &&
  3284. s.setStyle &&
  3285. this.options.pointToLayer &&
  3286. ((i = this.options.pointToLayer(
  3287. r,
  3288. g.latLng(r.geometry.coordinates[1], r.geometry.coordinates[0])
  3289. ).options),
  3290. this.setFeatureStyle(r.id, i)),
  3291. s && s.setStyle && this.options.style && this.resetStyle(r.id);
  3292. },
  3293. });
  3294. var vt = e;
  3295. (t.BasemapLayer = ut),
  3296. (t.DynamicMapLayer = mt),
  3297. (t.FeatureLayer = _t),
  3298. (t.FeatureLayerService = nt),
  3299. (t.FeatureManager = gt),
  3300. (t.Find = Q),
  3301. (t.Identify = H),
  3302. (t.IdentifyFeatures = X),
  3303. (t.IdentifyImage = $),
  3304. (t.ImageMapLayer = dt),
  3305. (t.ImageService = rt),
  3306. (t.MapService = it),
  3307. (t.Query = J),
  3308. (t.RasterLayer = pt),
  3309. (t.Service = et),
  3310. (t.Support = a),
  3311. (t.Task = W),
  3312. (t.TiledMapLayer = ht),
  3313. (t.Util = j),
  3314. (t.VERSION = vt),
  3315. (t.basemapLayer = function (t, e) {
  3316. return new ut(t, e);
  3317. }),
  3318. (t.dynamicMapLayer = function (t, e) {
  3319. return new mt(t, e);
  3320. }),
  3321. (t.featureLayer = function (t) {
  3322. return new _t(t);
  3323. }),
  3324. (t.featureLayerService = at),
  3325. (t.find = K),
  3326. (t.get = d),
  3327. (t.identify = function (t) {
  3328. return new H(t);
  3329. }),
  3330. (t.identifyFeatures = Y),
  3331. (t.identifyImage = tt),
  3332. (t.imageMapLayer = function (t, e) {
  3333. return new dt(t, e);
  3334. }),
  3335. (t.imageService = ot),
  3336. (t.mapService = st),
  3337. (t.options = r),
  3338. (t.post = o),
  3339. (t.query = V),
  3340. (t.request = c),
  3341. (t.service = function (t) {
  3342. return (t = U(t)), new et(t);
  3343. }),
  3344. (t.task = function (t) {
  3345. return (t = U(t)), new W(t);
  3346. }),
  3347. (t.tiledMapLayer = function (t, e) {
  3348. return new ht(t, e);
  3349. }),
  3350. Object.defineProperty(t, "__esModule", { value: !0 });
  3351. });
  3352. //# sourceMappingURL=esri-leaflet.js.map