vue-baidu-map-3x.es.js 164 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566
  1. import { openBlock, createElementBlock, normalizeClass, normalizeStyle, createCommentVNode, renderSlot, withDirectives, vShow, resolveComponent, Fragment, renderList, createBlock, createElementVNode } from "vue";
  2. var events = {
  3. "bm-map": [
  4. "click",
  5. "dblclick",
  6. "rightclick",
  7. "rightdblclick",
  8. "maptypechange",
  9. "mousemove",
  10. "mouseover",
  11. "mouseout",
  12. "movestart",
  13. "moving",
  14. "moveend",
  15. "zoomstart",
  16. "zoomend",
  17. "addoverlay",
  18. "addcontrol",
  19. "removecontrol",
  20. "removeoverlay",
  21. "clearoverlays",
  22. "dragstart",
  23. "dragging",
  24. "dragend",
  25. "addtilelayer",
  26. "removetilelayer",
  27. "load",
  28. "resize",
  29. "hotspotclick",
  30. "hotspotover",
  31. "hotspotout",
  32. "tilesloaded",
  33. "touchstart",
  34. "touchmove",
  35. "touchend",
  36. "longpress"
  37. ],
  38. "bm-geolocation": [
  39. "locationSuccess",
  40. "locationError"
  41. ],
  42. "bm-overview-map": [
  43. "viewchanged",
  44. "viewchanging"
  45. ],
  46. "bm-marker": [
  47. "click",
  48. "dblclick",
  49. "mousedown",
  50. "mouseup",
  51. "mouseout",
  52. "mouseover",
  53. "remove",
  54. "infowindowclose",
  55. "infowindowopen",
  56. "dragstart",
  57. "dragging",
  58. "dragend",
  59. "rightclick"
  60. ],
  61. "bm-polyline": [
  62. "click",
  63. "dblclick",
  64. "mousedown",
  65. "mouseup",
  66. "mouseout",
  67. "mouseover",
  68. "remove",
  69. "lineupdate"
  70. ],
  71. "bm-polygon": [
  72. "click",
  73. "dblclick",
  74. "mousedown",
  75. "mouseup",
  76. "mouseout",
  77. "mouseover",
  78. "remove",
  79. "lineupdate"
  80. ],
  81. "bm-circle": [
  82. "click",
  83. "dblclick",
  84. "mousedown",
  85. "mouseup",
  86. "mouseout",
  87. "mouseover",
  88. "remove",
  89. "lineupdate"
  90. ],
  91. "bm-label": [
  92. "click",
  93. "dblclick",
  94. "mousedown",
  95. "mouseup",
  96. "mouseout",
  97. "mouseover",
  98. "remove",
  99. "rightclick"
  100. ],
  101. "bm-info-window": [
  102. "close",
  103. "open",
  104. "maximize",
  105. "restore",
  106. "clickclose"
  107. ],
  108. "bm-ground": [
  109. "click",
  110. "dblclick"
  111. ],
  112. "bm-autocomplete": [
  113. "onconfirm",
  114. "onhighlight"
  115. ],
  116. "bm-point-collection": [
  117. "click",
  118. "mouseover",
  119. "mouseout"
  120. ]
  121. };
  122. function bindEvents(instance2, eventList2) {
  123. const ev = eventList2 || events[this.$options.name];
  124. ev && ev.forEach((event) => {
  125. const hasOn = event.slice(0, 2) === "on";
  126. let eventName = hasOn ? event.slice(2) : event;
  127. const listener = this.$attrs["on" + eventName.replace(eventName[0], eventName[0].toUpperCase())];
  128. listener && instance2.addEventListener(event, listener);
  129. });
  130. }
  131. function createPoint(BMap2, options = {}) {
  132. const { lng, lat } = options;
  133. return new BMap2.Point(lng, lat);
  134. }
  135. function createBounds(BMap2, options = {}) {
  136. const { sw, ne } = options;
  137. return new BMap2.Bounds(createPoint(BMap2, sw), createPoint(BMap2, ne));
  138. }
  139. function createSize(BMap2, options = {}) {
  140. const { width, height } = options;
  141. return new BMap2.Size(width, height);
  142. }
  143. function createIcon(BMap2, options = {}) {
  144. const { url, size, opts = {} } = options;
  145. let iconOption = {
  146. anchor: opts.anchor && createSize(BMap2, opts.anchor),
  147. imageSize: opts.imageSize && createSize(BMap2, opts.imageSize),
  148. imageOffset: opts.imageOffset && createSize(BMap2, opts.imageOffset),
  149. infoWindowAnchor: opts.infoWindowAnchor && createSize(BMap2, opts.infoWindowAnchor),
  150. printImageUrl: opts.printImageUrl
  151. };
  152. deleteEmptyKey(iconOption);
  153. return new BMap2.Icon(url, createSize(BMap2, size), iconOption);
  154. }
  155. function createLabel(BMap2, options = {}) {
  156. const { content, opts } = options;
  157. let labelOption = {
  158. offset: opts.offset && createSize(BMap2, opts.offset),
  159. position: opts.position && createPoint(BMap2, opts.position),
  160. enableMassClear: opts.enableMassClear
  161. };
  162. deleteEmptyKey(labelOption);
  163. return new BMap2.Label(content, labelOption);
  164. }
  165. function createSymbol(BMap2, options = {}) {
  166. const { path, opts } = options;
  167. let symbolOption = {
  168. anchor: opts.anchor && createSize(BMap2, opts.anchor),
  169. fillColor: opts.fillColor,
  170. fillOpacity: opts.fillOpacity,
  171. scale: opts.scale,
  172. rotation: opts.rotation,
  173. strokeColor: opts.strokeColor,
  174. strokeOpacity: opts.strokeOpacity,
  175. strokeWeight: opts.strokeWeight
  176. };
  177. deleteEmptyKey(symbolOption);
  178. return new BMap2.Symbol(window[path] || path, symbolOption);
  179. }
  180. function createIconSequence(BMap2, options = {}) {
  181. const { symbol, offset, repeat, fixedRotation } = options;
  182. return new BMap2.IconSequence(symbol && createSymbol(BMap2, symbol), offset, repeat, fixedRotation);
  183. }
  184. const isPoint = (obj) => obj.lng && obj.lat;
  185. const checkType = (val) => Object.prototype.toString.call(val).slice(8, -1);
  186. const getPosition = (BMap2, point) => isPoint(point) ? createPoint(BMap2, point) : point;
  187. const deleteEmptyKey = (obj) => {
  188. Object.keys(obj).forEach((key) => {
  189. if (typeof obj[key] === "undefined") {
  190. delete obj[key];
  191. }
  192. });
  193. };
  194. let config = {
  195. v: "3.0",
  196. type: "API"
  197. };
  198. const setConfig = (options = {}) => {
  199. config = Object.assign(config, options);
  200. if (!config.ak) {
  201. console.error("\u8BF7\u914D\u7F6Eak\uFF1A\u767E\u5EA6\u5730\u56FE\u5F00\u53D1\u8005\u5E73\u53F0\u7533\u8BF7\u7684\u5BC6\u94A5");
  202. }
  203. };
  204. const getConfig = () => {
  205. return config;
  206. };
  207. var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  208. var tinyEmitter = { exports: {} };
  209. function E$1() {
  210. }
  211. E$1.prototype = {
  212. on: function(name, callback, ctx) {
  213. var e = this.e || (this.e = {});
  214. (e[name] || (e[name] = [])).push({
  215. fn: callback,
  216. ctx
  217. });
  218. return this;
  219. },
  220. once: function(name, callback, ctx) {
  221. var self2 = this;
  222. function listener() {
  223. self2.off(name, listener);
  224. callback.apply(ctx, arguments);
  225. }
  226. listener._ = callback;
  227. return this.on(name, listener, ctx);
  228. },
  229. emit: function(name) {
  230. var data = [].slice.call(arguments, 1);
  231. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  232. var i = 0;
  233. var len = evtArr.length;
  234. for (i; i < len; i++) {
  235. evtArr[i].fn.apply(evtArr[i].ctx, data);
  236. }
  237. return this;
  238. },
  239. off: function(name, callback) {
  240. var e = this.e || (this.e = {});
  241. var evts = e[name];
  242. var liveEvents = [];
  243. if (evts && callback) {
  244. for (var i = 0, len = evts.length; i < len; i++) {
  245. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  246. liveEvents.push(evts[i]);
  247. }
  248. }
  249. liveEvents.length ? e[name] = liveEvents : delete e[name];
  250. return this;
  251. }
  252. };
  253. tinyEmitter.exports = E$1;
  254. tinyEmitter.exports.TinyEmitter = E$1;
  255. var E = tinyEmitter.exports;
  256. var instance = new E();
  257. var EvenBus = {
  258. $on: (...args) => instance.on(...args),
  259. $once: (...args) => instance.once(...args),
  260. $off: (...args) => instance.off(...args),
  261. $emit: (...args) => instance.emit(...args)
  262. };
  263. const methods = {
  264. "API": {
  265. "2.0": {
  266. setMapStyle: "setMapStyle",
  267. NavigationControl: "NavigationControl"
  268. },
  269. "3.0": {
  270. setMapStyle: "setMapStyleV2",
  271. NavigationControl: "NavigationControl"
  272. }
  273. },
  274. "WebGL": {
  275. setMapStyle: "setMapStyleV2",
  276. NavigationControl: "NavigationControl3D"
  277. }
  278. };
  279. const getMapMethod = (method) => {
  280. const config2 = getConfig();
  281. if (config2.type == "WebGL") {
  282. return methods[config2.type][method];
  283. } else {
  284. return methods[config2.type][config2.v][method];
  285. }
  286. };
  287. let mapLoadResolve;
  288. let mapLoadPromise = new Promise((resolve) => {
  289. mapLoadResolve = resolve;
  290. });
  291. const getBMap = () => {
  292. return mapLoadPromise;
  293. };
  294. function getParamsStrByObject(obj) {
  295. let arr = [];
  296. Object.keys(obj).forEach((key) => {
  297. arr.push(key + "=" + obj[key]);
  298. });
  299. return arr.join("&");
  300. }
  301. function getAddressByPoints(config2, aks = []) {
  302. if (!config2.location || !config2.location.length) {
  303. console.error("\u8BF7\u4F20\u5165location");
  304. }
  305. const appConfig = getConfig();
  306. if (appConfig.ak) {
  307. aks.push(appConfig.ak);
  308. }
  309. return new Promise((resolve, reject) => {
  310. if (aks.length) {
  311. let params = Object.assign({
  312. location: [],
  313. extensions_poi: 1,
  314. output: "json",
  315. coordtype: "wgs84ll",
  316. timeout: 60
  317. }, config2);
  318. let num = 0;
  319. const requestBaidu = () => {
  320. var _a;
  321. const timer = setTimeout(() => {
  322. reject(new Error("\u67E5\u8BE2\u8D85\u65F6"));
  323. }, params.timeout * 1e3);
  324. const callbackName = "baiduReverse" + Math.floor(Math.random() * 1e6);
  325. params.callback = callbackName;
  326. window[callbackName] = (res) => {
  327. var _a2;
  328. clearTimeout(timer);
  329. window[callbackName] = null;
  330. (_a2 = document.getElementById(callbackName)) == null ? void 0 : _a2.remove();
  331. if (!res.status) {
  332. resolve(res.result);
  333. } else {
  334. if (num < aks.length * 4) {
  335. num++;
  336. requestBaidu();
  337. } else {
  338. reject(new Error("\u67E5\u8BE2\u5931\u8D25"));
  339. }
  340. }
  341. };
  342. params.ak = aks[num % aks.length];
  343. let script = document.createElement("script");
  344. script.id = callbackName;
  345. script.src = `https://api.map.baidu.com/reverse_geocoding/v3/?${getParamsStrByObject(params)}`;
  346. (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
  347. };
  348. requestBaidu();
  349. } else {
  350. console.error("\u8BF7\u914D\u7F6E\u767E\u5EA6ak\uFF01");
  351. reject(new Error("\u8BF7\u914D\u7F6E\u767E\u5EA6ak\uFF01"));
  352. }
  353. });
  354. }
  355. function getPointByAddress(config2, aks = []) {
  356. if (!config2.address) {
  357. console.error("\u8BF7\u4F20\u5165address");
  358. }
  359. const appConfig = getConfig();
  360. if (appConfig.ak) {
  361. aks.push(appConfig.ak);
  362. }
  363. return new Promise((resolve, reject) => {
  364. if (aks.length) {
  365. let params = Object.assign({
  366. address: "",
  367. output: "json",
  368. timeout: 60
  369. }, config2);
  370. let num = 0;
  371. const requestBaidu = () => {
  372. var _a;
  373. const timer = setTimeout(() => {
  374. reject(new Error("\u67E5\u8BE2\u8D85\u65F6"));
  375. }, params.timeout * 1e3);
  376. const callbackName = "baidugeocoding" + Math.floor(Math.random() * 1e6);
  377. params.callback = callbackName;
  378. window[callbackName] = (res) => {
  379. var _a2;
  380. clearTimeout(timer);
  381. window[callbackName] = null;
  382. (_a2 = document.getElementById(callbackName)) == null ? void 0 : _a2.remove();
  383. if (!res.status) {
  384. resolve(res.result);
  385. } else {
  386. if (num < aks.length * 4) {
  387. num++;
  388. requestBaidu();
  389. } else {
  390. reject(new Error("\u67E5\u8BE2\u5931\u8D25"));
  391. }
  392. }
  393. };
  394. params.ak = aks[num % aks.length];
  395. let script = document.createElement("script");
  396. script.id = callbackName;
  397. script.src = `https://api.map.baidu.com/geocoding/v3/?${getParamsStrByObject(params)}`;
  398. (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
  399. };
  400. requestBaidu();
  401. } else {
  402. console.error("\u8BF7\u914D\u7F6E\u767E\u5EA6ak\uFF01");
  403. reject(new Error("\u8BF7\u914D\u7F6E\u767E\u5EA6ak\uFF01"));
  404. }
  405. });
  406. }
  407. function getPointsTransfer(config2, aks = []) {
  408. if (!config2.locations || !config2.locations.length) {
  409. console.error("\u8BF7\u4F20\u5165locations");
  410. }
  411. const appConfig = getConfig();
  412. if (appConfig.ak) {
  413. aks.push(appConfig.ak);
  414. }
  415. return new Promise((resolve, reject) => {
  416. if (aks.length) {
  417. let params = Object.assign({
  418. locations: [],
  419. from: 1,
  420. to: 5,
  421. timeout: 60
  422. }, config2);
  423. let num = 0;
  424. const requestBaidu = () => {
  425. var _a;
  426. const timer = setTimeout(() => {
  427. reject(new Error("\u67E5\u8BE2\u8D85\u65F6"));
  428. }, params.timeout * 1e3);
  429. const callbackName = "baidugeoconv" + Math.floor(Math.random() * 1e6);
  430. params.callback = callbackName;
  431. window[callbackName] = (res) => {
  432. var _a2;
  433. clearTimeout(timer);
  434. window[callbackName] = null;
  435. (_a2 = document.getElementById(callbackName)) == null ? void 0 : _a2.remove();
  436. if (!res.status) {
  437. resolve(res.result);
  438. } else {
  439. if (num < aks.length * 4) {
  440. num++;
  441. requestBaidu();
  442. } else {
  443. reject(new Error("\u67E5\u8BE2\u5931\u8D25"));
  444. }
  445. }
  446. };
  447. params.ak = aks[num % aks.length];
  448. params.coords = params.locations.join(";");
  449. let script = document.createElement("script");
  450. script.id = callbackName;
  451. script.src = `https://api.map.baidu.com/geoconv/v1/?${getParamsStrByObject(params)}`;
  452. (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
  453. };
  454. requestBaidu();
  455. } else {
  456. console.error("\u8BF7\u914D\u7F6E\u767E\u5EA6ak\uFF01");
  457. reject(new Error("\u8BF7\u914D\u7F6E\u767E\u5EA6ak\uFF01"));
  458. }
  459. });
  460. }
  461. var _export_sfc = (sfc, props) => {
  462. const target = sfc.__vccOpts || sfc;
  463. for (const [key, val] of props) {
  464. target[key] = val;
  465. }
  466. return target;
  467. };
  468. const _sfc_main$x = {
  469. name: "bm-map",
  470. inheritAttrs: false,
  471. emits: ["ready", "init", "animationed"],
  472. props: {
  473. ak: {
  474. type: String
  475. },
  476. v: {
  477. type: String
  478. },
  479. type: {
  480. type: String
  481. },
  482. center: {
  483. type: [Object, String]
  484. },
  485. zoom: {
  486. type: Number
  487. },
  488. minZoom: {
  489. type: Number
  490. },
  491. maxZoom: {
  492. type: Number
  493. },
  494. highResolution: {
  495. type: Boolean,
  496. default: true
  497. },
  498. mapClick: {
  499. type: Boolean,
  500. default: true
  501. },
  502. mapType: {
  503. type: String
  504. },
  505. dragging: {
  506. type: Boolean,
  507. default: true
  508. },
  509. scrollWheelZoom: {
  510. type: Boolean,
  511. default: false
  512. },
  513. doubleClickZoom: {
  514. type: Boolean,
  515. default: true
  516. },
  517. keyboard: {
  518. type: Boolean,
  519. default: true
  520. },
  521. inertialDragging: {
  522. type: Boolean,
  523. default: true
  524. },
  525. continuousZoom: {
  526. type: Boolean,
  527. default: true
  528. },
  529. pinchToZoom: {
  530. type: Boolean,
  531. default: true
  532. },
  533. autoResize: {
  534. type: Boolean,
  535. default: true
  536. },
  537. theme: {
  538. type: Array
  539. },
  540. mapStyle: {
  541. type: Object
  542. },
  543. hasAnimation: {
  544. type: Boolean,
  545. default: true
  546. },
  547. defaultAnimation: {
  548. type: Boolean,
  549. default: true
  550. }
  551. },
  552. watch: {
  553. center(val, oldVal) {
  554. const { map, zoom } = this;
  555. if (checkType(val) === "String" && val !== oldVal) {
  556. this.setCenterZoom(map, val, zoom);
  557. }
  558. },
  559. "center.lng"(val, oldVal) {
  560. const { BMap: BMap2, map, zoom, center } = this;
  561. if (val !== oldVal && val >= -180 && val <= 180) {
  562. this.setCenterZoom(map, new BMap2.Point(val, center.lat), zoom);
  563. }
  564. },
  565. "center.lat"(val, oldVal) {
  566. const { BMap: BMap2, map, zoom, center } = this;
  567. if (val !== oldVal && val >= -74 && val <= 74) {
  568. this.setCenterZoom(map, new BMap2.Point(center.lng, val), zoom);
  569. }
  570. },
  571. zoom(val, oldVal) {
  572. const { map } = this;
  573. if (val !== oldVal && val >= 3 && val <= 19) {
  574. map.setZoom(val);
  575. }
  576. },
  577. minZoom(val) {
  578. const { map } = this;
  579. map.setMinZoom(val);
  580. },
  581. maxZoom(val) {
  582. const { map } = this;
  583. map.setMaxZoom(val);
  584. },
  585. highResolution() {
  586. this.reset();
  587. },
  588. mapClick() {
  589. this.reset();
  590. },
  591. mapType(val) {
  592. const { map } = this;
  593. map.setMapType(window[val]);
  594. },
  595. dragging(val) {
  596. const { map } = this;
  597. val ? map.enableDragging() : map.disableDragging();
  598. },
  599. scrollWheelZoom(val) {
  600. const { map } = this;
  601. val ? map.enableScrollWheelZoom() : map.disableScrollWheelZoom();
  602. },
  603. doubleClickZoom(val) {
  604. const { map } = this;
  605. val ? map.enableDoubleClickZoom() : map.disableDoubleClickZoom();
  606. },
  607. keyboard(val) {
  608. const { map } = this;
  609. val ? map.enableKeyboard() : map.disableKeyboard();
  610. },
  611. inertialDragging(val) {
  612. const { map } = this;
  613. val ? map.enableInertialDragging() : map.disableInertialDragging();
  614. },
  615. continuousZoom(val) {
  616. const { map } = this;
  617. val ? map.enableContinuousZoom() : map.disableContinuousZoom();
  618. },
  619. pinchToZoom(val) {
  620. const { map } = this;
  621. val ? map.enablePinchToZoom() : map.disablePinchToZoom();
  622. },
  623. autoResize(val) {
  624. const { map } = this;
  625. val ? map.enableAutoResize() : map.disableAutoResize();
  626. },
  627. theme(val) {
  628. const { map } = this;
  629. map[getMapMethod("setMapStyle")]({ styleJson: val });
  630. },
  631. mapStyle: {
  632. handler(val) {
  633. const { map, theme } = this;
  634. !theme && map[getMapMethod("setMapStyle")](val);
  635. },
  636. deep: true
  637. }
  638. },
  639. methods: {
  640. setMapOptions() {
  641. const { map, minZoom, maxZoom, mapType, dragging, scrollWheelZoom, doubleClickZoom, keyboard, inertialDragging, continuousZoom, pinchToZoom, autoResize } = this;
  642. minZoom && map.setMinZoom(minZoom);
  643. maxZoom && map.setMaxZoom(maxZoom);
  644. mapType && map.setMapType(window[mapType]);
  645. dragging ? map.enableDragging() : map.disableDragging();
  646. scrollWheelZoom ? map.enableScrollWheelZoom() : map.disableScrollWheelZoom();
  647. doubleClickZoom ? map.enableDoubleClickZoom() : map.disableDoubleClickZoom();
  648. keyboard ? map.enableKeyboard() : map.disableKeyboard();
  649. inertialDragging ? map.enableInertialDragging() : map.disableInertialDragging();
  650. continuousZoom ? map.enableContinuousZoom() : map.disableContinuousZoom();
  651. pinchToZoom ? map.enablePinchToZoom() : map.disablePinchToZoom();
  652. autoResize ? map.enableAutoResize() : map.disableAutoResize();
  653. },
  654. init(BMap2) {
  655. if (this.map) {
  656. return;
  657. }
  658. let $el = this.$refs.view;
  659. if (this.$slots.default)
  660. ;
  661. const map = new BMap2.Map($el, { enableHighResolution: this.highResolution, enableMapClick: this.mapClick });
  662. this.map = map;
  663. const { setMapOptions, zoom, getCenterPoint, theme, mapStyle } = this;
  664. setMapOptions();
  665. bindEvents.call(this, map);
  666. map.reset();
  667. this.setCenterZoom(map, getCenterPoint(), zoom);
  668. theme ? map[getMapMethod("setMapStyle")]({ styleJson: theme }) : mapStyle && map[getMapMethod("setMapStyle")](mapStyle);
  669. let loadNum = 0;
  670. this.$emit("init", { BMap: BMap2, map });
  671. EvenBus.$emit("init", { BMap: BMap2, map });
  672. map.addEventListener("tilesloaded", () => {
  673. if (!loadNum) {
  674. loadNum++;
  675. this.$emit("ready", { BMap: BMap2, map });
  676. EvenBus.$emit("ready", { BMap: BMap2, map });
  677. }
  678. });
  679. map.addEventListener("loaded", () => {
  680. this.$emit("loaded", { BMap: BMap2, map });
  681. EvenBus.$emit("loaded", { BMap: BMap2, map });
  682. });
  683. },
  684. setCenterZoom(map, center, zoom) {
  685. if (getConfig().type === "WebGL") {
  686. if (!this.hasAnimation || !this.defaultAnimation) {
  687. map.setCenter(center, {
  688. noAnimation: !this.hasAnimation,
  689. callback: () => {
  690. map.setZoom(zoom, {
  691. noAnimation: !this.hasAnimation,
  692. zoomCenter: center,
  693. callback: () => {
  694. this.$emit("animationed", { BMap: this.BMap, map });
  695. }
  696. });
  697. }
  698. });
  699. } else {
  700. map.centerAndZoom(center, zoom);
  701. }
  702. } else {
  703. map.centerAndZoom(center, zoom);
  704. }
  705. },
  706. getCenterPoint() {
  707. const { center, BMap: BMap2 } = this;
  708. switch (checkType(center)) {
  709. case "String":
  710. return center;
  711. case "Object":
  712. return new BMap2.Point(center.lng, center.lat);
  713. default:
  714. return new BMap2.Point();
  715. }
  716. },
  717. initMap(BMap2) {
  718. this.BMap = BMap2;
  719. this.init(BMap2);
  720. mapLoadResolve(BMap2);
  721. },
  722. getMapScript() {
  723. if (!window.BMap) {
  724. window.BMap = {};
  725. window.BMap._preloader = new Promise((resolve, reject) => {
  726. window._initBaiduMap = function() {
  727. window.BMap = getConfig().type == "WebGL" ? window.BMapGL : window.BMap;
  728. resolve(window.BMap);
  729. window.document.body.removeChild($script);
  730. window.BMap._preloader = null;
  731. window._initBaiduMap = null;
  732. };
  733. const $script = document.createElement("script");
  734. window.document.body.appendChild($script);
  735. switch (getConfig().type) {
  736. case "WebGL":
  737. $script.src = `https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${getConfig().ak}&callback=_initBaiduMap`;
  738. break;
  739. default:
  740. $script.src = `https://api.map.baidu.com/api?v=${getConfig().v}&ak=${getConfig().ak}&callback=_initBaiduMap`;
  741. }
  742. });
  743. return window.BMap._preloader;
  744. } else if (!window.BMap._preloader) {
  745. return Promise.resolve(window.BMap);
  746. } else {
  747. return window.BMap._preloader;
  748. }
  749. },
  750. reset() {
  751. const { getMapScript, initMap } = this;
  752. getMapScript().then(initMap);
  753. }
  754. },
  755. created() {
  756. const options = {};
  757. this.ak && (options.ak = this.ak);
  758. this.v && (options.v = this.v);
  759. this.type && (options.type = this.type);
  760. setConfig(options);
  761. },
  762. mounted() {
  763. this.reset();
  764. },
  765. data() {
  766. return {
  767. hasBmView: false,
  768. map: null,
  769. BMap: null,
  770. name: "bm-map"
  771. };
  772. }
  773. };
  774. const _hoisted_1$2 = {
  775. key: 0,
  776. ref: "view",
  777. style: { "width": "100%", "height": "100%" }
  778. };
  779. function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
  780. return openBlock(), createElementBlock("div", {
  781. class: normalizeClass(_ctx.$attrs.class),
  782. style: normalizeStyle(_ctx.$attrs.style)
  783. }, [
  784. !$data.hasBmView ? (openBlock(), createElementBlock("div", _hoisted_1$2, null, 512)) : createCommentVNode("", true),
  785. renderSlot(_ctx.$slots, "default")
  786. ], 6);
  787. }
  788. var BaiduMap = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["render", _sfc_render$e]]);
  789. const types = {
  790. control: {
  791. unload: "removeControl"
  792. },
  793. layer: {
  794. unload: "removeTileLayer"
  795. },
  796. overlay: {
  797. unload: "removeOverlay"
  798. },
  799. contextMenu: {
  800. unload: "removeContextMenu"
  801. }
  802. };
  803. const getParent = ($component) => {
  804. return $component.abstract || $component.name !== "bm-map" ? getParent($component.$parent) : $component;
  805. };
  806. function destroyInstance() {
  807. const { unload, renderByParent, $parent, ready } = this;
  808. EvenBus.$off("ready", ready);
  809. if (renderByParent) {
  810. $parent.reload();
  811. }
  812. unload();
  813. }
  814. const getMixin = (prop = {}) => {
  815. return {
  816. emits: ["ready"],
  817. computed: {
  818. renderByParent() {
  819. return this.$parent.preventChildrenRender;
  820. }
  821. },
  822. created() {
  823. const $parent = getParent(this.$parent);
  824. const map = $parent.map;
  825. const { ready } = this;
  826. map ? ready() : EvenBus.$on("ready", ready);
  827. map ? this.init({ BMap: $parent.BMap, map }) : EvenBus.$on("init", this.init);
  828. },
  829. mounted() {
  830. const $parent = getParent(this.$parent);
  831. const map = $parent.map;
  832. const { mountedReady } = this;
  833. map ? mountedReady() : EvenBus.$on("ready", mountedReady);
  834. },
  835. unmounted: destroyInstance,
  836. methods: {
  837. init() {
  838. },
  839. ready() {
  840. const $parent = getParent(this.$parent);
  841. const BMap2 = this.BMap = $parent.BMap;
  842. const map = this.map = $parent.map;
  843. this.load();
  844. this.$emit("ready", {
  845. BMap: BMap2,
  846. map
  847. });
  848. },
  849. mountedReady() {
  850. this.mountedLoad();
  851. },
  852. transmitEvent(e) {
  853. this.$emit(e.type.replace(/^on/, ""), e);
  854. },
  855. reload() {
  856. this && this.BMap && this.$nextTick(() => {
  857. this.unload();
  858. this.$nextTick(() => {
  859. this.load();
  860. this.mountedLoad();
  861. });
  862. });
  863. },
  864. unload() {
  865. const { map, originInstance } = this;
  866. try {
  867. switch (prop.type) {
  868. case "search":
  869. return originInstance.clearResults();
  870. case "autoComplete":
  871. case "lushu":
  872. return originInstance.dispose();
  873. case "markerClusterer":
  874. return originInstance.clearMarkers();
  875. default:
  876. map[types[prop.type].unload](originInstance);
  877. }
  878. } catch (e) {
  879. }
  880. },
  881. mountedLoad() {
  882. }
  883. }
  884. };
  885. };
  886. var commonMixin = (type) => getMixin({ type });
  887. const _sfc_main$w = {
  888. name: "bm-scale",
  889. render() {
  890. },
  891. mixins: [commonMixin("control")],
  892. props: {
  893. anchor: {
  894. type: String
  895. },
  896. offset: {
  897. type: Object
  898. }
  899. },
  900. watch: {
  901. anchor() {
  902. this.reload();
  903. },
  904. offset() {
  905. this.reload();
  906. }
  907. },
  908. methods: {
  909. load() {
  910. const { BMap: BMap2, map, anchor, offset } = this;
  911. this.originInstance = new BMap2.ScaleControl({
  912. anchor: window[anchor],
  913. offset: offset && createSize(BMap2, offset)
  914. });
  915. map.addControl(this.originInstance);
  916. }
  917. }
  918. };
  919. const _sfc_main$v = {
  920. name: "bm-navigation",
  921. render() {
  922. },
  923. mixins: [commonMixin("control")],
  924. props: {
  925. anchor: {
  926. type: String
  927. },
  928. offset: {
  929. type: Object
  930. },
  931. type: {
  932. type: String
  933. },
  934. showZoomInfo: {
  935. type: Boolean
  936. },
  937. enableGeolocation: {
  938. type: Boolean,
  939. default: false
  940. }
  941. },
  942. watch: {
  943. anchor() {
  944. this.reload();
  945. },
  946. offset() {
  947. this.reload();
  948. },
  949. type() {
  950. this.reload();
  951. },
  952. showZoomInfo() {
  953. this.reload();
  954. }
  955. },
  956. methods: {
  957. load() {
  958. const { BMap: BMap2, map, anchor, offset, type, showZoomInfo, enableGeolocation } = this;
  959. let navigationOption = {
  960. anchor: window[anchor],
  961. offset: offset && createSize(BMap2, offset),
  962. type: window[type],
  963. showZoomInfo,
  964. enableGeolocation
  965. };
  966. deleteEmptyKey(navigationOption);
  967. this.originInstance = new BMap2[getMapMethod("NavigationControl")](navigationOption);
  968. map.addControl(this.originInstance);
  969. }
  970. }
  971. };
  972. const _sfc_main$u = {
  973. name: "bm-map-type",
  974. render() {
  975. },
  976. mixins: [commonMixin("control")],
  977. props: ["type", "mapTypes", "anchor", "offset"],
  978. watch: {
  979. anchor() {
  980. this.reload();
  981. },
  982. offset() {
  983. this.reload();
  984. },
  985. type() {
  986. this.reload();
  987. },
  988. mapTypes() {
  989. this.reload();
  990. }
  991. },
  992. methods: {
  993. load() {
  994. const { BMap: BMap2, map, anchor, offset, type } = this;
  995. const mapTypes = [];
  996. this.mapTypes && this.mapTypes.forEach((item) => mapTypes.push(window[item]));
  997. let maptypeControlOption = {
  998. anchor: window[anchor],
  999. offset: offset && createSize(BMap2, offset),
  1000. type: window[type],
  1001. mapTypes
  1002. };
  1003. deleteEmptyKey(maptypeControlOption);
  1004. this.originInstance = new BMap2.MapTypeControl(maptypeControlOption);
  1005. map.addControl(this.originInstance);
  1006. }
  1007. }
  1008. };
  1009. const _sfc_main$t = {
  1010. name: "bm-overview-map",
  1011. mixins: [commonMixin("control")],
  1012. render() {
  1013. },
  1014. props: {
  1015. anchor: {
  1016. type: String
  1017. },
  1018. offset: {
  1019. type: Object
  1020. },
  1021. size: {
  1022. type: Object
  1023. },
  1024. isOpen: {
  1025. type: Boolean
  1026. }
  1027. },
  1028. watch: {
  1029. anchor() {
  1030. this.reload();
  1031. },
  1032. offset() {
  1033. this.reload();
  1034. },
  1035. size() {
  1036. this.reload();
  1037. },
  1038. isOpen() {
  1039. this.reload();
  1040. }
  1041. },
  1042. methods: {
  1043. load() {
  1044. const { BMap: BMap2, map, isOpen, size, offset, anchor } = this;
  1045. this.mapTypes && this.mapTypes.forEach((item) => {
  1046. });
  1047. let overviewOption = {
  1048. anchor: window[anchor],
  1049. offset: createSize(BMap2, offset),
  1050. size: createSize(BMap2, size),
  1051. isOpen
  1052. };
  1053. deleteEmptyKey(overviewOption);
  1054. this.originInstance = new BMap2.OverviewMapControl(overviewOption);
  1055. bindEvents.call(this, this.originInstance);
  1056. map.addControl(this.originInstance);
  1057. }
  1058. }
  1059. };
  1060. const _sfc_main$s = {
  1061. name: "bm-geolocation",
  1062. render() {
  1063. },
  1064. mixins: [commonMixin("control")],
  1065. props: {
  1066. anchor: {
  1067. type: String
  1068. },
  1069. offset: {
  1070. type: Object
  1071. },
  1072. showAddressBar: {
  1073. type: Boolean
  1074. },
  1075. autoLocation: {
  1076. type: Boolean
  1077. },
  1078. locationIcon: {
  1079. type: Object
  1080. }
  1081. },
  1082. watch: {
  1083. anchor() {
  1084. this.reload();
  1085. },
  1086. offset() {
  1087. this.reload();
  1088. },
  1089. showAddressBar() {
  1090. this.reload();
  1091. },
  1092. autoLocation() {
  1093. this.reload();
  1094. },
  1095. locationIcon() {
  1096. this.reload();
  1097. }
  1098. },
  1099. methods: {
  1100. load() {
  1101. const { BMap: BMap2, map, anchor, showAddressBar, autoLocation, locationIcon, offset } = this;
  1102. let geoLocationOption = {
  1103. anchor: window[anchor],
  1104. showAddressBar,
  1105. enableAutoLocation: autoLocation,
  1106. offset: offset && createSize(BMap2, offset),
  1107. locationIcon: locationIcon && createIcon(BMap2, locationIcon)
  1108. };
  1109. deleteEmptyKey(geoLocationOption);
  1110. switch (getConfig().type) {
  1111. case "WebGL":
  1112. this.originInstance = new BMap2.LocationControl(geoLocationOption);
  1113. break;
  1114. default:
  1115. this.originInstance = new BMap2.GeolocationControl(geoLocationOption);
  1116. }
  1117. bindEvents.call(this, this.originInstance);
  1118. map.addControl(this.originInstance);
  1119. }
  1120. }
  1121. };
  1122. const _sfc_main$r = {
  1123. name: "bm-copyright",
  1124. render() {
  1125. },
  1126. mixins: [commonMixin("control")],
  1127. props: ["anchor", "offset", "copyright"],
  1128. watch: {
  1129. anchor() {
  1130. this.reload();
  1131. },
  1132. offset() {
  1133. this.reload();
  1134. },
  1135. copyright() {
  1136. this.reload();
  1137. }
  1138. },
  1139. methods: {
  1140. load() {
  1141. const { BMap: BMap2, map, offset, anchor, updateCopyrightList } = this;
  1142. this.originInstance = new BMap2.CopyrightControl({
  1143. anchor: window[anchor],
  1144. offset: offset && createSize(BMap2, offset)
  1145. });
  1146. updateCopyrightList();
  1147. map.addControl(this.originInstance);
  1148. },
  1149. updateCopyrightList() {
  1150. const { BMap: BMap2, map } = this;
  1151. const { removeCopyright, getCopyrightCollection } = this.originInstance;
  1152. const copyrightList = getCopyrightCollection();
  1153. copyrightList && copyrightList.forEach((item) => {
  1154. removeCopyright(item.id);
  1155. });
  1156. this.copyright && this.copyright.forEach((item) => {
  1157. const bounds = item.bounds ? new BMap2.Bounds(new BMap2.Point(item.bounds.sw.lng, item.bounds.sw.lat), new BMap2.Point(item.bounds.ne.lng, item.bounds.ne.lat)) : map.getBounds();
  1158. this.originInstance.addCopyright({
  1159. id: item.id,
  1160. content: item.content,
  1161. bounds
  1162. });
  1163. });
  1164. }
  1165. }
  1166. };
  1167. const _sfc_main$q = {
  1168. name: "bm-city-list",
  1169. render() {
  1170. },
  1171. emits: ["changeBefore", "changeAfter"],
  1172. mixins: [commonMixin("control")],
  1173. props: {
  1174. anchor: {
  1175. type: String
  1176. },
  1177. offset: {
  1178. type: Object
  1179. }
  1180. },
  1181. watch: {
  1182. anchor() {
  1183. this.reload();
  1184. },
  1185. offset() {
  1186. this.reload();
  1187. }
  1188. },
  1189. methods: {
  1190. load() {
  1191. const { BMap: BMap2, map, anchor, offset } = this;
  1192. const self2 = this;
  1193. this.originInstance = new BMap2.CityListControl({
  1194. anchor: window[anchor],
  1195. offset: offset && createSize(BMap2, offset),
  1196. onChangeBefore() {
  1197. self2.$emit("changeBefore");
  1198. },
  1199. onChangeAfter() {
  1200. self2.$emit("changeAfter");
  1201. }
  1202. });
  1203. map.addControl(this.originInstance);
  1204. }
  1205. }
  1206. };
  1207. const _sfc_main$p = {
  1208. name: "bm-panorama",
  1209. mixins: [commonMixin("control")],
  1210. render() {
  1211. },
  1212. props: ["anchor", "offset"],
  1213. watch: {
  1214. anchor() {
  1215. this.reload();
  1216. },
  1217. offset() {
  1218. this.reload();
  1219. }
  1220. },
  1221. methods: {
  1222. load() {
  1223. const { BMap: BMap2, map, anchor, offset } = this;
  1224. this.originInstance = new BMap2.PanoramaControl({
  1225. anchor: window[anchor],
  1226. offset: offset && createSize(BMap2, offset)
  1227. });
  1228. map.addControl(this.originInstance);
  1229. }
  1230. }
  1231. };
  1232. const _sfc_main$o = {
  1233. name: "bm-control",
  1234. mixins: [commonMixin("control")],
  1235. props: ["anchor", "offset"],
  1236. watch: {
  1237. anchor(val) {
  1238. this.originInstance.setAnchor(val);
  1239. },
  1240. offset(val) {
  1241. this.originInstance.setOffset(val);
  1242. }
  1243. },
  1244. methods: {
  1245. load() {
  1246. const { BMap: BMap2, map, anchor, offset, $el } = this;
  1247. const Control = function() {
  1248. this.defaultAnchor = window[anchor || "BMAP_ANCHOR_TOP_LEFT"];
  1249. this.defaultOffset = createSize(BMap2, offset);
  1250. };
  1251. Control.prototype = new BMap2.Control();
  1252. Control.prototype.initialize = (map2) => map2.getContainer().appendChild($el);
  1253. this.originInstance = new Control(anchor, offset);
  1254. map.addControl(this.originInstance);
  1255. }
  1256. }
  1257. };
  1258. function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
  1259. return openBlock(), createElementBlock("div", null, [
  1260. renderSlot(_ctx.$slots, "default")
  1261. ]);
  1262. }
  1263. var BmControl = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$d]]);
  1264. var Marker_vue_vue_type_style_index_0_lang = "";
  1265. const _sfc_main$n = {
  1266. name: "bm-marker",
  1267. mixins: [commonMixin("overlay")],
  1268. inject: {
  1269. Cluster: {
  1270. default: () => ({})
  1271. }
  1272. },
  1273. props: {
  1274. position: {},
  1275. offset: {},
  1276. icon: {},
  1277. massClear: {
  1278. type: Boolean,
  1279. default: true
  1280. },
  1281. dragging: {
  1282. type: Boolean,
  1283. default: false
  1284. },
  1285. clicking: {
  1286. type: Boolean,
  1287. default: true
  1288. },
  1289. raiseOnDrag: {
  1290. type: Boolean,
  1291. default: false
  1292. },
  1293. draggingCursor: {
  1294. type: String
  1295. },
  1296. rotation: {
  1297. type: Number
  1298. },
  1299. shadow: {
  1300. type: Object
  1301. },
  1302. title: {
  1303. type: String
  1304. },
  1305. label: {
  1306. type: Object
  1307. },
  1308. animation: {
  1309. type: String
  1310. },
  1311. top: {
  1312. type: Boolean,
  1313. default: false
  1314. },
  1315. zIndex: {
  1316. type: Number,
  1317. default: 0
  1318. }
  1319. },
  1320. watch: {
  1321. "position.lng"(val, oldVal) {
  1322. const { BMap: BMap2, originInstance, position, renderByParent, $parent } = this;
  1323. if (val !== oldVal && val >= -180 && val <= 180) {
  1324. originInstance.setPosition(createPoint(BMap2, { lng: val, lat: position.lat }));
  1325. }
  1326. renderByParent && $parent.reload();
  1327. },
  1328. "position.lat"(val, oldVal) {
  1329. const { BMap: BMap2, originInstance, position, renderByParent, $parent } = this;
  1330. if (val !== oldVal && val >= -74 && val <= 74) {
  1331. originInstance.setPosition(createPoint(BMap2, { lng: position.lng, lat: val }));
  1332. }
  1333. renderByParent && $parent.reload();
  1334. },
  1335. "offset.width"(val, oldVal) {
  1336. const { BMap: BMap2, originInstance } = this;
  1337. if (val !== oldVal) {
  1338. originInstance.setOffset(new BMap2.Size(val, this.offset.height));
  1339. }
  1340. },
  1341. "offset.height"(val, oldVal) {
  1342. const { BMap: BMap2, originInstance } = this;
  1343. if (val !== oldVal) {
  1344. originInstance.setOffset(new BMap2.Size(this.offset.width, val));
  1345. }
  1346. },
  1347. icon: {
  1348. deep: true,
  1349. handler(val) {
  1350. const { BMap: BMap2, originInstance, rotation } = this;
  1351. originInstance && originInstance.setIcon(createIcon(BMap2, val));
  1352. rotation && originInstance && originInstance.setRotation(rotation);
  1353. }
  1354. },
  1355. massClear(val) {
  1356. val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
  1357. },
  1358. dragging(val) {
  1359. val ? this.originInstance.enableDragging() : this.originInstance.disableDragging();
  1360. },
  1361. clicking() {
  1362. this.reload();
  1363. },
  1364. raiseOnDrag() {
  1365. this.reload();
  1366. },
  1367. draggingCursor(val) {
  1368. this.originInstance.setDraggingCursor(val);
  1369. },
  1370. rotation(val) {
  1371. this.originInstance.setRotation(val);
  1372. },
  1373. shadow(val) {
  1374. this.originInstance.setShadow(val);
  1375. },
  1376. title(val) {
  1377. this.originInstance.setTitle(val);
  1378. },
  1379. label(val) {
  1380. this.reload();
  1381. },
  1382. animation(val) {
  1383. this.originInstance.setAnimation(window[val]);
  1384. },
  1385. top(val) {
  1386. this.originInstance.setTop(val);
  1387. },
  1388. zIndex(val) {
  1389. this.originInstance.setZIndex(val);
  1390. }
  1391. },
  1392. methods: {
  1393. load() {
  1394. var _a, _b;
  1395. const { BMap: BMap2, map, position, offset, icon, massClear, dragging, clicking, raiseOnDrag, draggingCursor, rotation, shadow, title, label, animation, top, renderByParent, $parent, zIndex } = this;
  1396. let makerOption = {
  1397. offset,
  1398. icon: icon && createIcon(BMap2, icon),
  1399. enableMassClear: massClear,
  1400. enableDragging: dragging,
  1401. enableClicking: clicking,
  1402. raiseOnDrag,
  1403. draggingCursor,
  1404. rotation,
  1405. shadow,
  1406. title
  1407. };
  1408. deleteEmptyKey(makerOption);
  1409. const overlay = new BMap2.Marker(new BMap2.Point(position.lng, position.lat), makerOption);
  1410. this.originInstance = overlay;
  1411. label && overlay && overlay.setLabel(createLabel(BMap2, label));
  1412. overlay.setTop(top);
  1413. overlay.setZIndex(zIndex);
  1414. bindEvents.call(this, overlay);
  1415. if (renderByParent) {
  1416. $parent.reload();
  1417. } else {
  1418. map.addOverlay(overlay);
  1419. }
  1420. overlay.setAnimation(window[animation]);
  1421. (_b = (_a = this.Cluster) == null ? void 0 : _a.addMaker) == null ? void 0 : _b.call(_a, this);
  1422. }
  1423. },
  1424. beforeUnmount() {
  1425. var _a, _b;
  1426. (_b = (_a = this.Cluster) == null ? void 0 : _a.removeMaker) == null ? void 0 : _b.call(_a, this);
  1427. }
  1428. };
  1429. function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
  1430. return openBlock(), createElementBlock("div", null, [
  1431. renderSlot(_ctx.$slots, "default")
  1432. ]);
  1433. }
  1434. var BmMarker = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$c]]);
  1435. const _sfc_main$m = {
  1436. render() {
  1437. },
  1438. name: "bm-point-collection",
  1439. mixins: [commonMixin("overlay")],
  1440. props: {
  1441. points: {
  1442. type: Array,
  1443. default() {
  1444. return [];
  1445. }
  1446. },
  1447. shape: {
  1448. type: String,
  1449. default: "BMAP_POINT_SHAPE_CIRCLE"
  1450. },
  1451. color: {
  1452. type: String
  1453. },
  1454. size: {
  1455. type: String,
  1456. default: "BMAP_POINT_SIZE_NORMAL"
  1457. }
  1458. },
  1459. watch: {
  1460. shape(val) {
  1461. const { originInstance, color, size } = this;
  1462. originInstance.setStyles({
  1463. shape: window[val],
  1464. color,
  1465. size: window[size]
  1466. });
  1467. },
  1468. size(val) {
  1469. const { originInstance, color, shape } = this;
  1470. originInstance.setStyles({
  1471. shape: window[shape],
  1472. color,
  1473. size: window[val]
  1474. });
  1475. },
  1476. color(val) {
  1477. const { originInstance, shape, size } = this;
  1478. originInstance.setStyles({
  1479. shape: window[shape],
  1480. color: val,
  1481. size: window[size]
  1482. });
  1483. },
  1484. points: {
  1485. deep: true,
  1486. handler(val) {
  1487. const { originInstance } = this;
  1488. originInstance.clear();
  1489. originInstance.setPoints(val);
  1490. }
  1491. }
  1492. },
  1493. methods: {
  1494. load() {
  1495. },
  1496. init({ BMap: BMap2, map }) {
  1497. this.$emit("init", {
  1498. BMap: BMap2,
  1499. map
  1500. });
  1501. const { points, shape, color, size } = this;
  1502. let pointCollectionOption = {
  1503. shape: window[shape],
  1504. color,
  1505. size: window[size]
  1506. };
  1507. deleteEmptyKey(pointCollectionOption);
  1508. const overlay = this.originInstance = new BMap2.PointCollection(points.map((p) => createPoint(BMap2, p)), pointCollectionOption);
  1509. bindEvents.call(this, overlay);
  1510. map.addOverlay(overlay);
  1511. }
  1512. }
  1513. };
  1514. const _sfc_main$l = {
  1515. name: "bm-polyline",
  1516. render() {
  1517. },
  1518. mixins: [commonMixin("overlay")],
  1519. props: {
  1520. path: {
  1521. type: Array
  1522. },
  1523. strokeColor: {
  1524. type: String,
  1525. default: "blue"
  1526. },
  1527. strokeWeight: {
  1528. type: Number,
  1529. default: 2
  1530. },
  1531. strokeOpacity: {
  1532. type: Number,
  1533. default: 0.5
  1534. },
  1535. strokeStyle: {
  1536. type: String,
  1537. default: "solid"
  1538. },
  1539. massClear: {
  1540. type: Boolean,
  1541. default: true
  1542. },
  1543. clicking: {
  1544. type: Boolean,
  1545. default: true
  1546. },
  1547. editing: {
  1548. type: Boolean,
  1549. default: false
  1550. },
  1551. icons: {
  1552. type: Array,
  1553. default() {
  1554. return [];
  1555. }
  1556. }
  1557. },
  1558. watch: {
  1559. path: {
  1560. handler(val, oldVal) {
  1561. this.reload();
  1562. },
  1563. deep: true
  1564. },
  1565. icons: {
  1566. handler(val, oldVal) {
  1567. this.reload();
  1568. },
  1569. deep: true
  1570. },
  1571. strokeColor(val) {
  1572. this.originInstance.setStrokeColor(val);
  1573. },
  1574. strokeOpacity(val) {
  1575. this.originInstance.setStrokeOpacity(val);
  1576. },
  1577. strokeWeight(val) {
  1578. this.originInstance.setStrokeWeight(val);
  1579. },
  1580. strokeStyle(val) {
  1581. this.originInstance.setStrokeStyle(val);
  1582. },
  1583. editing(val) {
  1584. val ? this.originInstance.enableEditing() : this.originInstance.disableEditing();
  1585. },
  1586. massClear(val) {
  1587. val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
  1588. },
  1589. clicking(val) {
  1590. this.reload();
  1591. }
  1592. },
  1593. computed: {
  1594. iconSequences() {
  1595. const { BMap: BMap2, icons } = this;
  1596. return icons.map((item) => {
  1597. return createIconSequence(BMap2, item);
  1598. });
  1599. }
  1600. },
  1601. methods: {
  1602. load() {
  1603. const { BMap: BMap2, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking, iconSequences } = this;
  1604. let polyLineOption = {
  1605. strokeColor,
  1606. strokeWeight,
  1607. strokeOpacity,
  1608. strokeStyle,
  1609. enableEditing: editing,
  1610. enableMassClear: massClear,
  1611. enableClicking: clicking,
  1612. icons: iconSequences
  1613. };
  1614. deleteEmptyKey(polyLineOption);
  1615. const overlay = new BMap2.Polyline(path.map((item) => createPoint(BMap2, { lng: item.lng, lat: item.lat })), polyLineOption);
  1616. this.originInstance = overlay;
  1617. map.addOverlay(overlay);
  1618. bindEvents.call(this, overlay);
  1619. }
  1620. }
  1621. };
  1622. const _sfc_main$k = {
  1623. name: "bm-polygon",
  1624. render() {
  1625. },
  1626. mixins: [commonMixin("overlay")],
  1627. props: {
  1628. path: {
  1629. type: Array,
  1630. default() {
  1631. return [];
  1632. }
  1633. },
  1634. strokeColor: {
  1635. type: String
  1636. },
  1637. strokeWeight: {
  1638. type: Number
  1639. },
  1640. strokeOpacity: {
  1641. type: Number
  1642. },
  1643. strokeStyle: {
  1644. type: String
  1645. },
  1646. fillColor: {
  1647. type: String
  1648. },
  1649. fillOpacity: {
  1650. type: Number
  1651. },
  1652. massClear: {
  1653. type: Boolean,
  1654. default: true
  1655. },
  1656. clicking: {
  1657. type: Boolean,
  1658. default: true
  1659. },
  1660. editing: {
  1661. type: Boolean,
  1662. default: false
  1663. }
  1664. },
  1665. watch: {
  1666. path: {
  1667. handler(val, oldVal) {
  1668. this.reload();
  1669. },
  1670. deep: true
  1671. },
  1672. strokeColor(val) {
  1673. this.originInstance.setStrokeColor(val);
  1674. },
  1675. strokeOpacity(val) {
  1676. this.originInstance.setStrokeOpacity(val);
  1677. },
  1678. strokeWeight(val) {
  1679. this.originInstance.setStrokeWeight(val);
  1680. },
  1681. strokeStyle(val) {
  1682. this.originInstance.setStrokeStyle(val);
  1683. },
  1684. fillColor(val) {
  1685. this.originInstance.setFillColor(val);
  1686. },
  1687. fillOpacity(val) {
  1688. this.originInstance.setFillOpacity(val);
  1689. },
  1690. editing(val) {
  1691. val ? this.originInstance.enableEditing() : this.originInstance.disableEditing();
  1692. },
  1693. massClear(val) {
  1694. val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
  1695. },
  1696. clicking(val) {
  1697. this.reload();
  1698. }
  1699. },
  1700. methods: {
  1701. load() {
  1702. const { BMap: BMap2, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, fillColor, fillOpacity, editing, massClear, clicking } = this;
  1703. let polygonOption = {
  1704. strokeColor,
  1705. strokeWeight,
  1706. strokeOpacity,
  1707. strokeStyle,
  1708. fillColor,
  1709. fillOpacity,
  1710. enableMassClear: massClear,
  1711. enableClicking: clicking
  1712. };
  1713. deleteEmptyKey(polygonOption);
  1714. const overlay = new BMap2.Polygon(path.map((item) => createPoint(BMap2, { lng: item.lng, lat: item.lat })), polygonOption);
  1715. this.originInstance = overlay;
  1716. map.addOverlay(overlay);
  1717. bindEvents.call(this, overlay);
  1718. editing ? overlay.enableEditing() : overlay.disableEditing();
  1719. }
  1720. }
  1721. };
  1722. const _sfc_main$j = {
  1723. name: "bm-circle",
  1724. render() {
  1725. },
  1726. mixins: [commonMixin("overlay")],
  1727. props: {
  1728. center: {},
  1729. radius: {},
  1730. strokeColor: {
  1731. type: String
  1732. },
  1733. strokeWeight: {
  1734. type: Number
  1735. },
  1736. strokeOpacity: {
  1737. type: Number
  1738. },
  1739. strokeStyle: {
  1740. type: String
  1741. },
  1742. fillColor: {
  1743. type: String
  1744. },
  1745. fillOpacity: {
  1746. type: Number
  1747. },
  1748. massClear: {
  1749. type: Boolean,
  1750. default: true
  1751. },
  1752. clicking: {
  1753. type: Boolean,
  1754. default: true
  1755. },
  1756. editing: {
  1757. type: Boolean,
  1758. default: false
  1759. }
  1760. },
  1761. watch: {
  1762. "center.lng"(val, oldVal) {
  1763. const { BMap: BMap2, originInstance, isEditing, disableEditing, enableEditing, center, editing } = this;
  1764. if (!isEditing) {
  1765. disableEditing();
  1766. const lng = val;
  1767. if (val.toString() !== oldVal.toString() && lng >= -180 && lng <= 180) {
  1768. originInstance.setCenter(createPoint(BMap2, { lng, lat: center.lat }));
  1769. }
  1770. editing && enableEditing();
  1771. }
  1772. },
  1773. "center.lat"(val, oldVal) {
  1774. const { BMap: BMap2, originInstance, isEditing, disableEditing, enableEditing, center, editing } = this;
  1775. if (!isEditing) {
  1776. disableEditing();
  1777. const lat = val;
  1778. if (val.toString() !== oldVal.toString() && lat >= -74 && lat <= 74) {
  1779. originInstance.setCenter(createPoint(BMap2, { lng: center.lng, lat }));
  1780. }
  1781. editing && enableEditing();
  1782. }
  1783. },
  1784. radius(val, oldVal) {
  1785. const { originInstance, isEditing, disableEditing, enableEditing, editing } = this;
  1786. if (!isEditing) {
  1787. disableEditing();
  1788. originInstance.setRadius(val);
  1789. editing && enableEditing();
  1790. }
  1791. },
  1792. strokeColor(val) {
  1793. this.originInstance.setStrokeColor(val);
  1794. },
  1795. strokeOpacity(val) {
  1796. this.originInstance.setStrokeOpacity(val);
  1797. },
  1798. strokeWeight(val) {
  1799. this.originInstance.setStrokeWeight(val);
  1800. },
  1801. strokeStyle(val) {
  1802. this.originInstance.setStrokeStyle(val);
  1803. },
  1804. fillColor(val) {
  1805. this.originInstance.setFillColor(val);
  1806. },
  1807. fillOpacity(val) {
  1808. this.originInstance.setFillOpacity(val);
  1809. },
  1810. editing(val) {
  1811. val ? this.enableEditing() : this.disableEditing();
  1812. },
  1813. massClear(val) {
  1814. val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
  1815. },
  1816. clicking(val) {
  1817. this.reload();
  1818. }
  1819. },
  1820. methods: {
  1821. dragStartHandler() {
  1822. this.isEditing = true;
  1823. },
  1824. dragEndHandler() {
  1825. this.isEditing = false;
  1826. this.bindEditingNodeEvents();
  1827. },
  1828. bindEditingNodeEvents() {
  1829. const { originInstance, editingKey, dragStartHandler, dragEndHandler } = this;
  1830. if (originInstance[editingKey]) {
  1831. originInstance[editingKey].forEach(($node) => {
  1832. $node.addEventListener("dragstart", dragStartHandler);
  1833. $node.addEventListener("dragend", dragEndHandler);
  1834. });
  1835. }
  1836. },
  1837. enableEditing() {
  1838. const { originInstance, bindEditingNodeEvents } = this;
  1839. originInstance.enableEditing();
  1840. bindEditingNodeEvents();
  1841. },
  1842. disableEditing() {
  1843. const { originInstance } = this;
  1844. originInstance.disableEditing();
  1845. },
  1846. getEditingKey(overlay) {
  1847. const stack = [];
  1848. overlay.enableEditing();
  1849. setTimeout(() => {
  1850. for (const key in overlay) {
  1851. if (overlay[key] && overlay[key].length === 2) {
  1852. stack.push(key);
  1853. }
  1854. }
  1855. overlay.disableEditing();
  1856. for (const key in overlay) {
  1857. if (overlay[key] && overlay[key].length === 0 && ~stack.indexOf(key)) {
  1858. this.editingKey = key;
  1859. }
  1860. }
  1861. }, 0);
  1862. },
  1863. load() {
  1864. const { BMap: BMap2, map, center, radius, strokeColor, strokeWeight, strokeOpacity, strokeStyle, fillColor, fillOpacity, editing, massClear, clicking, enableEditing, disableEditing, getEditingKey, editingKey } = this;
  1865. let overlayOption = {
  1866. strokeColor,
  1867. strokeWeight,
  1868. strokeOpacity,
  1869. strokeStyle,
  1870. fillColor,
  1871. fillOpacity,
  1872. enableMassClear: massClear,
  1873. enableClicking: clicking
  1874. };
  1875. deleteEmptyKey(overlayOption);
  1876. const overlay = new BMap2.Circle(createPoint(BMap2, { lng: center.lng, lat: center.lat }), radius, overlayOption);
  1877. this.originInstance = overlay;
  1878. map.addOverlay(overlay);
  1879. bindEvents.call(this, overlay);
  1880. !editingKey && getEditingKey(overlay);
  1881. setTimeout(() => {
  1882. editing ? enableEditing() : disableEditing();
  1883. }, 0);
  1884. }
  1885. }
  1886. };
  1887. const _sfc_main$i = {
  1888. name: "bm-ground",
  1889. render() {
  1890. },
  1891. mixins: [commonMixin("overlay")],
  1892. props: {
  1893. bounds: {
  1894. type: Object
  1895. },
  1896. opacity: {
  1897. type: Number
  1898. },
  1899. imageURL: {
  1900. type: String
  1901. },
  1902. displayOnMinLevel: {
  1903. type: Number
  1904. },
  1905. displayOnMaxLevel: {
  1906. type: Number
  1907. }
  1908. },
  1909. watch: {
  1910. bounds: {
  1911. handler(val) {
  1912. const { BMap: BMap2 } = this;
  1913. this.originInstance.setBounds(createBounds(BMap2, val));
  1914. },
  1915. deep: true
  1916. },
  1917. opacity(val) {
  1918. this.originInstance.setOpacity(val);
  1919. },
  1920. imageURL(val) {
  1921. this.originInstance.setImageURL(val);
  1922. },
  1923. displayOnMinLevel(val) {
  1924. this.originInstance.setDisplayOnMinLevel(val);
  1925. },
  1926. displayOnMaxLevel(val) {
  1927. this.originInstance.setDisplayOnMaxLevel(val);
  1928. }
  1929. },
  1930. methods: {
  1931. load() {
  1932. const { BMap: BMap2, map, bounds, opacity, imageURL, displayOnMinLevel, displayOnMaxLevel } = this;
  1933. let groundOption = {
  1934. opacity,
  1935. imageURL,
  1936. displayOnMaxLevel,
  1937. displayOnMinLevel
  1938. };
  1939. deleteEmptyKey(groundOption);
  1940. const overlay = new BMap2.GroundOverlay(bounds && createBounds(BMap2, bounds), groundOption);
  1941. overlay.setImageURL(imageURL);
  1942. this.originInstance = overlay;
  1943. bindEvents.call(this, overlay);
  1944. map.addOverlay(overlay);
  1945. }
  1946. }
  1947. };
  1948. const _sfc_main$h = {
  1949. name: "bm-label",
  1950. render() {
  1951. },
  1952. mixins: [commonMixin("overlay")],
  1953. props: {
  1954. content: {
  1955. type: String
  1956. },
  1957. title: {
  1958. type: String
  1959. },
  1960. offset: {},
  1961. position: {},
  1962. labelStyle: {},
  1963. zIndex: {
  1964. type: Number,
  1965. default: 0
  1966. },
  1967. massClear: {
  1968. type: Boolean,
  1969. default: true
  1970. }
  1971. },
  1972. watch: {
  1973. content(val) {
  1974. this.originInstance.setContent(val);
  1975. },
  1976. title(val) {
  1977. this.originInstance.setTitle(val);
  1978. },
  1979. "offset.width"(val, oldVal) {
  1980. const { BMap: BMap2 } = this;
  1981. if (val.toString() !== oldVal.toString()) {
  1982. this.originInstance.setOffset(createSize(BMap2, { width: val, height: this.offset.height }));
  1983. }
  1984. },
  1985. "offset.height"(val, oldVal) {
  1986. const { BMap: BMap2 } = this;
  1987. if (val.toString() !== oldVal.toString()) {
  1988. this.originInstance.setOffset(createSize(BMap2, {
  1989. width: this.offset.width,
  1990. height: val
  1991. }));
  1992. }
  1993. },
  1994. "position.lng"(val, oldVal) {
  1995. const { BMap: BMap2 } = this;
  1996. const lng = val;
  1997. if (val.toString() !== oldVal.toString() && lng >= -180 && lng <= 180) {
  1998. this.originInstance.setPosition(createPoint(BMap2, { lng, lat: this.position.lat }));
  1999. }
  2000. },
  2001. "position.lat"(val, oldVal) {
  2002. const { BMap: BMap2 } = this;
  2003. const lat = val;
  2004. if (val.toString() !== oldVal.toString() && lat >= -74 && lat <= 74) {
  2005. this.originInstance.setPosition(createPoint(BMap2, { lng: this.position.lng, lat }));
  2006. }
  2007. },
  2008. labelStyle: {
  2009. handler(val) {
  2010. this.originInstance.setStyle(val);
  2011. },
  2012. deep: true
  2013. },
  2014. zIndex(val) {
  2015. this.originInstance.setZIndex(val);
  2016. },
  2017. massClear(val) {
  2018. val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
  2019. }
  2020. },
  2021. methods: {
  2022. load() {
  2023. const { BMap: BMap2, map, content, title, offset, position, labelStyle, zIndex, massClear, $parent } = this;
  2024. let labelOption = {
  2025. offset: createSize(BMap2, offset),
  2026. position: createPoint(BMap2, position),
  2027. enableMassClear: massClear
  2028. };
  2029. deleteEmptyKey(labelOption);
  2030. const overlay = new BMap2.Label(content, labelOption);
  2031. this.originInstance = overlay;
  2032. try {
  2033. $parent.originInstance.setLabel(overlay);
  2034. } catch (e) {
  2035. map.addOverlay(overlay);
  2036. }
  2037. title && overlay.setTitle(title);
  2038. labelStyle && overlay.setStyle(labelStyle);
  2039. zIndex && overlay.setZIndex(zIndex);
  2040. bindEvents.call(this, overlay);
  2041. }
  2042. }
  2043. };
  2044. const _sfc_main$g = {
  2045. name: "bm-info-window",
  2046. mixins: [commonMixin("overlay")],
  2047. props: {
  2048. show: {
  2049. type: Boolean
  2050. },
  2051. position: {
  2052. type: Object
  2053. },
  2054. title: {
  2055. type: String
  2056. },
  2057. width: {
  2058. type: Number
  2059. },
  2060. height: {
  2061. type: Number
  2062. },
  2063. maxWidth: {
  2064. type: Number
  2065. },
  2066. offset: {
  2067. type: Object
  2068. },
  2069. maximize: {
  2070. type: Boolean
  2071. },
  2072. autoPan: {
  2073. type: Boolean
  2074. },
  2075. closeOnClick: {
  2076. type: Boolean,
  2077. default: true
  2078. },
  2079. message: {
  2080. type: String
  2081. }
  2082. },
  2083. watch: {
  2084. show(val) {
  2085. val ? this.openInfoWindow() : this.closeInfoWindow();
  2086. },
  2087. "position.lng"(val, oldVal) {
  2088. this.reload();
  2089. },
  2090. "position.lat"(val, oldVal) {
  2091. this.reload();
  2092. },
  2093. "offset.width"(val, oldVal) {
  2094. this.reload();
  2095. },
  2096. "offset.height"(val) {
  2097. this.reload();
  2098. },
  2099. maxWidth() {
  2100. this.reload();
  2101. },
  2102. width(val) {
  2103. this.originInstance.setWidth(val);
  2104. },
  2105. height(val) {
  2106. this.originInstance.setHeight(val);
  2107. },
  2108. title(val) {
  2109. this.originInstance.setTitle(val);
  2110. },
  2111. maximize(val) {
  2112. val ? this.originInstance.enableMaximize() : this.originInstance.disableMaximize();
  2113. },
  2114. autoPan(val) {
  2115. val ? this.originInstance.enableAutoPan() : this.originInstance.disableAutoPan();
  2116. },
  2117. closeOnClick(val) {
  2118. val ? this.originInstance.enableCloseOnClick() : this.originInstance.disableCloseOnClick();
  2119. }
  2120. },
  2121. methods: {
  2122. redraw() {
  2123. this.originInstance.redraw();
  2124. },
  2125. load() {
  2126. const { BMap: BMap2, map, show, title, width, height, maxWidth, offset, autoPan, closeOnClick, message, maximize, bindObserver, $parent } = this;
  2127. const $content = this.$el;
  2128. let infoWindowOption = {
  2129. width,
  2130. height,
  2131. title,
  2132. maxWidth,
  2133. offset: offset && createSize(BMap2, offset),
  2134. enableAutoPan: autoPan,
  2135. enableCloseOnClick: closeOnClick,
  2136. enableMessage: typeof message === "undefined",
  2137. message
  2138. };
  2139. deleteEmptyKey(infoWindowOption);
  2140. const overlay = new BMap2.InfoWindow($content, infoWindowOption);
  2141. maximize ? overlay.enableMaximize() : overlay.disableMaximize();
  2142. bindEvents.call(this, overlay);
  2143. this.originInstance = overlay;
  2144. overlay.redraw();
  2145. [].forEach.call($content.querySelectorAll("img"), ($img) => {
  2146. $img.onload = () => overlay.redraw();
  2147. });
  2148. bindObserver();
  2149. this.$container = $parent.originInstance && $parent.originInstance.openInfoWindow ? $parent.originInstance : map;
  2150. show && this.openInfoWindow();
  2151. },
  2152. bindObserver() {
  2153. const MutationObserver = window.MutationObserver;
  2154. if (!MutationObserver) {
  2155. return;
  2156. }
  2157. const { $el, originInstance } = this;
  2158. this.observer = new MutationObserver((mutations) => originInstance.redraw());
  2159. this.observer.observe($el, { attributes: true, childList: true, characterData: true, subtree: true });
  2160. },
  2161. openInfoWindow() {
  2162. const { BMap: BMap2, $container, position, originInstance } = this;
  2163. $container.openInfoWindow(originInstance, createPoint(BMap2, position || this.$parent.position));
  2164. },
  2165. closeInfoWindow() {
  2166. this.$container.closeInfoWindow(this.originInstance);
  2167. }
  2168. }
  2169. };
  2170. function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
  2171. return withDirectives((openBlock(), createElementBlock("div", null, [
  2172. renderSlot(_ctx.$slots, "default")
  2173. ], 512)), [
  2174. [vShow, $props.show]
  2175. ]);
  2176. }
  2177. var BmInfoWindow = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$b]]);
  2178. const _sfc_main$f = {
  2179. name: "bm-overlay",
  2180. emits: ["initialize", "draw"],
  2181. mixins: [commonMixin("overlay")],
  2182. props: {
  2183. pane: {
  2184. type: String
  2185. }
  2186. },
  2187. watch: {
  2188. pane() {
  2189. this.reload();
  2190. }
  2191. },
  2192. methods: {
  2193. load() {
  2194. },
  2195. mountedLoad() {
  2196. const { BMap: BMap2, map, $el, pane } = this;
  2197. const $emit = this.$emit.bind(this);
  2198. class CustomOverlay extends BMap2.Overlay {
  2199. initialize() {
  2200. $emit("initialize", {
  2201. BMap: BMap2,
  2202. map,
  2203. el: $el,
  2204. overlay: this
  2205. });
  2206. try {
  2207. map.getPanes()[pane].appendChild($el);
  2208. } catch (e) {
  2209. }
  2210. return $el;
  2211. }
  2212. draw() {
  2213. $emit("draw", {
  2214. BMap: BMap2,
  2215. map,
  2216. el: $el,
  2217. overlay: this
  2218. });
  2219. }
  2220. }
  2221. const overlay = new CustomOverlay();
  2222. this.originInstance = overlay;
  2223. map.addOverlay(overlay);
  2224. }
  2225. }
  2226. };
  2227. function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
  2228. return openBlock(), createElementBlock("div", null, [
  2229. renderSlot(_ctx.$slots, "default")
  2230. ]);
  2231. }
  2232. var BmOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$a]]);
  2233. const _sfc_main$e = {
  2234. name: "bm-context-menu",
  2235. props: {
  2236. width: {
  2237. type: Number
  2238. }
  2239. },
  2240. mixins: [commonMixin("contextMenu")],
  2241. methods: {
  2242. load() {
  2243. const { width, BMap: BMap2, map, $parent } = this;
  2244. const parent = this.parent = $parent.originInstance || map;
  2245. if (this.originInstance) {
  2246. parent.removeContextMenu(this.originInstance);
  2247. }
  2248. const menu = this.originInstance = new BMap2.ContextMenu();
  2249. if (this.$slots.default) {
  2250. for (const item of this.$slots.default() || []) {
  2251. const props = item.props;
  2252. if (props.seperator) {
  2253. menu.addSeparator();
  2254. continue;
  2255. }
  2256. const menuItem = new BMap2.MenuItem(props.text, function(point, pixel) {
  2257. props.callback && props.callback({
  2258. point,
  2259. pixel,
  2260. BMap: BMap2,
  2261. map,
  2262. target: parent
  2263. });
  2264. }, {
  2265. width,
  2266. id: props.id,
  2267. iconUrl: props.iconUrl
  2268. });
  2269. props.disabled ? menuItem.disable() : menuItem.enable();
  2270. props.originInstance = menuItem;
  2271. menu.addItem(menuItem);
  2272. }
  2273. }
  2274. parent.addContextMenu(menu);
  2275. }
  2276. }
  2277. };
  2278. function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
  2279. return openBlock(), createElementBlock("div", null, [
  2280. renderSlot(_ctx.$slots, "default")
  2281. ]);
  2282. }
  2283. var BmContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
  2284. const _sfc_main$d = {
  2285. name: "bm-context-menu-item",
  2286. props: {
  2287. callback: {
  2288. type: Function,
  2289. default: function() {
  2290. }
  2291. },
  2292. text: {
  2293. type: String
  2294. },
  2295. iconUrl: {
  2296. type: String
  2297. },
  2298. id: {
  2299. type: String
  2300. },
  2301. disabled: {
  2302. type: Boolean
  2303. },
  2304. seperator: {
  2305. type: Boolean
  2306. },
  2307. originInstance: {}
  2308. },
  2309. methods: {
  2310. reload() {
  2311. this.$parent.map && this.$parent.load();
  2312. }
  2313. },
  2314. watch: {
  2315. text() {
  2316. this.reload();
  2317. },
  2318. iconUrl() {
  2319. this.reload();
  2320. },
  2321. id() {
  2322. this.reload();
  2323. },
  2324. disabled() {
  2325. this.reload();
  2326. },
  2327. iseperator() {
  2328. this.reload();
  2329. },
  2330. callback() {
  2331. this.reload();
  2332. }
  2333. },
  2334. destroyed() {
  2335. this.reload();
  2336. },
  2337. mounted() {
  2338. this.reload();
  2339. }
  2340. };
  2341. function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
  2342. return openBlock(), createElementBlock("span", null, [
  2343. renderSlot(_ctx.$slots, "default")
  2344. ]);
  2345. }
  2346. var BmContextMenuItem = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
  2347. const _sfc_main$c = {
  2348. name: "bm-local-search",
  2349. emits: ["markersset", "infohtmlset", "resultshtmlset", "searchcomplete"],
  2350. mixins: [commonMixin("search")],
  2351. props: {
  2352. location: {
  2353. type: [Object, String]
  2354. },
  2355. keyword: {
  2356. type: [Array, String]
  2357. },
  2358. panel: {
  2359. type: Boolean,
  2360. default: true
  2361. },
  2362. forceLocal: {
  2363. type: Boolean
  2364. },
  2365. customData: {
  2366. type: Object
  2367. },
  2368. bounds: {
  2369. type: Object
  2370. },
  2371. nearby: {
  2372. type: Object
  2373. },
  2374. pageCapacity: {
  2375. type: Number
  2376. },
  2377. autoViewport: {
  2378. type: Boolean
  2379. },
  2380. selectFirstResult: {
  2381. type: Boolean
  2382. }
  2383. },
  2384. watch: {
  2385. location: {
  2386. handler(val) {
  2387. const { originInstance, search } = this;
  2388. originInstance.setLocation(val || this.map);
  2389. search();
  2390. },
  2391. deep: true
  2392. },
  2393. keyword() {
  2394. this.search();
  2395. },
  2396. bounds: {
  2397. handler(val) {
  2398. const { searchInBounds } = this;
  2399. searchInBounds(val);
  2400. },
  2401. deep: true
  2402. },
  2403. nearby: {
  2404. handler(val) {
  2405. const { searchNearby } = this;
  2406. searchNearby(val);
  2407. },
  2408. deep: true
  2409. },
  2410. forceLocal() {
  2411. this.reload();
  2412. },
  2413. customData: {
  2414. deep: true,
  2415. handler() {
  2416. this.reload();
  2417. }
  2418. },
  2419. pageCapacity(val) {
  2420. this.originInstance && this.originInstance.setPageCapacity(val);
  2421. },
  2422. autoViewport(val) {
  2423. this.originInstance && (val ? this.originInstance.enableAutoViewport() : this.originInstance.disableAutoViewport());
  2424. },
  2425. selectFirstResult(val) {
  2426. this.originInstance && (val ? this.originInstance.enableFirstResultSelection() : this.originInstance.disableFirstResultSelection());
  2427. },
  2428. highlightMode() {
  2429. this.reload();
  2430. }
  2431. },
  2432. methods: {
  2433. searchNearby(nearby) {
  2434. const { originInstance, keyword, customData, BMap: BMap2 } = this;
  2435. originInstance.searchNearby(keyword, createPoint(BMap2, nearby.center), nearby.radius, customData);
  2436. },
  2437. searchInBounds(bounds) {
  2438. const { originInstance, keyword, customData, BMap: BMap2 } = this;
  2439. originInstance.searchInBounds(keyword, createBounds(BMap2, bounds), customData);
  2440. },
  2441. search() {
  2442. const { originInstance, keyword, forceLocal, customData, nearby, bounds, searchNearby, searchInBounds } = this;
  2443. nearby ? searchNearby(nearby) : bounds ? searchInBounds(bounds) : originInstance.search(keyword, {
  2444. forceLocal,
  2445. customData
  2446. });
  2447. },
  2448. load() {
  2449. const instance2 = this;
  2450. const { map, BMap: BMap2, search, pageCapacity, autoViewport, selectFirstResult, highlightMode, location, originInstance } = this;
  2451. const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
  2452. const route = this.originInstance = new BMap2.LocalSearch(_location, {
  2453. onMarkersSet(e) {
  2454. instance2.$emit("markersset", e);
  2455. },
  2456. onInfoHtmlSet(e) {
  2457. instance2.$emit("infohtmlset", e);
  2458. },
  2459. onResultsHtmlSet(e) {
  2460. instance2.$emit("resultshtmlset", e);
  2461. },
  2462. onSearchComplete(e) {
  2463. if (originInstance && originInstance !== route) {
  2464. originInstance.clearResults();
  2465. }
  2466. instance2.$emit("searchcomplete", e);
  2467. },
  2468. pageCapacity,
  2469. renderOptions: {
  2470. map,
  2471. panel: this.$el,
  2472. selectFirstResult,
  2473. autoViewport,
  2474. highlightMode
  2475. }
  2476. });
  2477. search();
  2478. }
  2479. }
  2480. };
  2481. function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
  2482. return withDirectives((openBlock(), createElementBlock("div", null, [
  2483. renderSlot(_ctx.$slots, "default")
  2484. ], 512)), [
  2485. [vShow, $props.panel]
  2486. ]);
  2487. }
  2488. var BmLocalSearch = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
  2489. const _sfc_main$b = {
  2490. name: "bm-transit",
  2491. emits: ["searchcomplete", "markersset", "infohtmlset", "polylinesset", "resultshtmlset"],
  2492. mixins: [commonMixin("search")],
  2493. props: {
  2494. location: {
  2495. type: [Object, String]
  2496. },
  2497. start: {
  2498. type: [Object, String]
  2499. },
  2500. end: {
  2501. type: [Object, String]
  2502. },
  2503. panel: {
  2504. type: Boolean,
  2505. default: true
  2506. },
  2507. policy: {
  2508. type: String
  2509. },
  2510. pageCapacity: {
  2511. type: Number
  2512. },
  2513. autoViewport: {
  2514. type: Boolean
  2515. },
  2516. selectFirstResult: {
  2517. type: Boolean
  2518. }
  2519. },
  2520. watch: {
  2521. location: {
  2522. handler(val) {
  2523. const { originInstance, map } = this;
  2524. originInstance.setLocation(val || map);
  2525. },
  2526. deep: true
  2527. },
  2528. start: {
  2529. handler(val) {
  2530. const { originInstance, end, BMap: BMap2 } = this;
  2531. originInstance.search(getPosition(BMap2, val), getPosition(BMap2, end));
  2532. },
  2533. deep: true
  2534. },
  2535. end: {
  2536. handler(val) {
  2537. const { originInstance, start, BMap: BMap2 } = this;
  2538. originInstance.search(getPosition(BMap2, start), getPosition(BMap2, val));
  2539. },
  2540. deep: true
  2541. },
  2542. panel() {
  2543. this.reload();
  2544. },
  2545. policy(val) {
  2546. this.originInstance.setPolicy(window[val]);
  2547. },
  2548. pageCapacity(val) {
  2549. this.originInstance && this.originInstance.setPageCapacity(val);
  2550. },
  2551. autoViewport(val) {
  2552. this.originInstance && (val ? this.originInstance.enableAutoViewport() : this.originInstance.disableAutoViewport());
  2553. },
  2554. selectFirstResult() {
  2555. this.reload();
  2556. },
  2557. highlightMode() {
  2558. this.reload();
  2559. }
  2560. },
  2561. methods: {
  2562. search(start, end) {
  2563. const { originInstance } = this;
  2564. originInstance.search(start, end);
  2565. },
  2566. load() {
  2567. const instance2 = this;
  2568. const { map, BMap: BMap2, location, policy, pageCapacity, selectFirstResult, autoViewport, highlightMode, search, start, end, originInstance } = this;
  2569. const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
  2570. const route = this.originInstance = new BMap2.TransitRoute(_location, {
  2571. renderOptions: {
  2572. map,
  2573. panel: this.$el,
  2574. selectFirstResult,
  2575. autoViewport,
  2576. highlightMode
  2577. },
  2578. policy: window[policy],
  2579. pageCapacity,
  2580. onSearchComplete(e) {
  2581. if (originInstance && originInstance !== route) {
  2582. originInstance.clearResults();
  2583. }
  2584. instance2.$emit("searchcomplete", e);
  2585. },
  2586. onMarkersSet(e) {
  2587. instance2.$emit("markersset", e);
  2588. },
  2589. onInfoHtmlSet(e) {
  2590. instance2.$emit("infohtmlset", e);
  2591. },
  2592. onPolylinesSet(e) {
  2593. instance2.$emit("polylinesset", e);
  2594. },
  2595. onResultsHtmlSet(e) {
  2596. instance2.$emit("resultshtmlset", e);
  2597. }
  2598. });
  2599. search(isPoint(start) ? createPoint(BMap2, start) : start, isPoint(end) ? createPoint(BMap2, end) : end);
  2600. }
  2601. }
  2602. };
  2603. function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
  2604. return withDirectives((openBlock(), createElementBlock("div", null, [
  2605. renderSlot(_ctx.$slots, "default")
  2606. ], 512)), [
  2607. [vShow, $props.panel]
  2608. ]);
  2609. }
  2610. var BmTransit = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$6]]);
  2611. const _sfc_main$a = {
  2612. name: "bm-walking",
  2613. emits: ["searchcomplete", "markersset", "infohtmlset", "polylinesset", "resultshtmlset"],
  2614. mixins: [commonMixin("search")],
  2615. props: {
  2616. location: {
  2617. type: [Object, String]
  2618. },
  2619. start: {
  2620. type: [Object, String]
  2621. },
  2622. end: {
  2623. type: [Object, String]
  2624. },
  2625. panel: {
  2626. type: Boolean,
  2627. default: true
  2628. },
  2629. pageCapacity: {
  2630. type: Number
  2631. },
  2632. autoViewport: {
  2633. type: Boolean
  2634. },
  2635. selectFirstResult: {
  2636. type: Boolean
  2637. }
  2638. },
  2639. watch: {
  2640. location: {
  2641. handler(val) {
  2642. const { originInstance, map } = this;
  2643. originInstance.setLocation(val || map);
  2644. },
  2645. deep: true
  2646. },
  2647. start: {
  2648. handler(val) {
  2649. const { originInstance, end, BMap: BMap2 } = this;
  2650. originInstance.search(getPosition(BMap2, val), getPosition(BMap2, end));
  2651. },
  2652. deep: true
  2653. },
  2654. end: {
  2655. handler(val) {
  2656. const { originInstance, start, BMap: BMap2 } = this;
  2657. originInstance.search(getPosition(BMap2, start), getPosition(BMap2, val));
  2658. },
  2659. deep: true
  2660. },
  2661. panel() {
  2662. this.reload();
  2663. },
  2664. autoViewport(val) {
  2665. this.reload();
  2666. },
  2667. selectFirstResult(val) {
  2668. this.reload();
  2669. },
  2670. highlightMode() {
  2671. this.reload();
  2672. }
  2673. },
  2674. methods: {
  2675. search(start, end) {
  2676. const { originInstance } = this;
  2677. originInstance.search(start, end);
  2678. },
  2679. load() {
  2680. const instance2 = this;
  2681. const { map, BMap: BMap2, location, selectFirstResult, autoViewport, highlightMode, search, start, end, originInstance } = this;
  2682. const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
  2683. const route = this.originInstance = new BMap2.WalkingRoute(_location, {
  2684. renderOptions: {
  2685. map,
  2686. panel: this.$el,
  2687. selectFirstResult,
  2688. autoViewport,
  2689. highlightMode
  2690. },
  2691. onSearchComplete(e) {
  2692. if (originInstance && originInstance !== route) {
  2693. originInstance.clearResults();
  2694. }
  2695. instance2.$emit("searchcomplete", e);
  2696. },
  2697. onMarkersSet(e) {
  2698. instance2.$emit("markersset", e);
  2699. },
  2700. onInfoHtmlSet(e) {
  2701. instance2.$emit("infohtmlset", e);
  2702. },
  2703. onPolylinesSet(e) {
  2704. instance2.$emit("polylinesset", e);
  2705. },
  2706. onResultsHtmlSet(e) {
  2707. instance2.$emit("resultshtmlset", e);
  2708. }
  2709. });
  2710. search(isPoint(start) ? createPoint(BMap2, start) : start, isPoint(end) ? createPoint(BMap2, end) : end);
  2711. }
  2712. }
  2713. };
  2714. function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
  2715. return withDirectives((openBlock(), createElementBlock("div", null, [
  2716. renderSlot(_ctx.$slots, "default")
  2717. ], 512)), [
  2718. [vShow, $props.panel]
  2719. ]);
  2720. }
  2721. var BmWalking = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$5]]);
  2722. const _sfc_main$9 = {
  2723. name: "bm-driving",
  2724. emits: ["searchcomplete", "markersset", "infohtmlset", "polylinesset", "resultshtmlset"],
  2725. mixins: [commonMixin("search")],
  2726. props: {
  2727. location: {
  2728. type: [Object, String]
  2729. },
  2730. start: {
  2731. type: [Object, String]
  2732. },
  2733. end: {
  2734. type: [Object, String]
  2735. },
  2736. startCity: {
  2737. type: [String, Number]
  2738. },
  2739. endCity: {
  2740. type: [String, Number]
  2741. },
  2742. waypoints: {
  2743. type: Array
  2744. },
  2745. policy: {
  2746. type: String
  2747. },
  2748. panel: {
  2749. type: Boolean,
  2750. default: true
  2751. },
  2752. autoViewport: {
  2753. type: Boolean
  2754. },
  2755. selectFirstResult: {
  2756. type: Boolean
  2757. }
  2758. },
  2759. watch: {
  2760. location: {
  2761. handler(val) {
  2762. const { originInstance, map } = this;
  2763. originInstance.setLocation(val || map);
  2764. },
  2765. deep: true
  2766. },
  2767. start: {
  2768. handler(val) {
  2769. const { originInstance, end, startCity, endCity, waypoints, BMap: BMap2, getWaypoints } = this;
  2770. originInstance.search(getPosition(BMap2, val), getPosition(BMap2, end), {
  2771. startCity,
  2772. endCity,
  2773. waypoints: getWaypoints(waypoints)
  2774. });
  2775. },
  2776. deep: true
  2777. },
  2778. end: {
  2779. handler(val) {
  2780. const { originInstance, start, startCity, endCity, waypoints, BMap: BMap2, getWaypoints } = this;
  2781. originInstance.search(getPosition(BMap2, start), getPosition(BMap2, val), {
  2782. startCity,
  2783. endCity,
  2784. waypoints: getWaypoints(waypoints)
  2785. });
  2786. },
  2787. deep: true
  2788. },
  2789. startCity(val) {
  2790. const { originInstance, start, end, endCity, waypoints, getWaypoints } = this;
  2791. originInstance.search(start, end, {
  2792. val,
  2793. endCity,
  2794. waypoints: getWaypoints(waypoints)
  2795. });
  2796. },
  2797. endCity(val) {
  2798. const { originInstance, start, end, startCity, waypoints, getWaypoints } = this;
  2799. originInstance.search(start, end, {
  2800. startCity,
  2801. val,
  2802. waypoints: getWaypoints(waypoints)
  2803. });
  2804. },
  2805. waypoints: {
  2806. handler(val) {
  2807. const { originInstance, start, end, startCity, endCity, getWaypoints } = this;
  2808. originInstance.search(start, end, {
  2809. startCity,
  2810. endCity,
  2811. waypoints: getWaypoints(val)
  2812. });
  2813. },
  2814. deep: true
  2815. },
  2816. panel() {
  2817. this.reload();
  2818. },
  2819. policy(val) {
  2820. this.reload();
  2821. },
  2822. autoViewport() {
  2823. this.reload();
  2824. },
  2825. selectFirstResult() {
  2826. this.reload();
  2827. },
  2828. highlightMode() {
  2829. this.reload();
  2830. }
  2831. },
  2832. methods: {
  2833. search(start, end, { startCity, endCity, waypoints }) {
  2834. const { originInstance, getWaypoints } = this;
  2835. originInstance.search(start, end, {
  2836. startCity,
  2837. endCity,
  2838. waypoints: getWaypoints(waypoints)
  2839. });
  2840. },
  2841. getWaypoints(waypoints) {
  2842. const { BMap: BMap2 } = this;
  2843. if (waypoints) {
  2844. return waypoints.map((position) => getPosition(BMap2, position));
  2845. }
  2846. },
  2847. load() {
  2848. const instance2 = this;
  2849. const { map, BMap: BMap2, location, policy, selectFirstResult, autoViewport, highlightMode, search, start, end, startCity, endCity, waypoints, originInstance, getWaypoints } = this;
  2850. const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
  2851. const route = this.originInstance = new BMap2.DrivingRoute(_location, {
  2852. renderOptions: {
  2853. map,
  2854. panel: this.$el,
  2855. selectFirstResult,
  2856. autoViewport,
  2857. highlightMode
  2858. },
  2859. policy: window[policy],
  2860. onSearchComplete(e) {
  2861. if (originInstance && originInstance !== route) {
  2862. originInstance.clearResults();
  2863. }
  2864. instance2.$emit("searchcomplete", e);
  2865. },
  2866. onMarkersSet(e) {
  2867. instance2.$emit("markersset", e);
  2868. },
  2869. onInfoHtmlSet(e) {
  2870. instance2.$emit("infohtmlset", e);
  2871. },
  2872. onPolylinesSet(e) {
  2873. instance2.$emit("polylinesset", e);
  2874. },
  2875. onResultsHtmlSet(e) {
  2876. instance2.$emit("resultshtmlset", e);
  2877. }
  2878. });
  2879. search(getPosition(BMap2, start), getPosition(BMap2, end), {
  2880. startCity,
  2881. endCity,
  2882. waypoints: getWaypoints(waypoints)
  2883. });
  2884. }
  2885. }
  2886. };
  2887. function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
  2888. return withDirectives((openBlock(), createElementBlock("div", null, [
  2889. renderSlot(_ctx.$slots, "default")
  2890. ], 512)), [
  2891. [vShow, $props.panel]
  2892. ]);
  2893. }
  2894. var BmDriving = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$4]]);
  2895. const _sfc_main$8 = {
  2896. name: "bm-bus",
  2897. emits: ["getbuslistcomplete", "getbuslinecomplete", "buslisthtmlset", "buslinehtmlset", "markersset", "polylinesset"],
  2898. mixins: [commonMixin("search")],
  2899. props: {
  2900. location: {
  2901. type: [Object, String]
  2902. },
  2903. keyword: {
  2904. type: String
  2905. },
  2906. panel: {
  2907. type: Boolean,
  2908. default: true
  2909. },
  2910. pageCapacity: {
  2911. type: Number
  2912. },
  2913. autoViewport: {
  2914. type: Boolean
  2915. },
  2916. selectFirstResult: {
  2917. type: Boolean
  2918. }
  2919. },
  2920. watch: {
  2921. location: {
  2922. handler(val) {
  2923. const { originInstance, map } = this;
  2924. originInstance.setLocation(val || map);
  2925. },
  2926. deep: true
  2927. },
  2928. keyword(val) {
  2929. this.search(val);
  2930. },
  2931. panel() {
  2932. this.reload();
  2933. },
  2934. autoViewport(val) {
  2935. this.reload();
  2936. },
  2937. selectFirstResult(val) {
  2938. this.reload();
  2939. }
  2940. },
  2941. methods: {
  2942. search(keyword) {
  2943. const { originInstance } = this;
  2944. originInstance.getBusList(keyword);
  2945. },
  2946. load() {
  2947. const instance2 = this;
  2948. const { location, selectFirstResult, autoViewport, highlightMode, keyword, search, BMap: BMap2, map, originInstance } = this;
  2949. const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
  2950. const route = this.originInstance = new BMap2.BusLineSearch(_location, {
  2951. renderOptions: {
  2952. map,
  2953. panel: this.$el,
  2954. selectFirstResult,
  2955. autoViewport,
  2956. highlightMode
  2957. },
  2958. onGetBusListComplete(e) {
  2959. if (originInstance && originInstance !== route) {
  2960. originInstance.clearResults();
  2961. }
  2962. instance2.$emit("getbuslistcomplete", e);
  2963. },
  2964. onGetBusLineComplete(e) {
  2965. if (originInstance && originInstance !== route) {
  2966. originInstance.clearResults();
  2967. }
  2968. instance2.$emit("getbuslinecomplete", e);
  2969. },
  2970. onBusListHtmlSet(e) {
  2971. instance2.$emit("buslisthtmlset", e);
  2972. },
  2973. onBusLineHtmlSet(e) {
  2974. instance2.$emit("buslinehtmlset", e);
  2975. },
  2976. onMarkersSet(e) {
  2977. instance2.$emit("markersset", e);
  2978. },
  2979. onPolylinesSet(e) {
  2980. instance2.$emit("polylinesset", e);
  2981. }
  2982. });
  2983. search(keyword);
  2984. }
  2985. }
  2986. };
  2987. function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  2988. return withDirectives((openBlock(), createElementBlock("div", null, null, 512)), [
  2989. [vShow, $props.panel]
  2990. ]);
  2991. }
  2992. var BmBus = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$3]]);
  2993. const _sfc_main$7 = {
  2994. name: "bm-tile",
  2995. render(h) {
  2996. },
  2997. mixins: [commonMixin("layer")],
  2998. props: {
  2999. transparentPng: {
  3000. type: Boolean
  3001. },
  3002. tileUrlTemplate: {
  3003. type: String
  3004. },
  3005. copyright: {},
  3006. zIndex: {
  3007. type: Number
  3008. }
  3009. },
  3010. watch: {
  3011. transparentPng() {
  3012. this.reload();
  3013. },
  3014. tileUrlTemplate() {
  3015. this.reload();
  3016. },
  3017. copyright() {
  3018. this.reload();
  3019. },
  3020. zIndex() {
  3021. this.reload();
  3022. }
  3023. },
  3024. methods: {
  3025. load() {
  3026. const { BMap: BMap2, map, transparentPng, tileUrlTemplate, copyright, zIndex } = this;
  3027. this.originInstance = new BMap2.TileLayer({
  3028. transparentPng,
  3029. tileUrlTemplate,
  3030. copyright: copyright && {
  3031. id: copyright.id,
  3032. content: copyright.content,
  3033. bounds: copyright.bounds && createBounds(copyright.bounds)
  3034. },
  3035. zIndex
  3036. });
  3037. map.addTileLayer(this.originInstance);
  3038. }
  3039. }
  3040. };
  3041. const _sfc_main$6 = {
  3042. name: "bm-triffic",
  3043. render(h) {
  3044. },
  3045. mixins: [commonMixin("layer")],
  3046. props: {
  3047. predictDate: {
  3048. type: Object
  3049. }
  3050. },
  3051. watch: {
  3052. "pridictDate.weekday"() {
  3053. this.reload();
  3054. },
  3055. "pridictDate.hour"() {
  3056. this.reload();
  3057. },
  3058. pridictDate() {
  3059. this.reload();
  3060. }
  3061. },
  3062. methods: {
  3063. load() {
  3064. const { pridictDate, BMap: BMap2, map } = this;
  3065. this.originInstance = new BMap2.TrafficLayer({
  3066. pridictDate
  3067. });
  3068. map.addTileLayer(this.originInstance);
  3069. }
  3070. }
  3071. };
  3072. const _sfc_main$5 = {
  3073. mixins: [
  3074. commonMixin("abstract")
  3075. ],
  3076. emits: ["click", "dblclick", "mousedown", "mouseup", "mouseout", "mouseover", "remove", "load"],
  3077. props: ["name", "strokeColor", "strokeWeight", "strokeOpacity", "strokeStyle", "fillColor", "fillOpacity", "massClear", "clicking"],
  3078. data() {
  3079. return {
  3080. paths: []
  3081. };
  3082. },
  3083. components: {
  3084. BmPolygon: _sfc_main$k
  3085. },
  3086. watch: {
  3087. name() {
  3088. this.reload();
  3089. }
  3090. },
  3091. methods: {
  3092. load() {
  3093. const { BMap: BMap2, name } = this;
  3094. const bd = new BMap2.Boundary();
  3095. bd.get(name, (data) => {
  3096. const paths = data.boundaries.map((boundary) => (boundary || []).split(";").map((point) => (([lng, lat]) => ({ lng, lat }))(point.split(",").map((p) => +p))));
  3097. this.paths = paths;
  3098. this.$emit("load", { boundaries: data.boundaries, paths: [...paths] });
  3099. });
  3100. }
  3101. }
  3102. };
  3103. const _hoisted_1$1 = { key: 0 };
  3104. function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  3105. const _component_bm_polygon = resolveComponent("bm-polygon");
  3106. return $data.paths.length ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
  3107. (openBlock(true), createElementBlock(Fragment, null, renderList($data.paths, (path, index2) => {
  3108. return openBlock(), createBlock(_component_bm_polygon, {
  3109. key: index2,
  3110. path,
  3111. "stroke-color": $props.strokeColor,
  3112. "stroke-weight": $props.strokeWeight,
  3113. "stroke-opacity": $props.strokeOpacity,
  3114. "stroke-style": $props.strokeStyle,
  3115. "fill-opacity": $props.fillOpacity,
  3116. "fill-color": $props.fillColor,
  3117. "mass-clear": $props.massClear,
  3118. clicking: $props.clicking,
  3119. onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click", $event)),
  3120. onDblclick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("dblclick", $event)),
  3121. onMousedown: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("mousedown", $event)),
  3122. onMouseup: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("mouseup", $event)),
  3123. onMouseout: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("mouseout", $event)),
  3124. onMouseover: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("mouseover", $event)),
  3125. onRemove: _cache[6] || (_cache[6] = ($event) => _ctx.$emit("remove", $event))
  3126. }, null, 8, ["path", "stroke-color", "stroke-weight", "stroke-opacity", "stroke-style", "fill-opacity", "fill-color", "mass-clear", "clicking"]);
  3127. }), 128))
  3128. ])) : createCommentVNode("", true);
  3129. }
  3130. var BmBoundary = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$2]]);
  3131. const _sfc_main$4 = {
  3132. name: "bm-autocomplete",
  3133. mixins: [commonMixin("autoComplete")],
  3134. emits: ["update:modelValue", "searchcomplete"],
  3135. props: {
  3136. types: {
  3137. type: String
  3138. },
  3139. location: {
  3140. type: String
  3141. },
  3142. sugStyle: {
  3143. type: Object,
  3144. default() {
  3145. return {};
  3146. }
  3147. },
  3148. modelValue: {}
  3149. },
  3150. watch: {
  3151. types() {
  3152. this.reload();
  3153. },
  3154. location() {
  3155. this.reload();
  3156. }
  3157. },
  3158. methods: {
  3159. load() {
  3160. const { BMap: BMap2, map, $el, types: types2, location, sugStyle } = this;
  3161. const input = $el.querySelector("input");
  3162. if (!input) {
  3163. return;
  3164. }
  3165. this.originInstance = new BMap2.Autocomplete({
  3166. input,
  3167. types: types2,
  3168. location: location || map,
  3169. onSearchComplete: (e) => {
  3170. const $sugs = document.querySelectorAll(".tangram-suggestion-main");
  3171. for (const $sug of $sugs) {
  3172. for (const name in sugStyle) {
  3173. $sug.style[name] = sugStyle[name].toString();
  3174. }
  3175. }
  3176. this.$emit("searchcomplete", e);
  3177. }
  3178. });
  3179. this.originInstance.addEventListener("onconfirm", (e) => {
  3180. const val = e.item.value;
  3181. this.$emit("update:modelValue", val.province + val.city + val.district + val.street + val.business);
  3182. });
  3183. bindEvents.call(this, this.originInstance);
  3184. }
  3185. }
  3186. };
  3187. const _hoisted_1 = /* @__PURE__ */ createElementVNode("input", null, null, -1);
  3188. function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  3189. return openBlock(), createElementBlock("span", null, [
  3190. renderSlot(_ctx.$slots, "default", {}, () => [
  3191. _hoisted_1
  3192. ])
  3193. ]);
  3194. }
  3195. var BmAutoComplete = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$1]]);
  3196. var bmaplib_markerclusterer = { exports: {} };
  3197. (function(module, exports) {
  3198. (function(global2, factory) {
  3199. module.exports = factory();
  3200. })(commonjsGlobal, function() {
  3201. var __commonjs_global = typeof window !== "undefined" ? window : typeof commonjsGlobal !== "undefined" ? commonjsGlobal : this;
  3202. function __commonjs(fn, module2) {
  3203. return module2 = { exports: {} }, fn(module2, module2.exports, __commonjs_global), module2.exports;
  3204. }
  3205. var index$1 = __commonjs(function(module2, exports2, global2) {
  3206. (function(root, factory) {
  3207. if (typeof exports2 === "object") {
  3208. module2.exports = factory();
  3209. } else {
  3210. root.BMapLib = root.BMapLib || {};
  3211. root.BMapLib.TextIconOverlay = root.BMapLib.TextIconOverlay || factory();
  3212. }
  3213. })(__commonjs_global, function() {
  3214. var T, baidu = T = baidu || { version: "1.3.8" };
  3215. var context = {};
  3216. baidu.guid = "$BAIDU$";
  3217. context[baidu.guid] = context[baidu.guid] || {};
  3218. baidu.dom = baidu.dom || {};
  3219. baidu.dom.g = function(id) {
  3220. if (typeof id == "string" || id instanceof String) {
  3221. return document.getElementById(id);
  3222. } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) {
  3223. return id;
  3224. }
  3225. return null;
  3226. };
  3227. baidu.g = baidu.G = baidu.dom.g;
  3228. baidu.dom.getDocument = function(element) {
  3229. element = baidu.dom.g(element);
  3230. return element.nodeType == 9 ? element : element.ownerDocument || element.document;
  3231. };
  3232. baidu.lang = baidu.lang || {};
  3233. baidu.lang.isString = function(source) {
  3234. return Object.prototype.toString.call(source) == "[object String]";
  3235. };
  3236. baidu.isString = baidu.lang.isString;
  3237. baidu.dom._g = function(id) {
  3238. if (baidu.lang.isString(id)) {
  3239. return document.getElementById(id);
  3240. }
  3241. return id;
  3242. };
  3243. baidu._g = baidu.dom._g;
  3244. baidu.browser = baidu.browser || {};
  3245. if (/msie (\d+\.\d)/i.test(navigator.userAgent)) {
  3246. baidu.browser.ie = baidu.ie = document.documentMode || +RegExp["$1"];
  3247. }
  3248. baidu.dom.getComputedStyle = function(element, key) {
  3249. element = baidu.dom._g(element);
  3250. var doc = baidu.dom.getDocument(element), styles;
  3251. if (doc.defaultView && doc.defaultView.getComputedStyle) {
  3252. styles = doc.defaultView.getComputedStyle(element, null);
  3253. if (styles) {
  3254. return styles[key] || styles.getPropertyValue(key);
  3255. }
  3256. }
  3257. return "";
  3258. };
  3259. baidu.dom._styleFixer = baidu.dom._styleFixer || {};
  3260. baidu.dom._styleFilter = baidu.dom._styleFilter || [];
  3261. baidu.dom._styleFilter.filter = function(key, value, method) {
  3262. for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) {
  3263. if (filter = filter[method]) {
  3264. value = filter(key, value);
  3265. }
  3266. }
  3267. return value;
  3268. };
  3269. baidu.string = baidu.string || {};
  3270. baidu.string.toCamelCase = function(source) {
  3271. if (source.indexOf("-") < 0 && source.indexOf("_") < 0) {
  3272. return source;
  3273. }
  3274. return source.replace(/[-_][^-_]/g, function(match) {
  3275. return match.charAt(1).toUpperCase();
  3276. });
  3277. };
  3278. baidu.dom.getStyle = function(element, key) {
  3279. var dom = baidu.dom;
  3280. element = dom.g(element);
  3281. key = baidu.string.toCamelCase(key);
  3282. var value = element.style[key] || (element.currentStyle ? element.currentStyle[key] : "") || dom.getComputedStyle(element, key);
  3283. if (!value) {
  3284. var fixer = dom._styleFixer[key];
  3285. if (fixer) {
  3286. value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer);
  3287. }
  3288. }
  3289. if (fixer = dom._styleFilter) {
  3290. value = fixer.filter(key, value, "get");
  3291. }
  3292. return value;
  3293. };
  3294. baidu.getStyle = baidu.dom.getStyle;
  3295. if (/opera\/(\d+\.\d)/i.test(navigator.userAgent)) {
  3296. baidu.browser.opera = +RegExp["$1"];
  3297. }
  3298. baidu.browser.isWebkit = /webkit/i.test(navigator.userAgent);
  3299. baidu.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent);
  3300. baidu.browser.isStrict = document.compatMode == "CSS1Compat";
  3301. baidu.dom.getPosition = function(element) {
  3302. element = baidu.dom.g(element);
  3303. var doc = baidu.dom.getDocument(element), browser = baidu.browser, getStyle = baidu.dom.getStyle;
  3304. browser.isGecko > 0 && doc.getBoxObjectFor && getStyle(element, "position") == "absolute" && (element.style.top === "" || element.style.left === "");
  3305. var pos = { "left": 0, "top": 0 }, viewport = browser.ie && !browser.isStrict ? doc.body : doc.documentElement, parent, box;
  3306. if (element == viewport) {
  3307. return pos;
  3308. }
  3309. if (element.getBoundingClientRect) {
  3310. box = element.getBoundingClientRect();
  3311. pos.left = Math.floor(box.left) + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
  3312. pos.top = Math.floor(box.top) + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
  3313. pos.left -= doc.documentElement.clientLeft;
  3314. pos.top -= doc.documentElement.clientTop;
  3315. var htmlDom = doc.body, htmlBorderLeftWidth = parseInt(getStyle(htmlDom, "borderLeftWidth")), htmlBorderTopWidth = parseInt(getStyle(htmlDom, "borderTopWidth"));
  3316. if (browser.ie && !browser.isStrict) {
  3317. pos.left -= isNaN(htmlBorderLeftWidth) ? 2 : htmlBorderLeftWidth;
  3318. pos.top -= isNaN(htmlBorderTopWidth) ? 2 : htmlBorderTopWidth;
  3319. }
  3320. } else {
  3321. parent = element;
  3322. do {
  3323. pos.left += parent.offsetLeft;
  3324. pos.top += parent.offsetTop;
  3325. if (browser.isWebkit > 0 && getStyle(parent, "position") == "fixed") {
  3326. pos.left += doc.body.scrollLeft;
  3327. pos.top += doc.body.scrollTop;
  3328. break;
  3329. }
  3330. parent = parent.offsetParent;
  3331. } while (parent && parent != element);
  3332. if (browser.opera > 0 || browser.isWebkit > 0 && getStyle(element, "position") == "absolute") {
  3333. pos.top -= doc.body.offsetTop;
  3334. }
  3335. parent = element.offsetParent;
  3336. while (parent && parent != doc.body) {
  3337. pos.left -= parent.scrollLeft;
  3338. if (!browser.opera || parent.tagName != "TR") {
  3339. pos.top -= parent.scrollTop;
  3340. }
  3341. parent = parent.offsetParent;
  3342. }
  3343. }
  3344. return pos;
  3345. };
  3346. baidu.event = baidu.event || {};
  3347. baidu.event._listeners = baidu.event._listeners || [];
  3348. baidu.event.on = function(element, type, listener) {
  3349. type = type.replace(/^on/i, "");
  3350. element = baidu.dom._g(element);
  3351. var realListener = function(ev) {
  3352. listener.call(element, ev);
  3353. }, lis = baidu.event._listeners, filter = baidu.event._eventFilter, afterFilter, realType = type;
  3354. type = type.toLowerCase();
  3355. if (filter && filter[type]) {
  3356. afterFilter = filter[type](element, type, realListener);
  3357. realType = afterFilter.type;
  3358. realListener = afterFilter.listener;
  3359. }
  3360. if (element.addEventListener) {
  3361. element.addEventListener(realType, realListener, false);
  3362. } else if (element.attachEvent) {
  3363. element.attachEvent("on" + realType, realListener);
  3364. }
  3365. lis[lis.length] = [element, type, listener, realListener, realType];
  3366. return element;
  3367. };
  3368. baidu.on = baidu.event.on;
  3369. (function() {
  3370. var guid = context[baidu.guid];
  3371. baidu.lang.guid = function() {
  3372. return "TANGRAM__" + (guid._counter++).toString(36);
  3373. };
  3374. guid._counter = guid._counter || 1;
  3375. })();
  3376. context[baidu.guid]._instances = context[baidu.guid]._instances || {};
  3377. baidu.lang.isFunction = function(source) {
  3378. return Object.prototype.toString.call(source) == "[object Function]";
  3379. };
  3380. baidu.lang.Class = function(guid) {
  3381. this.guid = guid || baidu.lang.guid();
  3382. context[baidu.guid]._instances[this.guid] = this;
  3383. };
  3384. context[baidu.guid]._instances = context[baidu.guid]._instances || {};
  3385. baidu.lang.Class.prototype.dispose = function() {
  3386. delete context[baidu.guid]._instances[this.guid];
  3387. for (var property in this) {
  3388. if (!baidu.lang.isFunction(this[property])) {
  3389. delete this[property];
  3390. }
  3391. }
  3392. this.disposed = true;
  3393. };
  3394. baidu.lang.Class.prototype.toString = function() {
  3395. return "[object " + (this._className || "Object") + "]";
  3396. };
  3397. baidu.lang.Event = function(type, target) {
  3398. this.type = type;
  3399. this.returnValue = true;
  3400. this.target = target || null;
  3401. this.currentTarget = null;
  3402. };
  3403. baidu.lang.Class.prototype.addEventListener = function(type, handler, key) {
  3404. if (!baidu.lang.isFunction(handler)) {
  3405. return;
  3406. }
  3407. !this.__listeners && (this.__listeners = {});
  3408. var t = this.__listeners, id;
  3409. if (typeof key == "string" && key) {
  3410. if (/[^\w\-]/.test(key)) {
  3411. throw "nonstandard key:" + key;
  3412. } else {
  3413. handler.hashCode = key;
  3414. id = key;
  3415. }
  3416. }
  3417. type.indexOf("on") != 0 && (type = "on" + type);
  3418. typeof t[type] != "object" && (t[type] = {});
  3419. id = id || baidu.lang.guid();
  3420. handler.hashCode = id;
  3421. t[type][id] = handler;
  3422. };
  3423. baidu.lang.Class.prototype.removeEventListener = function(type, handler) {
  3424. if (typeof handler != "undefined") {
  3425. if (baidu.lang.isFunction(handler) && !(handler = handler.hashCode) || !baidu.lang.isString(handler)) {
  3426. return;
  3427. }
  3428. }
  3429. !this.__listeners && (this.__listeners = {});
  3430. type.indexOf("on") != 0 && (type = "on" + type);
  3431. var t = this.__listeners;
  3432. if (!t[type]) {
  3433. return;
  3434. }
  3435. if (typeof handler != "undefined") {
  3436. t[type][handler] && delete t[type][handler];
  3437. } else {
  3438. for (var guid in t[type]) {
  3439. delete t[type][guid];
  3440. }
  3441. }
  3442. };
  3443. baidu.lang.Class.prototype.dispatchEvent = function(event, options) {
  3444. if (baidu.lang.isString(event)) {
  3445. event = new baidu.lang.Event(event);
  3446. }
  3447. !this.__listeners && (this.__listeners = {});
  3448. options = options || {};
  3449. for (var i in options) {
  3450. event[i] = options[i];
  3451. }
  3452. var i, t = this.__listeners, p = event.type;
  3453. event.target = event.target || this;
  3454. event.currentTarget = this;
  3455. p.indexOf("on") != 0 && (p = "on" + p);
  3456. baidu.lang.isFunction(this[p]) && this[p].apply(this, arguments);
  3457. if (typeof t[p] == "object") {
  3458. for (i in t[p]) {
  3459. t[p][i].apply(this, arguments);
  3460. }
  3461. }
  3462. return event.returnValue;
  3463. };
  3464. baidu.lang.inherits = function(subClass, superClass, className) {
  3465. var key, proto, selfProps = subClass.prototype, clazz = new Function();
  3466. clazz.prototype = superClass.prototype;
  3467. proto = subClass.prototype = new clazz();
  3468. for (key in selfProps) {
  3469. proto[key] = selfProps[key];
  3470. }
  3471. subClass.prototype.constructor = subClass;
  3472. subClass.superClass = superClass.prototype;
  3473. if (typeof className == "string") {
  3474. proto._className = className;
  3475. }
  3476. };
  3477. baidu.inherits = baidu.lang.inherits;
  3478. var _IMAGE_PATH = "http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m";
  3479. var _IMAGE_EXTENSION = "png";
  3480. var TextIconOverlay2 = function(position, text, options) {
  3481. try {
  3482. BMap;
  3483. } catch (e) {
  3484. throw Error("Baidu Map JS API is not ready yet!");
  3485. }
  3486. T.lang.inherits(TextIconOverlay2, BMap.Overlay, "TextIconOverlay");
  3487. this._position = position;
  3488. this._text = text;
  3489. this._options = options || {};
  3490. this._styles = this._options["styles"] || [];
  3491. !this._styles.length && this._setupDefaultStyles();
  3492. };
  3493. TextIconOverlay2.prototype._setupDefaultStyles = function() {
  3494. var sizes = [53, 56, 66, 78, 90];
  3495. for (var i = 0, size; size = sizes[i]; i++) {
  3496. this._styles.push({
  3497. url: _IMAGE_PATH + i + "." + _IMAGE_EXTENSION,
  3498. size: new BMap.Size(size, size)
  3499. });
  3500. }
  3501. };
  3502. TextIconOverlay2.prototype.initialize = function(map) {
  3503. this._map = map;
  3504. this._domElement = document.createElement("div");
  3505. this._updateCss();
  3506. this._updateText();
  3507. this._updatePosition();
  3508. this._bind();
  3509. this._map.getPanes().markerMouseTarget.appendChild(this._domElement);
  3510. return this._domElement;
  3511. };
  3512. TextIconOverlay2.prototype.draw = function() {
  3513. this._map && this._updatePosition();
  3514. };
  3515. TextIconOverlay2.prototype.getText = function() {
  3516. return this._text;
  3517. };
  3518. TextIconOverlay2.prototype.setText = function(text) {
  3519. if (text && (!this._text || this._text.toString() != text.toString())) {
  3520. this._text = text;
  3521. this._updateText();
  3522. this._updateCss();
  3523. this._updatePosition();
  3524. }
  3525. };
  3526. TextIconOverlay2.prototype.getPosition = function() {
  3527. return this._position;
  3528. };
  3529. TextIconOverlay2.prototype.setPosition = function(position) {
  3530. if (position && (!this._position || !this._position.equals(position))) {
  3531. this._position = position;
  3532. this._updatePosition();
  3533. }
  3534. };
  3535. TextIconOverlay2.prototype.getStyleByText = function(text, styles) {
  3536. var count = parseInt(text);
  3537. var index2 = parseInt(count / 10);
  3538. index2 = Math.max(0, index2);
  3539. index2 = Math.min(index2, styles.length - 1);
  3540. return styles[index2];
  3541. };
  3542. TextIconOverlay2.prototype._updateCss = function() {
  3543. if (!this._domElement) {
  3544. return;
  3545. }
  3546. var style = this.getStyleByText(this._text, this._styles);
  3547. this._domElement.style.cssText = this._buildCssText(style);
  3548. };
  3549. TextIconOverlay2.prototype._updateText = function() {
  3550. if (this._domElement) {
  3551. this._domElement.innerHTML = this._text;
  3552. }
  3553. };
  3554. TextIconOverlay2.prototype._updatePosition = function() {
  3555. if (this._domElement && this._position) {
  3556. var style = this._domElement.style;
  3557. var pixelPosition = this._map.pointToOverlayPixel(this._position);
  3558. pixelPosition.x -= Math.ceil(parseInt(style.width) / 2);
  3559. pixelPosition.y -= Math.ceil(parseInt(style.height) / 2);
  3560. style.left = pixelPosition.x + "px";
  3561. style.top = pixelPosition.y + "px";
  3562. }
  3563. };
  3564. TextIconOverlay2.prototype._buildCssText = function(style) {
  3565. var url = style["url"];
  3566. var size = style["size"];
  3567. var anchor = style["anchor"];
  3568. var offset = style["offset"];
  3569. var textColor = style["textColor"] || "black";
  3570. var textSize = style["textSize"] || 10;
  3571. var csstext = [];
  3572. if (T.browser["ie"] < 7) {
  3573. csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="' + url + '");');
  3574. } else {
  3575. csstext.push("background-image:url(" + url + ");");
  3576. var backgroundPosition = "0 0";
  3577. offset instanceof BMap.Size && (backgroundPosition = offset.width + "px " + offset.height + "px");
  3578. csstext.push("background-position:" + backgroundPosition + ";");
  3579. }
  3580. if (size instanceof BMap.Size) {
  3581. if (anchor instanceof BMap.Size) {
  3582. if (anchor.height > 0 && anchor.height < size.height) {
  3583. csstext.push("height:" + (size.height - anchor.height) + "px; padding-top:" + anchor.height + "px;");
  3584. }
  3585. if (anchor.width > 0 && anchor.width < size.width) {
  3586. csstext.push("width:" + (size.width - anchor.width) + "px; padding-left:" + anchor.width + "px;");
  3587. }
  3588. } else {
  3589. csstext.push("height:" + size.height + "px; line-height:" + size.height + "px;");
  3590. csstext.push("width:" + size.width + "px; text-align:center;");
  3591. }
  3592. }
  3593. csstext.push("cursor:pointer; color:" + textColor + "; position:absolute; font-size:" + textSize + "px; font-family:Arial,sans-serif; font-weight:bold");
  3594. return csstext.join("");
  3595. };
  3596. TextIconOverlay2.prototype._bind = function() {
  3597. if (!this._domElement) {
  3598. return;
  3599. }
  3600. var me = this;
  3601. var map = this._map;
  3602. var BaseEvent = T.lang.Event;
  3603. function eventExtend(e, be) {
  3604. var elem = e.srcElement || e.target;
  3605. var x = e.clientX || e.pageX;
  3606. var y = e.clientY || e.pageY;
  3607. if (e && be && x && y && elem) {
  3608. var offset = T.dom.getPosition(map.getContainer());
  3609. be.pixel = new BMap.Pixel(x - offset.left, y - offset.top);
  3610. be.point = map.pixelToPoint(be.pixel);
  3611. }
  3612. return be;
  3613. }
  3614. T.event.on(this._domElement, "mouseover", function(e) {
  3615. me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseover")));
  3616. });
  3617. T.event.on(this._domElement, "mouseout", function(e) {
  3618. me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseout")));
  3619. });
  3620. T.event.on(this._domElement, "click", function(e) {
  3621. me.dispatchEvent(eventExtend(e, new BaseEvent("onclick")));
  3622. });
  3623. };
  3624. return TextIconOverlay2;
  3625. });
  3626. });
  3627. var TextIconOverlay = index$1 && typeof index$1 === "object" && "default" in index$1 ? index$1["default"] : index$1;
  3628. var getExtendedBounds = function(map, bounds, gridSize) {
  3629. bounds = cutBoundsInRange(bounds);
  3630. var pixelNE = map.pointToPixel(bounds.getNorthEast());
  3631. var pixelSW = map.pointToPixel(bounds.getSouthWest());
  3632. pixelNE.x += gridSize;
  3633. pixelNE.y -= gridSize;
  3634. pixelSW.x -= gridSize;
  3635. pixelSW.y += gridSize;
  3636. var newNE = map.pixelToPoint(pixelNE);
  3637. var newSW = map.pixelToPoint(pixelSW);
  3638. return new BMap.Bounds(newSW, newNE);
  3639. };
  3640. var cutBoundsInRange = function(bounds) {
  3641. var maxX = getRange(bounds.getNorthEast().lng, -180, 180);
  3642. var minX = getRange(bounds.getSouthWest().lng, -180, 180);
  3643. var maxY = getRange(bounds.getNorthEast().lat, -74, 74);
  3644. var minY = getRange(bounds.getSouthWest().lat, -74, 74);
  3645. return new BMap.Bounds(new BMap.Point(minX, minY), new BMap.Point(maxX, maxY));
  3646. };
  3647. var getRange = function(i, mix, max) {
  3648. mix && (i = Math.max(i, mix));
  3649. max && (i = Math.min(i, max));
  3650. return i;
  3651. };
  3652. var isArray = function(source) {
  3653. return Object.prototype.toString.call(source) === "[object Array]";
  3654. };
  3655. var indexOf = function(item, source) {
  3656. var index2 = -1;
  3657. if (isArray(source)) {
  3658. if (source.indexOf) {
  3659. index2 = source.indexOf(item);
  3660. } else {
  3661. for (var i = 0, m; m = source[i]; i++) {
  3662. if (m === item) {
  3663. index2 = i;
  3664. break;
  3665. }
  3666. }
  3667. }
  3668. }
  3669. return index2;
  3670. };
  3671. var MarkerClusterer2 = function(map, options) {
  3672. try {
  3673. BMap;
  3674. } catch (e) {
  3675. throw Error("Baidu Map JS API is not ready yet!");
  3676. }
  3677. if (!map) {
  3678. return;
  3679. }
  3680. this._map = map;
  3681. this._markers = [];
  3682. this._clusters = [];
  3683. var opts = options || {};
  3684. this._gridSize = opts["gridSize"] || 60;
  3685. this._maxZoom = opts["maxZoom"] || 18;
  3686. this._minClusterSize = opts["minClusterSize"] || 2;
  3687. this._isAverageCenter = false;
  3688. if (opts["isAverageCenter"] != void 0) {
  3689. this._isAverageCenter = opts["isAverageCenter"];
  3690. }
  3691. this._styles = opts["styles"] || [];
  3692. var that = this;
  3693. this._map.addEventListener("zoomend", function() {
  3694. that._redraw();
  3695. });
  3696. this._map.addEventListener("moveend", function() {
  3697. that._redraw();
  3698. });
  3699. var mkrs = opts["markers"];
  3700. isArray(mkrs) && this.addMarkers(mkrs);
  3701. };
  3702. MarkerClusterer2.prototype.addMarkers = function(markers2) {
  3703. if (!markers2.length) {
  3704. return;
  3705. }
  3706. for (var i = 0, len = markers2.length; i < len; i++) {
  3707. this._pushMarkerTo(markers2[i]);
  3708. }
  3709. this._createClusters();
  3710. };
  3711. MarkerClusterer2.prototype._pushMarkerTo = function(marker) {
  3712. var index2 = indexOf(marker, this._markers);
  3713. if (index2 === -1) {
  3714. marker.isInCluster = false;
  3715. this._markers.push(marker);
  3716. }
  3717. };
  3718. MarkerClusterer2.prototype.addMarker = function(marker) {
  3719. this._pushMarkerTo(marker);
  3720. this._createClusters();
  3721. };
  3722. MarkerClusterer2.prototype._createClusters = function() {
  3723. var mapBounds = this._map.getBounds();
  3724. if (!mapBounds.getCenter()) {
  3725. return;
  3726. }
  3727. var extendedBounds = getExtendedBounds(this._map, mapBounds, this._gridSize);
  3728. for (var i = 0, marker; marker = this._markers[i]; i++) {
  3729. if (!marker.isInCluster && extendedBounds.containsPoint(marker.getPosition())) {
  3730. this._addToClosestCluster(marker);
  3731. }
  3732. }
  3733. };
  3734. MarkerClusterer2.prototype._addToClosestCluster = function(marker) {
  3735. var distance = 4e6;
  3736. var clusterToAddTo = null;
  3737. marker.getPosition();
  3738. for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
  3739. var center = cluster.getCenter();
  3740. if (center) {
  3741. var d = this._map.getDistance(center, marker.getPosition());
  3742. if (d < distance) {
  3743. distance = d;
  3744. clusterToAddTo = cluster;
  3745. }
  3746. }
  3747. }
  3748. if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
  3749. clusterToAddTo.addMarker(marker);
  3750. } else {
  3751. var cluster = new Cluster(this);
  3752. cluster.addMarker(marker);
  3753. this._clusters.push(cluster);
  3754. }
  3755. };
  3756. MarkerClusterer2.prototype._clearLastClusters = function() {
  3757. for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
  3758. cluster.remove();
  3759. }
  3760. this._clusters = [];
  3761. this._removeMarkersFromCluster();
  3762. };
  3763. MarkerClusterer2.prototype._removeMarkersFromCluster = function() {
  3764. for (var i = 0, marker; marker = this._markers[i]; i++) {
  3765. marker.isInCluster = false;
  3766. }
  3767. };
  3768. MarkerClusterer2.prototype._removeMarkersFromMap = function() {
  3769. for (var i = 0, marker; marker = this._markers[i]; i++) {
  3770. marker.isInCluster = false;
  3771. var label = marker.getLabel();
  3772. this._map.removeOverlay(marker);
  3773. marker.setLabel(label);
  3774. }
  3775. };
  3776. MarkerClusterer2.prototype._removeMarker = function(marker) {
  3777. var index2 = indexOf(marker, this._markers);
  3778. if (index2 === -1) {
  3779. return false;
  3780. }
  3781. this._map.removeOverlay(marker);
  3782. this._markers.splice(index2, 1);
  3783. return true;
  3784. };
  3785. MarkerClusterer2.prototype.removeMarker = function(marker) {
  3786. var success = this._removeMarker(marker);
  3787. if (success) {
  3788. this._clearLastClusters();
  3789. this._createClusters();
  3790. }
  3791. return success;
  3792. };
  3793. MarkerClusterer2.prototype.removeMarkers = function(markers2) {
  3794. var success = false;
  3795. for (var i = 0; i < markers2.length; i++) {
  3796. var r = this._removeMarker(markers2[i]);
  3797. success = success || r;
  3798. }
  3799. if (success) {
  3800. this._clearLastClusters();
  3801. this._createClusters();
  3802. }
  3803. return success;
  3804. };
  3805. MarkerClusterer2.prototype.clearMarkers = function() {
  3806. this._clearLastClusters();
  3807. this._removeMarkersFromMap();
  3808. this._markers = [];
  3809. };
  3810. MarkerClusterer2.prototype._redraw = function() {
  3811. this._clearLastClusters();
  3812. this._createClusters();
  3813. };
  3814. MarkerClusterer2.prototype.getGridSize = function() {
  3815. return this._gridSize;
  3816. };
  3817. MarkerClusterer2.prototype.setGridSize = function(size) {
  3818. this._gridSize = size;
  3819. this._redraw();
  3820. };
  3821. MarkerClusterer2.prototype.getMaxZoom = function() {
  3822. return this._maxZoom;
  3823. };
  3824. MarkerClusterer2.prototype.setMaxZoom = function(maxZoom) {
  3825. this._maxZoom = maxZoom;
  3826. this._redraw();
  3827. };
  3828. MarkerClusterer2.prototype.getStyles = function() {
  3829. return this._styles;
  3830. };
  3831. MarkerClusterer2.prototype.setStyles = function(styles) {
  3832. this._styles = styles;
  3833. this._redraw();
  3834. };
  3835. MarkerClusterer2.prototype.getMinClusterSize = function() {
  3836. return this._minClusterSize;
  3837. };
  3838. MarkerClusterer2.prototype.setMinClusterSize = function(size) {
  3839. this._minClusterSize = size;
  3840. this._redraw();
  3841. };
  3842. MarkerClusterer2.prototype.isAverageCenter = function() {
  3843. return this._isAverageCenter;
  3844. };
  3845. MarkerClusterer2.prototype.getMap = function() {
  3846. return this._map;
  3847. };
  3848. MarkerClusterer2.prototype.getMarkers = function() {
  3849. return this._markers;
  3850. };
  3851. MarkerClusterer2.prototype.getClustersCount = function() {
  3852. var count = 0;
  3853. for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
  3854. cluster.isReal() && count++;
  3855. }
  3856. return count;
  3857. };
  3858. function Cluster(markerClusterer) {
  3859. this._markerClusterer = markerClusterer;
  3860. this._map = markerClusterer.getMap();
  3861. this._minClusterSize = markerClusterer.getMinClusterSize();
  3862. this._isAverageCenter = markerClusterer.isAverageCenter();
  3863. this._center = null;
  3864. this._markers = [];
  3865. this._gridBounds = null;
  3866. this._isReal = false;
  3867. this._clusterMarker = new TextIconOverlay(this._center, this._markers.length, { "styles": this._markerClusterer.getStyles() });
  3868. }
  3869. Cluster.prototype.addMarker = function(marker) {
  3870. if (this.isMarkerInCluster(marker)) {
  3871. return false;
  3872. }
  3873. if (!this._center) {
  3874. this._center = marker.getPosition();
  3875. this.updateGridBounds();
  3876. } else {
  3877. if (this._isAverageCenter) {
  3878. var l = this._markers.length + 1;
  3879. var lat = (this._center.lat * (l - 1) + marker.getPosition().lat) / l;
  3880. var lng = (this._center.lng * (l - 1) + marker.getPosition().lng) / l;
  3881. this._center = new BMap.Point(lng, lat);
  3882. this.updateGridBounds();
  3883. }
  3884. }
  3885. marker.isInCluster = true;
  3886. this._markers.push(marker);
  3887. var len = this._markers.length;
  3888. if (len < this._minClusterSize) {
  3889. this._map.addOverlay(marker);
  3890. return true;
  3891. } else if (len === this._minClusterSize) {
  3892. for (var i = 0; i < len; i++) {
  3893. var label = this._markers[i].getLabel();
  3894. this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]);
  3895. this._markers[i].setLabel(label);
  3896. }
  3897. }
  3898. this._map.addOverlay(this._clusterMarker);
  3899. this._isReal = true;
  3900. this.updateClusterMarker();
  3901. return true;
  3902. };
  3903. Cluster.prototype.isMarkerInCluster = function(marker) {
  3904. if (this._markers.indexOf) {
  3905. return this._markers.indexOf(marker) != -1;
  3906. } else {
  3907. for (var i = 0, m; m = this._markers[i]; i++) {
  3908. if (m === marker) {
  3909. return true;
  3910. }
  3911. }
  3912. }
  3913. return false;
  3914. };
  3915. Cluster.prototype.isMarkerInClusterBounds = function(marker) {
  3916. return this._gridBounds.containsPoint(marker.getPosition());
  3917. };
  3918. Cluster.prototype.isReal = function(marker) {
  3919. return this._isReal;
  3920. };
  3921. Cluster.prototype.updateGridBounds = function() {
  3922. var bounds = new BMap.Bounds(this._center, this._center);
  3923. this._gridBounds = getExtendedBounds(this._map, bounds, this._markerClusterer.getGridSize());
  3924. };
  3925. Cluster.prototype.updateClusterMarker = function() {
  3926. if (this._map.getZoom() > this._markerClusterer.getMaxZoom()) {
  3927. this._clusterMarker && this._map.removeOverlay(this._clusterMarker);
  3928. for (var i = 0, marker; marker = this._markers[i]; i++) {
  3929. this._map.addOverlay(marker);
  3930. }
  3931. return;
  3932. }
  3933. if (this._markers.length < this._minClusterSize) {
  3934. this._clusterMarker.hide();
  3935. return;
  3936. }
  3937. this._clusterMarker.setPosition(this._center);
  3938. this._clusterMarker.setText(this._markers.length);
  3939. this._clusterMarker.addEventListener && !this._clusterMarker._hasClickEvent && this._clusterMarker.addEventListener("click", function(event) {
  3940. this._clusterMarker._hasClickEvent = true;
  3941. this._markers && this._map.setViewport(this.getBounds());
  3942. }.bind(this));
  3943. };
  3944. Cluster.prototype.remove = function() {
  3945. for (var i = 0; this._markers[i]; i++) {
  3946. var label = this._markers[i].getLabel();
  3947. this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]);
  3948. this._markers[i].setLabel(label);
  3949. }
  3950. this._map.removeOverlay(this._clusterMarker);
  3951. this._markers.length = 0;
  3952. delete this._markers;
  3953. };
  3954. Cluster.prototype.getBounds = function() {
  3955. var bounds = new BMap.Bounds(this._center, this._center);
  3956. for (var i = 0, marker; marker = this._markers[i]; i++) {
  3957. bounds.extend(marker.getPosition());
  3958. }
  3959. return bounds;
  3960. };
  3961. Cluster.prototype.getCenter = function() {
  3962. return this._center;
  3963. };
  3964. return MarkerClusterer2;
  3965. });
  3966. })(bmaplib_markerclusterer);
  3967. var MarkerClusterer$1 = bmaplib_markerclusterer.exports;
  3968. const markers = [];
  3969. const _sfc_main$3 = {
  3970. name: "bml-marker-clusterer",
  3971. mixins: [commonMixin("markerClusterer")],
  3972. provide() {
  3973. return {
  3974. Cluster: this
  3975. };
  3976. },
  3977. props: {
  3978. gridSize: {
  3979. type: Number
  3980. },
  3981. maxZoom: {
  3982. type: Number
  3983. },
  3984. minClusterSize: {
  3985. type: Number
  3986. },
  3987. styles: {
  3988. type: Array,
  3989. default() {
  3990. return [];
  3991. }
  3992. },
  3993. averageCenter: {
  3994. type: Boolean,
  3995. default: false
  3996. }
  3997. },
  3998. data() {
  3999. return {};
  4000. },
  4001. watch: {
  4002. gridSize: {
  4003. handler(val) {
  4004. const { BMap: BMap2, originInstance } = this;
  4005. originInstance.setGridSize(val);
  4006. },
  4007. deep: true
  4008. },
  4009. maxZoom(val) {
  4010. const { originInstance } = this;
  4011. originInstance.setMaxZoom(val);
  4012. },
  4013. minClusterSize: {
  4014. handler(val) {
  4015. const { BMap: BMap2, originInstance } = this;
  4016. originInstance.setMinClusterSize(val);
  4017. },
  4018. deep: true
  4019. },
  4020. styles: {
  4021. handler(val) {
  4022. const { BMap: BMap2, originInstance } = this;
  4023. const obj = JSON.parse(JSON.stringify(val)).map((item) => {
  4024. item.size = item.size && createSize(BMap2, item.size);
  4025. return item;
  4026. });
  4027. originInstance.setStyles(obj);
  4028. },
  4029. deep: true
  4030. },
  4031. averageCenter(val) {
  4032. this.reload();
  4033. }
  4034. },
  4035. methods: {
  4036. load() {
  4037. const { BMap: BMap2, map, gridSize, minClusterSize, maxZoom, styles, averageCenter } = this;
  4038. this.originInstance = new MarkerClusterer$1(map, {
  4039. gridSize: gridSize || 60,
  4040. maxZoom,
  4041. minClusterSize: minClusterSize || 2,
  4042. styles: styles.map((item) => {
  4043. item.size = createSize(BMap2, item.size);
  4044. return item;
  4045. }),
  4046. isAverageCenter: averageCenter
  4047. });
  4048. this.$nextTick(() => {
  4049. const markersInstance = markers.map((inst) => inst.originInstance).filter((marker) => marker instanceof BMap2.Marker);
  4050. this.originInstance.addMarkers(markersInstance);
  4051. });
  4052. },
  4053. addMaker(maker) {
  4054. markers.push(maker);
  4055. },
  4056. removeMaker(maker) {
  4057. markers.splice(markers.indexOf(maker), 1);
  4058. }
  4059. },
  4060. beforeCreate() {
  4061. this.preventChildrenRender = true;
  4062. }
  4063. };
  4064. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  4065. return openBlock(), createElementBlock("span", null, [
  4066. renderSlot(_ctx.$slots, "default")
  4067. ]);
  4068. }
  4069. var MarkerClusterer = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
  4070. var bmaplib_lushu = { exports: {} };
  4071. (function(module, exports) {
  4072. (function(root, factory) {
  4073. {
  4074. module.exports = factory();
  4075. }
  4076. })(commonjsGlobal, function() {
  4077. var baidu = {};
  4078. baidu.dom = {};
  4079. baidu.dom.g = function(id) {
  4080. if (typeof id == "string" || id instanceof String) {
  4081. return document.getElementById(id);
  4082. } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) {
  4083. return id;
  4084. }
  4085. return null;
  4086. };
  4087. baidu.g = baidu.G = baidu.dom.g;
  4088. baidu.lang = baidu.lang || {};
  4089. baidu.lang.isString = function(source) {
  4090. return Object.prototype.toString.call(source) == "[object String]";
  4091. };
  4092. baidu.isString = baidu.lang.isString;
  4093. baidu.dom._g = function(id) {
  4094. if (baidu.lang.isString(id)) {
  4095. return document.getElementById(id);
  4096. }
  4097. return id;
  4098. };
  4099. baidu._g = baidu.dom._g;
  4100. baidu.dom.getDocument = function(element) {
  4101. element = baidu.dom.g(element);
  4102. return element.nodeType == 9 ? element : element.ownerDocument || element.document;
  4103. };
  4104. baidu.browser = baidu.browser || {};
  4105. baidu.browser.ie = baidu.ie = /msie (\d+\.\d+)/i.test(navigator.userAgent) ? document.documentMode || +RegExp["$1"] : void 0;
  4106. baidu.dom.getComputedStyle = function(element, key) {
  4107. element = baidu.dom._g(element);
  4108. var doc = baidu.dom.getDocument(element), styles;
  4109. if (doc.defaultView && doc.defaultView.getComputedStyle) {
  4110. styles = doc.defaultView.getComputedStyle(element, null);
  4111. if (styles) {
  4112. return styles[key] || styles.getPropertyValue(key);
  4113. }
  4114. }
  4115. return "";
  4116. };
  4117. baidu.dom._styleFixer = baidu.dom._styleFixer || {};
  4118. baidu.dom._styleFilter = baidu.dom._styleFilter || [];
  4119. baidu.dom._styleFilter.filter = function(key, value, method) {
  4120. for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) {
  4121. if (filter = filter[method]) {
  4122. value = filter(key, value);
  4123. }
  4124. }
  4125. return value;
  4126. };
  4127. baidu.string = baidu.string || {};
  4128. baidu.string.toCamelCase = function(source) {
  4129. if (source.indexOf("-") < 0 && source.indexOf("_") < 0) {
  4130. return source;
  4131. }
  4132. return source.replace(/[-_][^-_]/g, function(match) {
  4133. return match.charAt(1).toUpperCase();
  4134. });
  4135. };
  4136. baidu.dom.getStyle = function(element, key) {
  4137. var dom = baidu.dom;
  4138. element = dom.g(element);
  4139. key = baidu.string.toCamelCase(key);
  4140. var value = element.style[key] || (element.currentStyle ? element.currentStyle[key] : "") || dom.getComputedStyle(element, key);
  4141. if (!value) {
  4142. var fixer = dom._styleFixer[key];
  4143. if (fixer) {
  4144. value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer);
  4145. }
  4146. }
  4147. if (fixer = dom._styleFilter) {
  4148. value = fixer.filter(key, value, "get");
  4149. }
  4150. return value;
  4151. };
  4152. baidu.getStyle = baidu.dom.getStyle;
  4153. baidu.dom._NAME_ATTRS = function() {
  4154. var result = {
  4155. "cellpadding": "cellPadding",
  4156. "cellspacing": "cellSpacing",
  4157. "colspan": "colSpan",
  4158. "rowspan": "rowSpan",
  4159. "valign": "vAlign",
  4160. "usemap": "useMap",
  4161. "frameborder": "frameBorder"
  4162. };
  4163. if (baidu.browser.ie < 8) {
  4164. result["for"] = "htmlFor";
  4165. result["class"] = "className";
  4166. } else {
  4167. result["htmlFor"] = "for";
  4168. result["className"] = "class";
  4169. }
  4170. return result;
  4171. }();
  4172. baidu.dom.setAttr = function(element, key, value) {
  4173. element = baidu.dom.g(element);
  4174. if (key == "style") {
  4175. element.style.cssText = value;
  4176. } else {
  4177. key = baidu.dom._NAME_ATTRS[key] || key;
  4178. element.setAttribute(key, value);
  4179. }
  4180. return element;
  4181. };
  4182. baidu.setAttr = baidu.dom.setAttr;
  4183. baidu.dom.setAttrs = function(element, attributes) {
  4184. element = baidu.dom.g(element);
  4185. for (var key in attributes) {
  4186. baidu.dom.setAttr(element, key, attributes[key]);
  4187. }
  4188. return element;
  4189. };
  4190. baidu.setAttrs = baidu.dom.setAttrs;
  4191. baidu.dom.create = function(tagName, opt_attributes) {
  4192. var el = document.createElement(tagName), attributes = opt_attributes || {};
  4193. return baidu.dom.setAttrs(el, attributes);
  4194. };
  4195. baidu.object = baidu.object || {};
  4196. baidu.extend = baidu.object.extend = function(target, source) {
  4197. for (var p in source) {
  4198. if (source.hasOwnProperty(p)) {
  4199. target[p] = source[p];
  4200. }
  4201. }
  4202. return target;
  4203. };
  4204. var LuShu = function(map, path, opts) {
  4205. try {
  4206. BMap;
  4207. } catch (e) {
  4208. throw Error("Baidu Map JS API is not ready yet!");
  4209. }
  4210. if (!path || path.length < 1) {
  4211. return;
  4212. }
  4213. this._map = map;
  4214. this._path = path;
  4215. this.i = 0;
  4216. this._setTimeoutQuene = [];
  4217. this._projection = this._map.getMapType().getProjection();
  4218. this._opts = {
  4219. icon: null,
  4220. speed: 4e3,
  4221. defaultContent: "",
  4222. showInfoWindow: false
  4223. };
  4224. this._setOptions(opts);
  4225. this._rotation = 0;
  4226. if (!this._opts.icon instanceof BMap.Icon) {
  4227. this._opts.icon = defaultIcon;
  4228. }
  4229. };
  4230. LuShu.prototype._setOptions = function(opts) {
  4231. if (!opts) {
  4232. return;
  4233. }
  4234. for (var p in opts) {
  4235. if (opts.hasOwnProperty(p)) {
  4236. this._opts[p] = opts[p];
  4237. }
  4238. }
  4239. };
  4240. LuShu.prototype.start = function() {
  4241. var me = this, len = me._path.length;
  4242. this._opts.onstart && this._opts.onstart(me);
  4243. if (me.i && me.i < len - 1) {
  4244. if (!me._fromPause) {
  4245. return;
  4246. } else if (!me._fromStop) {
  4247. me._moveNext(++me.i);
  4248. }
  4249. } else {
  4250. !me._marker && me._addMarker();
  4251. me._timeoutFlag = setTimeout(function() {
  4252. !me._overlay && me._addInfoWin();
  4253. me._moveNext(me.i);
  4254. }, 400);
  4255. }
  4256. this._fromPause = false;
  4257. this._fromStop = false;
  4258. }, LuShu.prototype.stop = function() {
  4259. this.i = 0;
  4260. this._fromStop = true;
  4261. clearInterval(this._intervalFlag);
  4262. this._clearTimeout();
  4263. for (var i = 0, t = this._opts.landmarkPois, len = t.length; i < len; i++) {
  4264. t[i].bShow = false;
  4265. }
  4266. this._opts.onstop && this._opts.onstop(this);
  4267. };
  4268. LuShu.prototype.pause = function() {
  4269. clearInterval(this._intervalFlag);
  4270. this._fromPause = true;
  4271. this._clearTimeout();
  4272. this._opts.onpause && this._opts.onpause(this);
  4273. };
  4274. LuShu.prototype.hideInfoWindow = function() {
  4275. this._opts.showInfoWindow = false;
  4276. this._overlay && (this._overlay._div.style.visibility = "hidden");
  4277. };
  4278. LuShu.prototype.showInfoWindow = function() {
  4279. this._opts.showInfoWindow = true;
  4280. this._overlay && (this._overlay._div.style.visibility = "visible");
  4281. };
  4282. LuShu.prototype.dispose = function() {
  4283. clearInterval(this._intervalFlag);
  4284. this._setTimeoutQuene && this._clearTimeout();
  4285. if (this._map) {
  4286. this._map.removeOverlay(this._overlay);
  4287. this._map.removeOverlay(this._marker);
  4288. }
  4289. };
  4290. baidu.object.extend(LuShu.prototype, {
  4291. _addMarker: function(callback) {
  4292. if (this._marker) {
  4293. this.stop();
  4294. this._map.removeOverlay(this._marker);
  4295. clearTimeout(this._timeoutFlag);
  4296. }
  4297. this._overlay && this._map.removeOverlay(this._overlay);
  4298. var marker = new BMap.Marker(this._path[0]);
  4299. this._opts.icon && marker.setIcon(this._opts.icon);
  4300. this._map.addOverlay(marker);
  4301. marker.setAnimation(BMAP_ANIMATION_DROP);
  4302. this._marker = marker;
  4303. },
  4304. _addInfoWin: function() {
  4305. var me = this;
  4306. !CustomOverlay.prototype.initialize && initCustomOverlay();
  4307. var overlay = new CustomOverlay(me._marker.getPosition(), me._opts.defaultContent);
  4308. overlay.setRelatedClass(this);
  4309. this._overlay = overlay;
  4310. this._map.addOverlay(overlay);
  4311. this._opts.showInfoWindow ? this.showInfoWindow() : this.hideInfoWindow();
  4312. },
  4313. _getMercator: function(poi) {
  4314. return this._map.getMapType().getProjection().lngLatToPoint(poi);
  4315. },
  4316. _getDistance: function(pxA, pxB) {
  4317. return Math.sqrt(Math.pow(pxA.x - pxB.x, 2) + Math.pow(pxA.y - pxB.y, 2));
  4318. },
  4319. _move: function(initPos, targetPos, effect) {
  4320. var me = this, currentCount = 0, timer = 10, step = this._opts.speed / (1e3 / timer), init_pos = this._projection.lngLatToPoint(initPos), target_pos = this._projection.lngLatToPoint(targetPos), count = Math.round(me._getDistance(init_pos, target_pos) / step);
  4321. if (count < 1) {
  4322. me._moveNext(++me.i);
  4323. return;
  4324. }
  4325. me._intervalFlag = setInterval(function() {
  4326. if (currentCount >= count) {
  4327. clearInterval(me._intervalFlag);
  4328. if (me.i > me._path.length) {
  4329. return;
  4330. }
  4331. me._moveNext(++me.i);
  4332. } else {
  4333. currentCount++;
  4334. var x = effect(init_pos.x, target_pos.x, currentCount, count), y = effect(init_pos.y, target_pos.y, currentCount, count), pos = me._projection.pointToLngLat(new BMap.Pixel(x, y));
  4335. if (currentCount == 1) {
  4336. var proPos = null;
  4337. if (me.i - 1 >= 0) {
  4338. proPos = me._path[me.i - 1];
  4339. }
  4340. if (me._opts.enableRotation == true) {
  4341. me.setRotation(proPos, initPos, targetPos);
  4342. }
  4343. if (me._opts.autoView) {
  4344. if (!me._map.getBounds().containsPoint(pos)) {
  4345. me._map.setCenter(pos);
  4346. }
  4347. }
  4348. }
  4349. me._marker.setPosition(pos);
  4350. me._setInfoWin(pos);
  4351. }
  4352. }, timer);
  4353. },
  4354. setRotation: function(prePos, curPos, targetPos) {
  4355. var me = this;
  4356. var deg = 0;
  4357. curPos = me._map.pointToPixel(curPos);
  4358. targetPos = me._map.pointToPixel(targetPos);
  4359. if (targetPos.x != curPos.x) {
  4360. var tan = (targetPos.y - curPos.y) / (targetPos.x - curPos.x), atan = Math.atan(tan);
  4361. deg = atan * 360 / (2 * Math.PI);
  4362. if (targetPos.x < curPos.x) {
  4363. deg = -deg + 90 + 90;
  4364. } else {
  4365. deg = -deg;
  4366. }
  4367. me._marker.setRotation(-deg);
  4368. } else {
  4369. var disy = targetPos.y - curPos.y;
  4370. var bias = 0;
  4371. if (disy > 0)
  4372. bias = -1;
  4373. else
  4374. bias = 1;
  4375. me._marker.setRotation(-bias * 90);
  4376. }
  4377. return;
  4378. },
  4379. linePixellength: function(from, to) {
  4380. return Math.sqrt(Math.abs(from.x - to.x) * Math.abs(from.x - to.x) + Math.abs(from.y - to.y) * Math.abs(from.y - to.y));
  4381. },
  4382. pointToPoint: function(from, to) {
  4383. return Math.abs(from.x - to.x) * Math.abs(from.x - to.x) + Math.abs(from.y - to.y) * Math.abs(from.y - to.y);
  4384. },
  4385. _moveNext: function(index2) {
  4386. var me = this;
  4387. if (index2 < this._path.length - 1) {
  4388. me._move(me._path[index2], me._path[index2 + 1], me._tween.linear);
  4389. } else {
  4390. me.stop();
  4391. }
  4392. },
  4393. _setInfoWin: function(pos) {
  4394. var me = this;
  4395. me._overlay.setPosition(pos, me._marker.getIcon().size);
  4396. var index2 = me._troughPointIndex(pos);
  4397. if (index2 != -1) {
  4398. clearInterval(me._intervalFlag);
  4399. me._overlay.setHtml(me._opts.landmarkPois[index2].html);
  4400. me._overlay.setPosition(pos, me._marker.getIcon().size);
  4401. me._pauseForView(index2);
  4402. } else {
  4403. me._overlay.setHtml(me._opts.defaultContent);
  4404. }
  4405. },
  4406. _pauseForView: function(index2) {
  4407. var me = this;
  4408. var t = setTimeout(function() {
  4409. me._moveNext(++me.i);
  4410. }, me._opts.landmarkPois[index2].pauseTime * 1e3);
  4411. me._setTimeoutQuene.push(t);
  4412. },
  4413. _clearTimeout: function() {
  4414. for (var i in this._setTimeoutQuene) {
  4415. clearTimeout(this._setTimeoutQuene[i]);
  4416. }
  4417. this._setTimeoutQuene.length = 0;
  4418. },
  4419. _tween: {
  4420. linear: function(initPos, targetPos, currentCount, count) {
  4421. var b = initPos, c = targetPos - initPos, t = currentCount, d = count;
  4422. return c * t / d + b;
  4423. }
  4424. },
  4425. _troughPointIndex: function(markerPoi) {
  4426. var t = this._opts.landmarkPois, distance;
  4427. for (var i = 0, len = t.length; i < len; i++) {
  4428. if (!t[i].bShow) {
  4429. distance = this._map.getDistance(new BMap.Point(t[i].lng, t[i].lat), markerPoi);
  4430. if (distance < 10) {
  4431. t[i].bShow = true;
  4432. return i;
  4433. }
  4434. }
  4435. }
  4436. return -1;
  4437. }
  4438. });
  4439. function CustomOverlay(point, html) {
  4440. this._point = point;
  4441. this._html = html;
  4442. }
  4443. function initCustomOverlay() {
  4444. CustomOverlay.prototype = new BMap.Overlay();
  4445. CustomOverlay.prototype.initialize = function(map) {
  4446. var div = this._div = baidu.dom.create("div", { style: "border:solid 1px #ccc;width:auto;min-width:50px;text-align:center;position:absolute;background:#fff;color:#000;font-size:12px;border-radius: 10px;padding:5px;white-space: nowrap;" });
  4447. div.innerHTML = this._html;
  4448. map.getPanes().floatPane.appendChild(div);
  4449. this._map = map;
  4450. return div;
  4451. };
  4452. CustomOverlay.prototype.draw = function() {
  4453. this.setPosition(this.lushuMain._marker.getPosition(), this.lushuMain._marker.getIcon().size);
  4454. };
  4455. baidu.object.extend(CustomOverlay.prototype, {
  4456. setPosition: function(poi, markerSize) {
  4457. var px = this._map.pointToOverlayPixel(poi), styleW = baidu.dom.getStyle(this._div, "width"), styleH = baidu.dom.getStyle(this._div, "height"), overlayW = parseInt(this._div.clientWidth || styleW, 10);
  4458. parseInt(this._div.clientHeight || styleH, 10);
  4459. this._div.style.left = px.x - overlayW / 2 + "px";
  4460. this._div.style.bottom = -(px.y - markerSize.height) + "px";
  4461. },
  4462. setHtml: function(html) {
  4463. this._div.innerHTML = html;
  4464. },
  4465. setRelatedClass: function(lushuMain) {
  4466. this.lushuMain = lushuMain;
  4467. }
  4468. });
  4469. }
  4470. return LuShu;
  4471. });
  4472. })(bmaplib_lushu);
  4473. var Lushu = bmaplib_lushu.exports;
  4474. const _sfc_main$2 = {
  4475. name: "bm-lushu",
  4476. render(h) {
  4477. },
  4478. emits: ["start", "stop", "pause"],
  4479. mixins: [commonMixin("lushu")],
  4480. props: {
  4481. path: {
  4482. type: Array,
  4483. default: []
  4484. },
  4485. landmarkPois: {
  4486. type: Array,
  4487. default() {
  4488. return [];
  4489. }
  4490. },
  4491. icon: {
  4492. type: Object
  4493. },
  4494. speed: {
  4495. type: Number,
  4496. default: 4e3
  4497. },
  4498. content: {
  4499. type: String,
  4500. default: ""
  4501. },
  4502. autoView: {
  4503. type: Boolean,
  4504. default: false
  4505. },
  4506. rotation: {
  4507. type: Boolean,
  4508. default: false
  4509. },
  4510. infoWindow: {
  4511. type: Boolean,
  4512. default: true
  4513. },
  4514. play: {
  4515. type: Boolean,
  4516. default: true
  4517. }
  4518. },
  4519. watch: {
  4520. path: {
  4521. handler(val) {
  4522. this.reload();
  4523. },
  4524. deep: true
  4525. },
  4526. landmarkPois: {
  4527. handler(val) {
  4528. this.reload();
  4529. },
  4530. deep: true
  4531. },
  4532. icon: {
  4533. handler(val) {
  4534. const { originInstance, content } = this;
  4535. const newMarker = createIcon(BMap, val);
  4536. originInstance._opts.icon = newMarker;
  4537. originInstance._marker = newMarker;
  4538. },
  4539. deep: true
  4540. },
  4541. speed(val) {
  4542. const { originInstance, content } = this;
  4543. originInstance._opts.speed = val;
  4544. },
  4545. content(val) {
  4546. const { originInstance, infoWindow } = this;
  4547. val && infoWindow ? originInstance.showInfoWindow() : originInstance.hideInfoWindow();
  4548. originInstance._opts.defaultContent = val;
  4549. originInstance._overlay && originInstance._overlay.setHtml(val);
  4550. },
  4551. autoView(val) {
  4552. const { originInstance, content } = this;
  4553. originInstance._opts.autoView = val;
  4554. },
  4555. rotation(val) {
  4556. const { originInstance, content } = this;
  4557. originInstance._opts.enableRotation = val;
  4558. },
  4559. infoWindow(val) {
  4560. const { originInstance, content } = this;
  4561. originInstance && val && content ? originInstance.showInfoWindow() : originInstance.hideInfoWindow();
  4562. },
  4563. play(val) {
  4564. const { originInstance } = this;
  4565. val && originInstance ? originInstance.start() : !this._isEnd && originInstance.pause();
  4566. }
  4567. },
  4568. methods: {
  4569. load() {
  4570. const { BMap: BMap2, map, path, landmarkPois, icon, speed, content, autoView, rotation, infoWindow, play } = this;
  4571. const lushu = this.originInstance = new Lushu(map, path, {
  4572. enableRotation: rotation,
  4573. landmarkPois,
  4574. showInfoWindow: infoWindow,
  4575. defaultContent: content,
  4576. icon: icon && createIcon(BMap2, icon),
  4577. speed,
  4578. autoView,
  4579. onstart: (e) => {
  4580. this._isEnd = false;
  4581. this.$emit("start");
  4582. },
  4583. onstop: (e) => {
  4584. this._isEnd = true;
  4585. this.$emit("stop");
  4586. },
  4587. onpause: (e) => this.$emit("pause")
  4588. });
  4589. play && path.length && lushu.start(this);
  4590. path.length && (content && infoWindow ? lushu.showInfoWindow() : lushu.hideInfoWindow());
  4591. }
  4592. }
  4593. };
  4594. var bmaplib_heatmap = { exports: {} };
  4595. (function(module, exports) {
  4596. (function(root, factory) {
  4597. {
  4598. module.exports = factory();
  4599. }
  4600. })(commonjsGlobal, function() {
  4601. function inherits(subClass, superClass, className) {
  4602. var key, proto, selfProps = subClass.prototype, clazz = new Function();
  4603. clazz.prototype = superClass.prototype;
  4604. proto = subClass.prototype = new clazz();
  4605. for (key in selfProps) {
  4606. proto[key] = selfProps[key];
  4607. }
  4608. subClass.prototype.constructor = subClass;
  4609. subClass.superClass = superClass.prototype;
  4610. if (typeof className == "string") {
  4611. proto._className = className;
  4612. }
  4613. }
  4614. var heatmapFactory = function() {
  4615. var store = function store2(hmap) {
  4616. var _ = {
  4617. data: [],
  4618. heatmap: hmap
  4619. };
  4620. this.max = 1;
  4621. this.get = function(key) {
  4622. return _[key];
  4623. };
  4624. this.set = function(key, value) {
  4625. _[key] = value;
  4626. };
  4627. };
  4628. store.prototype = {
  4629. addDataPoint: function(x, y) {
  4630. if (x < 0 || y < 0)
  4631. return;
  4632. var me = this, heatmap2 = me.get("heatmap"), data = me.get("data");
  4633. if (!data[x])
  4634. data[x] = [];
  4635. if (!data[x][y])
  4636. data[x][y] = 0;
  4637. data[x][y] += arguments.length < 3 ? 1 : arguments[2];
  4638. me.set("data", data);
  4639. if (me.max < data[x][y]) {
  4640. heatmap2.get("actx").clearRect(0, 0, heatmap2.get("width"), heatmap2.get("height"));
  4641. me.setDataSet({ max: data[x][y], data }, true);
  4642. return;
  4643. }
  4644. heatmap2.drawAlpha(x, y, data[x][y], true);
  4645. },
  4646. setDataSet: function(obj, internal) {
  4647. var me = this, heatmap2 = me.get("heatmap"), data = [], d = obj.data, dlen = d.length;
  4648. heatmap2.clear();
  4649. this.max = obj.max;
  4650. heatmap2.get("legend") && heatmap2.get("legend").update(obj.max);
  4651. if (internal != null && internal) {
  4652. for (var one in d) {
  4653. if (one === void 0)
  4654. continue;
  4655. for (var two in d[one]) {
  4656. if (two === void 0)
  4657. continue;
  4658. heatmap2.drawAlpha(one, two, d[one][two], false);
  4659. }
  4660. }
  4661. } else {
  4662. while (dlen--) {
  4663. var point = d[dlen];
  4664. heatmap2.drawAlpha(point.x, point.y, point.count, false);
  4665. if (!data[point.x])
  4666. data[point.x] = [];
  4667. if (!data[point.x][point.y])
  4668. data[point.x][point.y] = 0;
  4669. data[point.x][point.y] = point.count;
  4670. }
  4671. }
  4672. heatmap2.colorize();
  4673. this.set("data", d);
  4674. },
  4675. exportDataSet: function() {
  4676. var me = this, data = me.get("data"), exportData = [];
  4677. for (var one in data) {
  4678. if (one === void 0)
  4679. continue;
  4680. for (var two in data[one]) {
  4681. if (two === void 0)
  4682. continue;
  4683. exportData.push({ x: parseInt(one, 10), y: parseInt(two, 10), count: data[one][two] });
  4684. }
  4685. }
  4686. return { max: me.max, data: exportData };
  4687. },
  4688. generateRandomDataSet: function(points) {
  4689. var heatmap2 = this.get("heatmap"), w = heatmap2.get("width"), h = heatmap2.get("height");
  4690. var randomset = {}, max = Math.floor(Math.random() * 1e3 + 1);
  4691. randomset.max = max;
  4692. var data = [];
  4693. while (points--) {
  4694. data.push({ x: Math.floor(Math.random() * w + 1), y: Math.floor(Math.random() * h + 1), count: Math.floor(Math.random() * max + 1) });
  4695. }
  4696. randomset.data = data;
  4697. this.setDataSet(randomset);
  4698. }
  4699. };
  4700. var legend = function legend2(config2) {
  4701. this.config = config2;
  4702. var _ = {
  4703. element: null,
  4704. labelsEl: null,
  4705. gradientCfg: null,
  4706. ctx: null
  4707. };
  4708. this.get = function(key) {
  4709. return _[key];
  4710. };
  4711. this.set = function(key, value) {
  4712. _[key] = value;
  4713. };
  4714. this.init();
  4715. };
  4716. legend.prototype = {
  4717. init: function() {
  4718. var me = this, config2 = me.config, title = config2.title || "Legend", position = config2.position, offset = config2.offset || 10;
  4719. config2.gradient;
  4720. var labelsEl = document.createElement("ul"), element, gradient, positionCss = "";
  4721. me.processGradientObject();
  4722. if (position.indexOf("t") > -1) {
  4723. positionCss += "top:" + offset + "px;";
  4724. } else {
  4725. positionCss += "bottom:" + offset + "px;";
  4726. }
  4727. if (position.indexOf("l") > -1) {
  4728. positionCss += "left:" + offset + "px;";
  4729. } else {
  4730. positionCss += "right:" + offset + "px;";
  4731. }
  4732. element = document.createElement("div");
  4733. element.style.cssText = "border-radius:5px;position:absolute;" + positionCss + "font-family:Helvetica; width:256px;z-index:10000000000; background:rgba(255,255,255,1);padding:10px;border:1px solid black;margin:0;";
  4734. element.innerHTML = "<h3 style='padding:0;margin:0;text-align:center;font-size:16px;'>" + title + "</h3>";
  4735. labelsEl.style.cssText = "position:relative;font-size:12px;display:block;list-style:none;list-style-type:none;margin:0;height:15px;";
  4736. gradient = document.createElement("div");
  4737. gradient.style.cssText = ["position:relative;display:block;width:256px;height:15px;border-bottom:1px solid black; background-image:url(", me.createGradientImage(), ");"].join("");
  4738. element.appendChild(labelsEl);
  4739. element.appendChild(gradient);
  4740. me.set("element", element);
  4741. me.set("labelsEl", labelsEl);
  4742. me.update(1);
  4743. },
  4744. processGradientObject: function() {
  4745. var me = this, gradientConfig = this.config.gradient, gradientArr = [];
  4746. for (var key in gradientConfig) {
  4747. if (gradientConfig.hasOwnProperty(key)) {
  4748. gradientArr.push({ stop: key, value: gradientConfig[key] });
  4749. }
  4750. }
  4751. gradientArr.sort(function(a, b) {
  4752. return a.stop - b.stop;
  4753. });
  4754. gradientArr.unshift({ stop: 0, value: "rgba(0,0,0,0)" });
  4755. me.set("gradientArr", gradientArr);
  4756. },
  4757. createGradientImage: function() {
  4758. var me = this, gradArr = me.get("gradientArr"), length = gradArr.length, canvas = document.createElement("canvas"), ctx = canvas.getContext("2d"), grad;
  4759. canvas.width = "256";
  4760. canvas.height = "15";
  4761. grad = ctx.createLinearGradient(0, 5, 256, 10);
  4762. for (var i = 0; i < length; i++) {
  4763. grad.addColorStop(1 / (length - 1) * i, gradArr[i].value);
  4764. }
  4765. ctx.fillStyle = grad;
  4766. ctx.fillRect(0, 5, 256, 10);
  4767. ctx.strokeStyle = "black";
  4768. ctx.beginPath();
  4769. for (var i = 0; i < length; i++) {
  4770. ctx.moveTo((1 / (length - 1) * i * 256 >> 0) + 0.5, 0);
  4771. ctx.lineTo((1 / (length - 1) * i * 256 >> 0) + 0.5, i == 0 ? 15 : 5);
  4772. }
  4773. ctx.moveTo(255.5, 0);
  4774. ctx.lineTo(255.5, 15);
  4775. ctx.moveTo(255.5, 4.5);
  4776. ctx.lineTo(0, 4.5);
  4777. ctx.stroke();
  4778. me.set("ctx", ctx);
  4779. return canvas.toDataURL();
  4780. },
  4781. getElement: function() {
  4782. return this.get("element");
  4783. },
  4784. update: function(max) {
  4785. var me = this, gradient = me.get("gradientArr"), ctx = me.get("ctx"), labels = me.get("labelsEl"), labelText, labelsHtml = "", offset;
  4786. for (var i = 0; i < gradient.length; i++) {
  4787. labelText = max * gradient[i].stop >> 0;
  4788. offset = ctx.measureText(labelText).width / 2 >> 0;
  4789. if (i == 0) {
  4790. offset = 0;
  4791. }
  4792. if (i == gradient.length - 1) {
  4793. offset *= 2;
  4794. }
  4795. labelsHtml += '<li style="position:absolute;left:' + (((1 / (gradient.length - 1) * i * 256 || 0) >> 0) - offset + 0.5) + 'px">' + labelText + "</li>";
  4796. }
  4797. labels.innerHTML = labelsHtml;
  4798. }
  4799. };
  4800. var heatmap = function heatmap2(config2) {
  4801. var _ = {
  4802. radius: 40,
  4803. element: {},
  4804. canvas: {},
  4805. acanvas: {},
  4806. ctx: {},
  4807. actx: {},
  4808. legend: null,
  4809. visible: true,
  4810. width: 0,
  4811. height: 0,
  4812. max: false,
  4813. gradient: false,
  4814. opacity: 180,
  4815. premultiplyAlpha: false,
  4816. bounds: {
  4817. l: 1e3,
  4818. r: 0,
  4819. t: 1e3,
  4820. b: 0
  4821. },
  4822. debug: false
  4823. };
  4824. this.store = new store(this);
  4825. this.get = function(key) {
  4826. return _[key];
  4827. };
  4828. this.set = function(key, value) {
  4829. _[key] = value;
  4830. };
  4831. this.configure(config2);
  4832. this.init();
  4833. };
  4834. heatmap.prototype = {
  4835. configure: function(config2) {
  4836. var me = this;
  4837. me.set("radius", config2["radius"] || 40);
  4838. me.set("element", config2.element instanceof Object ? config2.element : document.getElementById(config2.element));
  4839. me.set("visible", config2.visible != null ? config2.visible : true);
  4840. me.set("max", config2.max || false);
  4841. me.set("gradient", config2.gradient || { 0.45: "rgb(0,0,255)", 0.55: "rgb(0,255,255)", 0.65: "rgb(0,255,0)", 0.95: "yellow", 1: "rgb(255,0,0)" });
  4842. me.set("opacity", parseInt(255 / (100 / config2.opacity), 10) || 180);
  4843. me.set("width", config2.width || 0);
  4844. me.set("height", config2.height || 0);
  4845. me.set("debug", config2.debug);
  4846. if (config2.legend) {
  4847. var legendCfg = config2.legend;
  4848. legendCfg.gradient = me.get("gradient");
  4849. me.set("legend", new legend(legendCfg));
  4850. }
  4851. },
  4852. resize: function() {
  4853. var me = this, element = me.get("element"), canvas = me.get("canvas"), acanvas = me.get("acanvas");
  4854. canvas.width = acanvas.width = me.get("width") || element.style.width.replace(/px/, "") || me.getWidth(element);
  4855. this.set("width", canvas.width);
  4856. canvas.height = acanvas.height = me.get("height") || element.style.height.replace(/px/, "") || me.getHeight(element);
  4857. this.set("height", canvas.height);
  4858. },
  4859. init: function() {
  4860. var me = this, canvas = document.createElement("canvas"), acanvas = document.createElement("canvas"), ctx = canvas.getContext("2d"), actx = acanvas.getContext("2d"), element = me.get("element");
  4861. me.initColorPalette();
  4862. me.set("canvas", canvas);
  4863. me.set("ctx", ctx);
  4864. me.set("acanvas", acanvas);
  4865. me.set("actx", actx);
  4866. me.resize();
  4867. canvas.style.cssText = acanvas.style.cssText = "position:absolute;top:0;left:0;z-index:10000000;";
  4868. if (!me.get("visible"))
  4869. canvas.style.display = "none";
  4870. element.appendChild(canvas);
  4871. if (me.get("legend")) {
  4872. element.appendChild(me.get("legend").getElement());
  4873. }
  4874. if (me.get("debug"))
  4875. document.body.appendChild(acanvas);
  4876. actx.shadowOffsetX = 15e3;
  4877. actx.shadowOffsetY = 15e3;
  4878. actx.shadowBlur = 15;
  4879. },
  4880. initColorPalette: function() {
  4881. var me = this, canvas = document.createElement("canvas"), gradient = me.get("gradient"), ctx, grad, testData;
  4882. canvas.width = "1";
  4883. canvas.height = "256";
  4884. ctx = canvas.getContext("2d");
  4885. grad = ctx.createLinearGradient(0, 0, 1, 256);
  4886. testData = ctx.getImageData(0, 0, 1, 1);
  4887. testData.data[0] = testData.data[3] = 64;
  4888. testData.data[1] = testData.data[2] = 0;
  4889. ctx.putImageData(testData, 0, 0);
  4890. testData = ctx.getImageData(0, 0, 1, 1);
  4891. me.set("premultiplyAlpha", testData.data[0] < 60 || testData.data[0] > 70);
  4892. for (var x in gradient) {
  4893. grad.addColorStop(x, gradient[x]);
  4894. }
  4895. ctx.fillStyle = grad;
  4896. ctx.fillRect(0, 0, 1, 256);
  4897. me.set("gradient", ctx.getImageData(0, 0, 1, 256).data);
  4898. },
  4899. getWidth: function(element) {
  4900. var width = element.offsetWidth;
  4901. if (element.style.paddingLeft) {
  4902. width += element.style.paddingLeft;
  4903. }
  4904. if (element.style.paddingRight) {
  4905. width += element.style.paddingRight;
  4906. }
  4907. return width;
  4908. },
  4909. getHeight: function(element) {
  4910. var height = element.offsetHeight;
  4911. if (element.style.paddingTop) {
  4912. height += element.style.paddingTop;
  4913. }
  4914. if (element.style.paddingBottom) {
  4915. height += element.style.paddingBottom;
  4916. }
  4917. return height;
  4918. },
  4919. colorize: function(x, y) {
  4920. var me = this, width = me.get("width"), radius = me.get("radius"), height = me.get("height"), actx = me.get("actx"), ctx = me.get("ctx"), x2 = radius * 3, premultiplyAlpha = me.get("premultiplyAlpha"), palette = me.get("gradient"), opacity = me.get("opacity"), bounds = me.get("bounds"), left, top, bottom, right, image, length, alpha, offset, finalAlpha;
  4921. if (x != null && y != null) {
  4922. if (x + x2 > width) {
  4923. x = width - x2;
  4924. }
  4925. if (x < 0) {
  4926. x = 0;
  4927. }
  4928. if (y < 0) {
  4929. y = 0;
  4930. }
  4931. if (y + x2 > height) {
  4932. y = height - x2;
  4933. }
  4934. left = x;
  4935. top = y;
  4936. right = x + x2;
  4937. bottom = y + x2;
  4938. } else {
  4939. if (bounds["l"] < 0) {
  4940. left = 0;
  4941. } else {
  4942. left = bounds["l"];
  4943. }
  4944. if (bounds["r"] > width) {
  4945. right = width;
  4946. } else {
  4947. right = bounds["r"];
  4948. }
  4949. if (bounds["t"] < 0) {
  4950. top = 0;
  4951. } else {
  4952. top = bounds["t"];
  4953. }
  4954. if (bounds["b"] > height) {
  4955. bottom = height;
  4956. } else {
  4957. bottom = bounds["b"];
  4958. }
  4959. }
  4960. image = actx.getImageData(left, top, right - left, bottom - top);
  4961. length = image.data.length;
  4962. for (var i = 3; i < length; i += 4) {
  4963. alpha = image.data[i], offset = alpha * 4;
  4964. if (!offset)
  4965. continue;
  4966. finalAlpha = alpha < opacity ? alpha : opacity;
  4967. image.data[i - 3] = palette[offset];
  4968. image.data[i - 2] = palette[offset + 1];
  4969. image.data[i - 1] = palette[offset + 2];
  4970. if (premultiplyAlpha) {
  4971. image.data[i - 3] /= 255 / finalAlpha;
  4972. image.data[i - 2] /= 255 / finalAlpha;
  4973. image.data[i - 1] /= 255 / finalAlpha;
  4974. }
  4975. image.data[i] = finalAlpha;
  4976. }
  4977. ctx.putImageData(image, left, top);
  4978. },
  4979. drawAlpha: function(x, y, count, colorize) {
  4980. var me = this, radius = me.get("radius"), ctx = me.get("actx");
  4981. me.get("max");
  4982. var bounds = me.get("bounds"), xb = x - 1.5 * radius >> 0, yb = y - 1.5 * radius >> 0, xc = x + 1.5 * radius >> 0, yc = y + 1.5 * radius >> 0;
  4983. ctx.shadowColor = "rgba(0,0,0," + (count ? count / me.store.max : "0.1") + ")";
  4984. ctx.shadowOffsetX = 15e3;
  4985. ctx.shadowOffsetY = 15e3;
  4986. ctx.shadowBlur = 15;
  4987. ctx.beginPath();
  4988. ctx.arc(x - 15e3, y - 15e3, radius, 0, Math.PI * 2, true);
  4989. ctx.closePath();
  4990. ctx.fill();
  4991. if (colorize) {
  4992. me.colorize(xb, yb);
  4993. } else {
  4994. if (xb < bounds["l"]) {
  4995. bounds["l"] = xb;
  4996. }
  4997. if (yb < bounds["t"]) {
  4998. bounds["t"] = yb;
  4999. }
  5000. if (xc > bounds["r"]) {
  5001. bounds["r"] = xc;
  5002. }
  5003. if (yc > bounds["b"]) {
  5004. bounds["b"] = yc;
  5005. }
  5006. }
  5007. },
  5008. toggleDisplay: function() {
  5009. var me = this, visible = me.get("visible"), canvas = me.get("canvas");
  5010. if (!visible)
  5011. canvas.style.display = "block";
  5012. else
  5013. canvas.style.display = "none";
  5014. me.set("visible", !visible);
  5015. },
  5016. getImageData: function() {
  5017. return this.get("canvas").toDataURL();
  5018. },
  5019. clear: function() {
  5020. var me = this, w = me.get("width"), h = me.get("height");
  5021. me.store.set("data", []);
  5022. me.get("ctx").clearRect(0, 0, w, h);
  5023. me.get("actx").clearRect(0, 0, w, h);
  5024. },
  5025. cleanup: function() {
  5026. var me = this;
  5027. me.get("element").removeChild(me.get("canvas"));
  5028. }
  5029. };
  5030. return {
  5031. create: function(config2) {
  5032. return new heatmap(config2);
  5033. },
  5034. util: {
  5035. mousePosition: function(ev) {
  5036. var x, y;
  5037. if (ev.layerX) {
  5038. x = ev.layerX;
  5039. y = ev.layerY;
  5040. } else if (ev.offsetX) {
  5041. x = ev.offsetX;
  5042. y = ev.offsetY;
  5043. }
  5044. if (typeof x == "undefined")
  5045. return;
  5046. return [x, y];
  5047. }
  5048. }
  5049. };
  5050. }();
  5051. var HeatmapOverlay = function(opts) {
  5052. try {
  5053. BMap;
  5054. } catch (e) {
  5055. throw Error("Baidu Map JS API is not ready yet!");
  5056. }
  5057. if (!HeatmapOverlay._isExtended) {
  5058. HeatmapOverlay._isExtended = true;
  5059. inherits(HeatmapOverlay, BMap.Overlay, "HeatmapOverlay");
  5060. var newHeatmap = new HeatmapOverlay(opts);
  5061. this.__proto__ = newHeatmap.__proto__;
  5062. }
  5063. this.conf = opts;
  5064. this.heatmap = null;
  5065. this.latlngs = [];
  5066. this.bounds = null;
  5067. this._moveendHandler = this._moveendHandler.bind(this);
  5068. };
  5069. HeatmapOverlay.prototype.initialize = function(map) {
  5070. this._map = map;
  5071. var el = document.createElement("div");
  5072. el.style.position = "absolute";
  5073. el.style.top = 0;
  5074. el.style.left = 0;
  5075. el.style.border = 0;
  5076. el.style.width = this._map.getSize().width + "px";
  5077. el.style.height = this._map.getSize().height + "px";
  5078. this.conf.element = el;
  5079. map.getPanes().mapPane.appendChild(el);
  5080. this.heatmap = heatmapFactory.create(this.conf);
  5081. this._div = el;
  5082. return el;
  5083. };
  5084. HeatmapOverlay.prototype.draw = function() {
  5085. var currentBounds = this._map.getBounds();
  5086. if (currentBounds.equals(this.bounds)) {
  5087. return;
  5088. }
  5089. this.bounds = currentBounds;
  5090. var ne = this._map.pointToOverlayPixel(currentBounds.getNorthEast()), sw = this._map.pointToOverlayPixel(currentBounds.getSouthWest());
  5091. if (!ne || !sw) {
  5092. return;
  5093. }
  5094. var topY = ne.y, leftX = sw.x, h = sw.y - ne.y, w = ne.x - sw.x;
  5095. this.conf.element.style.left = leftX + "px";
  5096. this.conf.element.style.top = topY + "px";
  5097. this.conf.element.style.width = w + "px";
  5098. this.conf.element.style.height = h + "px";
  5099. this.heatmap.store.get("heatmap").resize();
  5100. if (this.latlngs.length > 0) {
  5101. this.heatmap.clear();
  5102. var len = this.latlngs.length;
  5103. var d = {
  5104. max: this.heatmap.store.max,
  5105. data: []
  5106. };
  5107. while (len--) {
  5108. var latlng = this.latlngs[len].latlng;
  5109. if (!currentBounds.containsPoint(latlng)) {
  5110. continue;
  5111. }
  5112. var divPixel = this._map.pointToOverlayPixel(latlng), screenPixel = new BMap.Pixel(divPixel.x - leftX, divPixel.y - topY);
  5113. var roundedPoint = this.pixelTransform(screenPixel);
  5114. d.data.push({
  5115. x: roundedPoint.x,
  5116. y: roundedPoint.y,
  5117. count: this.latlngs[len].c
  5118. });
  5119. }
  5120. this.heatmap.store.setDataSet(d);
  5121. }
  5122. };
  5123. HeatmapOverlay.prototype.pixelTransform = function(p) {
  5124. var w = this.heatmap.get("width"), h = this.heatmap.get("height");
  5125. while (p.x < 0) {
  5126. p.x += w;
  5127. }
  5128. while (p.x > w) {
  5129. p.x -= w;
  5130. }
  5131. while (p.y < 0) {
  5132. p.y += h;
  5133. }
  5134. while (p.y > h) {
  5135. p.y -= h;
  5136. }
  5137. p.x = p.x >> 0;
  5138. p.y = p.y >> 0;
  5139. return p;
  5140. };
  5141. HeatmapOverlay.prototype._moveendHandler = function(e) {
  5142. this.setDataSet(this._data);
  5143. delete this._data;
  5144. this._map.removeEventListener("moveend", this._moveendHandler);
  5145. };
  5146. HeatmapOverlay.prototype.setDataSet = function(data) {
  5147. if (!this._map) {
  5148. return;
  5149. }
  5150. var currentBounds = this._map.getBounds();
  5151. var ne = this._map.pointToOverlayPixel(currentBounds.getNorthEast()), sw = this._map.pointToOverlayPixel(currentBounds.getSouthWest());
  5152. if (!ne || !sw) {
  5153. this._data = data;
  5154. this._map.addEventListener("moveend", this._moveendHandler);
  5155. }
  5156. var mapdata = {
  5157. max: data.max,
  5158. data: []
  5159. };
  5160. var d = data.data, dlen = d.length;
  5161. this.latlngs = [];
  5162. while (dlen--) {
  5163. var latlng = new BMap.Point(d[dlen].lng, d[dlen].lat);
  5164. this.latlngs.push({
  5165. latlng,
  5166. c: d[dlen].count
  5167. });
  5168. if (!currentBounds.containsPoint(latlng)) {
  5169. continue;
  5170. }
  5171. var divPixel = this._map.pointToOverlayPixel(latlng), leftX = this._map.pointToOverlayPixel(currentBounds.getSouthWest()).x, topY = this._map.pointToOverlayPixel(currentBounds.getNorthEast()).y, screenPixel = new BMap.Pixel(divPixel.x - leftX, divPixel.y - topY);
  5172. var point = this.pixelTransform(screenPixel);
  5173. mapdata.data.push({
  5174. x: point.x,
  5175. y: point.y,
  5176. count: d[dlen].count
  5177. });
  5178. }
  5179. this.heatmap.clear();
  5180. this.heatmap.store.setDataSet(mapdata);
  5181. };
  5182. HeatmapOverlay.prototype.addDataPoint = function(lng, lat, count) {
  5183. var latlng = new BMap.Point(lng, lat), point = this.pixelTransform(this._map.pointToOverlayPixel(latlng));
  5184. this.heatmap.store.addDataPoint(point.x, point.y, count);
  5185. this.latlngs.push({
  5186. latlng,
  5187. c: count
  5188. });
  5189. };
  5190. HeatmapOverlay.prototype.toggle = function() {
  5191. this.heatmap.toggleDisplay();
  5192. };
  5193. return HeatmapOverlay;
  5194. });
  5195. })(bmaplib_heatmap);
  5196. var Heatmap = bmaplib_heatmap.exports;
  5197. const _sfc_main$1 = {
  5198. name: "bml-heatmap",
  5199. render() {
  5200. },
  5201. mixins: [commonMixin("overlay")],
  5202. props: {
  5203. data: {
  5204. type: Array,
  5205. default: Array
  5206. },
  5207. max: {
  5208. type: Number
  5209. },
  5210. radius: {
  5211. type: Number
  5212. },
  5213. gradient: {
  5214. type: Object
  5215. },
  5216. opacity: {
  5217. type: Number
  5218. }
  5219. },
  5220. watch: {
  5221. data: {
  5222. handler() {
  5223. this.reload();
  5224. },
  5225. deep: true
  5226. },
  5227. max() {
  5228. this.reload();
  5229. },
  5230. radius(val) {
  5231. const { originInstance, opacity, gradient } = this;
  5232. originInstance.setOptions({
  5233. radius: val,
  5234. opacity,
  5235. gradient
  5236. });
  5237. },
  5238. gradient: {
  5239. handler(val) {
  5240. const { originInstance, radius, opacity } = this;
  5241. originInstance.setOptions({
  5242. radius,
  5243. opacity,
  5244. gradient: val
  5245. });
  5246. },
  5247. deep: true
  5248. },
  5249. opacity(val) {
  5250. const { originInstance, radius, gradient } = this;
  5251. originInstance.setOptions({
  5252. radius,
  5253. opacity: val,
  5254. gradient
  5255. });
  5256. }
  5257. },
  5258. methods: {
  5259. load() {
  5260. const { map, data, max, radius, opacity, gradient } = this;
  5261. const overlay = this.originInstance = new Heatmap({
  5262. radius,
  5263. opacity,
  5264. gradient
  5265. });
  5266. map.addOverlay(overlay);
  5267. overlay.setDataSet({ data, max });
  5268. }
  5269. }
  5270. };
  5271. var bmaplib_curveline = { exports: {} };
  5272. (function(module, exports) {
  5273. (function(root, factory) {
  5274. {
  5275. module.exports = factory();
  5276. }
  5277. })(commonjsGlobal, function() {
  5278. function CurveLine2(points, opts) {
  5279. try {
  5280. BMap;
  5281. } catch (e) {
  5282. throw Error("Baidu Map JS API is not ready yet!");
  5283. }
  5284. var curvePoints = getCurvePoints(points);
  5285. var polyline = new BMap.Polyline(curvePoints, opts);
  5286. polyline.addEventListener("lineupdate", function() {
  5287. if (this.isEditing) {
  5288. this.enableEditing();
  5289. }
  5290. });
  5291. polyline.cornerPoints = points;
  5292. polyline.editMarkers = [];
  5293. polyline.enableEditing = function() {
  5294. var self2 = this;
  5295. if (self2.map) {
  5296. self2.disableEditing();
  5297. for (var i = 0; i < self2.cornerPoints.length; i++) {
  5298. var marker = new BMap.Marker(self2.cornerPoints[i], {
  5299. icon: new BMap.Icon("http://api.map.baidu.com/library/CurveLine/1.5/src/circle.png", new BMap.Size(16, 16)),
  5300. enableDragging: true,
  5301. raiseOnDrag: true
  5302. });
  5303. marker.addEventListener("dragend", function() {
  5304. self2.cornerPoints.length = 0;
  5305. for (var i2 = 0; i2 < self2.editMarkers.length; i2++) {
  5306. self2.cornerPoints.push(self2.editMarkers[i2].getPosition());
  5307. }
  5308. var curvePoints2 = getCurvePoints(self2.cornerPoints);
  5309. self2.setPath(curvePoints2);
  5310. });
  5311. marker.index = i;
  5312. self2.editMarkers.push(marker);
  5313. self2.map.addOverlay(marker);
  5314. }
  5315. }
  5316. self2.isEditing = true;
  5317. };
  5318. polyline.disableEditing = function() {
  5319. this.isEditing = false;
  5320. for (var i = 0; i < this.editMarkers.length; i++) {
  5321. this.map.removeOverlay(this.editMarkers[i]);
  5322. this.editMarkers[i] = null;
  5323. }
  5324. this.editMarkers.length = 0;
  5325. };
  5326. polyline.getPath = function() {
  5327. return curvePoints;
  5328. };
  5329. return polyline;
  5330. }
  5331. function getCurvePoints(points) {
  5332. var curvePoints = [];
  5333. for (var i = 0; i < points.length - 1; i++) {
  5334. var p = getCurveByTwoPoints(points[i], points[i + 1]);
  5335. if (p && p.length > 0) {
  5336. curvePoints = curvePoints.concat(p);
  5337. }
  5338. }
  5339. return curvePoints;
  5340. }
  5341. function getCurveByTwoPoints(obj1, obj2) {
  5342. var curveCoordinates = [];
  5343. if (!obj1 || !obj2 || !(obj1 instanceof BMap.Point) || !(obj2 instanceof BMap.Point)) {
  5344. return null;
  5345. }
  5346. var B1 = function(x) {
  5347. return 1 - 2 * x + x * x;
  5348. };
  5349. var B2 = function(x) {
  5350. return 2 * x - 2 * x * x;
  5351. };
  5352. var B3 = function(x) {
  5353. return x * x;
  5354. };
  5355. var count = 30;
  5356. var t, h, h2, lat3, lng3, t2;
  5357. var i = 0;
  5358. var inc = 0;
  5359. if (typeof obj2 == "undefined") {
  5360. if (typeof curveCoordinates != "undefined") {
  5361. curveCoordinates = [];
  5362. }
  5363. return;
  5364. }
  5365. var lat1 = parseFloat(obj1.lat);
  5366. var lat2 = parseFloat(obj2.lat);
  5367. var lng1 = parseFloat(obj1.lng);
  5368. var lng2 = parseFloat(obj2.lng);
  5369. if (lng2 > lng1) {
  5370. if (parseFloat(lng2 - lng1) > 180) {
  5371. if (lng1 < 0) {
  5372. lng1 = parseFloat(180 + 180 + lng1);
  5373. }
  5374. }
  5375. }
  5376. if (lng1 > lng2) {
  5377. if (parseFloat(lng1 - lng2) > 180) {
  5378. if (lng2 < 0) {
  5379. lng2 = parseFloat(180 + 180 + lng2);
  5380. }
  5381. }
  5382. }
  5383. t2 = 0;
  5384. if (lat2 == lat1) {
  5385. t = 0;
  5386. h = lng1 - lng2;
  5387. } else if (lng2 == lng1) {
  5388. t = Math.PI / 2;
  5389. h = lat1 - lat2;
  5390. } else {
  5391. t = Math.atan((lat2 - lat1) / (lng2 - lng1));
  5392. h = (lat2 - lat1) / Math.sin(t);
  5393. }
  5394. if (t2 == 0) {
  5395. t2 = t + Math.PI / 5;
  5396. }
  5397. h2 = h / 2;
  5398. lng3 = h2 * Math.cos(t2) + lng1;
  5399. lat3 = h2 * Math.sin(t2) + lat1;
  5400. for (i = 0; i < count + 1; i++) {
  5401. curveCoordinates.push(new BMap.Point(lng1 * B1(inc) + lng3 * B2(inc) + lng2 * B3(inc), lat1 * B1(inc) + lat3 * B2(inc) + lat2 * B3(inc)));
  5402. inc = inc + 1 / count;
  5403. }
  5404. return curveCoordinates;
  5405. }
  5406. return CurveLine2;
  5407. });
  5408. })(bmaplib_curveline);
  5409. var CurveLine = bmaplib_curveline.exports;
  5410. const eventList = [
  5411. "click",
  5412. "dblclick",
  5413. "mousedown",
  5414. "mouseup",
  5415. "mouseout",
  5416. "mouseover",
  5417. "remove",
  5418. "lineupdate"
  5419. ];
  5420. const _sfc_main = {
  5421. name: "bml-curve-line",
  5422. render() {
  5423. },
  5424. mixins: [commonMixin("overlay")],
  5425. props: {
  5426. points: {
  5427. type: Array,
  5428. default: Array
  5429. },
  5430. strokeColor: {
  5431. type: String
  5432. },
  5433. strokeWeight: {
  5434. type: Number
  5435. },
  5436. strokeOpacity: {
  5437. type: Number
  5438. },
  5439. strokeStyle: {
  5440. type: String
  5441. },
  5442. massClear: {
  5443. type: Boolean,
  5444. default: true
  5445. },
  5446. clicking: {
  5447. type: Boolean,
  5448. default: true
  5449. },
  5450. editing: {
  5451. type: Boolean,
  5452. default: false
  5453. }
  5454. },
  5455. watch: {
  5456. points: {
  5457. handler(val, oldVal) {
  5458. this.originInstance.disableEditing();
  5459. this.reload();
  5460. },
  5461. deep: true
  5462. },
  5463. strokeColor(val) {
  5464. this.originInstance.setStrokeColor(val);
  5465. },
  5466. strokeOpacity(val) {
  5467. this.originInstance.setStrokeOpacity(val);
  5468. },
  5469. strokeWeight(val) {
  5470. this.originInstance.setStrokeWeight(val);
  5471. },
  5472. strokeStyle(val) {
  5473. this.originInstance.setStrokeStyle(val);
  5474. },
  5475. editing(val) {
  5476. val ? this.originInstance.enableEditing() : this.originInstance.disableEditing();
  5477. },
  5478. massClear(val) {
  5479. val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
  5480. },
  5481. clicking(val) {
  5482. this.reload();
  5483. }
  5484. },
  5485. methods: {
  5486. load() {
  5487. const { BMap: BMap2, map, points, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking } = this;
  5488. const overlay = new CurveLine(points.map((item) => createPoint(BMap2, item)), {
  5489. strokeColor,
  5490. strokeWeight,
  5491. strokeOpacity,
  5492. strokeStyle,
  5493. enableMassClear: massClear,
  5494. enableClicking: clicking
  5495. });
  5496. editing ? overlay.enableEditing() : overlay.disableEditing();
  5497. this.originInstance = overlay;
  5498. map.addOverlay(overlay);
  5499. bindEvents.call(this, overlay, eventList);
  5500. }
  5501. }
  5502. };
  5503. const useMap = () => {
  5504. return new Promise((resolve) => {
  5505. getBMap().then((BMap2) => {
  5506. resolve(BMap2);
  5507. });
  5508. });
  5509. };
  5510. let geocoder;
  5511. const useGeocoder = () => {
  5512. return new Promise((resolve) => {
  5513. if (geocoder) {
  5514. resolve(geocoder);
  5515. } else {
  5516. useMap().then((BMap2) => {
  5517. geocoder = new BMap2.Geocoder();
  5518. resolve(geocoder);
  5519. });
  5520. }
  5521. });
  5522. };
  5523. const usePoint = (lng, lat) => {
  5524. return new Promise((resolve) => {
  5525. useMap().then((BMap2) => {
  5526. const point = new BMap2.Point(lng, lat);
  5527. resolve(point);
  5528. });
  5529. });
  5530. };
  5531. var index = {
  5532. install(Vue, options = {}) {
  5533. setConfig(options);
  5534. Vue.component("baidu-map", BaiduMap);
  5535. Vue.component("bm-scale", _sfc_main$w);
  5536. Vue.component("bm-navigation", _sfc_main$v);
  5537. Vue.component("bm-map-type", _sfc_main$u);
  5538. Vue.component("bm-overview-map", _sfc_main$t);
  5539. Vue.component("bm-geolocation", _sfc_main$s);
  5540. Vue.component("bm-copyright", _sfc_main$r);
  5541. Vue.component("bm-city-list", _sfc_main$q);
  5542. Vue.component("bm-panorama", _sfc_main$p);
  5543. Vue.component("bm-control", BmControl);
  5544. Vue.component("bm-marker", BmMarker);
  5545. Vue.component("bm-point-collection", _sfc_main$m);
  5546. Vue.component("bm-polyline", _sfc_main$l);
  5547. Vue.component("bm-polygon", _sfc_main$k);
  5548. Vue.component("bm-circle", _sfc_main$j);
  5549. Vue.component("bm-ground", _sfc_main$i);
  5550. Vue.component("bm-label", _sfc_main$h);
  5551. Vue.component("bm-info-window", BmInfoWindow);
  5552. Vue.component("bm-overlay", BmOverlay);
  5553. Vue.component("bm-context-menu", BmContextMenu);
  5554. Vue.component("bm-context-menu-item", BmContextMenuItem);
  5555. Vue.component("bm-local-search", BmLocalSearch);
  5556. Vue.component("bm-transit", BmTransit);
  5557. Vue.component("bm-walking", BmWalking);
  5558. Vue.component("bm-driving", BmDriving);
  5559. Vue.component("bm-bus", BmBus);
  5560. Vue.component("bm-tile", _sfc_main$7);
  5561. Vue.component("bm-traffic", _sfc_main$6);
  5562. Vue.component("bm-auto-complete", BmAutoComplete);
  5563. Vue.component("bm-boundary", BmBoundary);
  5564. }
  5565. };
  5566. export { BaiduMap, BmAutoComplete, BmBoundary, BmBus, _sfc_main$j as BmCircle, _sfc_main$q as BmCityList, BmContextMenu, BmContextMenuItem, BmControl, _sfc_main$r as BmCopyright, BmDriving, _sfc_main$s as BmGeolocation, _sfc_main$i as BmGround, BmInfoWindow, _sfc_main$h as BmLabel, BmLocalSearch, _sfc_main$u as BmMapType, BmMarker, _sfc_main$v as BmNavigation, BmOverlay, _sfc_main$t as BmOverviewMap, _sfc_main$p as BmPanorama, _sfc_main$m as BmPointCollection, _sfc_main$k as BmPolygon, _sfc_main$l as BmPolyline, _sfc_main$w as BmScale, _sfc_main$7 as BmTile, _sfc_main$6 as BmTraffic, BmTransit, BmWalking, _sfc_main as BmlCurveLine, _sfc_main$1 as BmlHeatmap, _sfc_main$2 as BmlLushu, MarkerClusterer as BmlMarkerClusterer, index as default, getAddressByPoints, getConfig, getPointByAddress, getPointsTransfer, useGeocoder, useMap, usePoint };