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

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