1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626 |
- import {
- Fragment,
- createBaseVNode,
- createBlock,
- createCommentVNode,
- createElementBlock,
- normalizeClass,
- normalizeStyle,
- openBlock,
- renderList,
- renderSlot,
- resolveComponent,
- vShow,
- withDirectives
- } from "./chunk-3NMN3MUW.js";
- import "./chunk-AC2VUBZ6.js";
- // node_modules/vue-baidu-map-3x/dist/vue-baidu-map-3x.es.js
- var events = {
- "bm-map": [
- "click",
- "dblclick",
- "rightclick",
- "rightdblclick",
- "maptypechange",
- "mousemove",
- "mouseover",
- "mouseout",
- "movestart",
- "moving",
- "moveend",
- "zoomstart",
- "zoomend",
- "addoverlay",
- "addcontrol",
- "removecontrol",
- "removeoverlay",
- "clearoverlays",
- "dragstart",
- "dragging",
- "dragend",
- "addtilelayer",
- "removetilelayer",
- "load",
- "resize",
- "hotspotclick",
- "hotspotover",
- "hotspotout",
- "tilesloaded",
- "touchstart",
- "touchmove",
- "touchend",
- "longpress"
- ],
- "bm-geolocation": [
- "locationSuccess",
- "locationError"
- ],
- "bm-overview-map": [
- "viewchanged",
- "viewchanging"
- ],
- "bm-marker": [
- "click",
- "dblclick",
- "mousedown",
- "mouseup",
- "mouseout",
- "mouseover",
- "remove",
- "infowindowclose",
- "infowindowopen",
- "dragstart",
- "dragging",
- "dragend",
- "rightclick"
- ],
- "bm-polyline": [
- "click",
- "dblclick",
- "mousedown",
- "mouseup",
- "mouseout",
- "mouseover",
- "remove",
- "lineupdate"
- ],
- "bm-polygon": [
- "click",
- "dblclick",
- "mousedown",
- "mouseup",
- "mouseout",
- "mouseover",
- "remove",
- "lineupdate"
- ],
- "bm-circle": [
- "click",
- "dblclick",
- "mousedown",
- "mouseup",
- "mouseout",
- "mouseover",
- "remove",
- "lineupdate"
- ],
- "bm-label": [
- "click",
- "dblclick",
- "mousedown",
- "mouseup",
- "mouseout",
- "mouseover",
- "remove",
- "rightclick"
- ],
- "bm-info-window": [
- "close",
- "open",
- "maximize",
- "restore",
- "clickclose"
- ],
- "bm-ground": [
- "click",
- "dblclick"
- ],
- "bm-autocomplete": [
- "onconfirm",
- "onhighlight"
- ],
- "bm-point-collection": [
- "click",
- "mouseover",
- "mouseout"
- ]
- };
- function bindEvents(instance2, eventList2) {
- const ev = eventList2 || events[this.$options.name];
- ev && ev.forEach((event) => {
- const hasOn = event.slice(0, 2) === "on";
- let eventName = hasOn ? event.slice(2) : event;
- const listener = this.$attrs["on" + eventName.replace(eventName[0], eventName[0].toUpperCase())];
- listener && instance2.addEventListener(event, listener);
- });
- }
- function createPoint(BMap2, options = {}) {
- const { lng, lat } = options;
- return new BMap2.Point(lng, lat);
- }
- function createBounds(BMap2, options = {}) {
- const { sw, ne } = options;
- return new BMap2.Bounds(createPoint(BMap2, sw), createPoint(BMap2, ne));
- }
- function createSize(BMap2, options = {}) {
- const { width, height } = options;
- return new BMap2.Size(width, height);
- }
- function createIcon(BMap2, options = {}) {
- const { url, size, opts = {} } = options;
- let iconOption = {
- anchor: opts.anchor && createSize(BMap2, opts.anchor),
- imageSize: opts.imageSize && createSize(BMap2, opts.imageSize),
- imageOffset: opts.imageOffset && createSize(BMap2, opts.imageOffset),
- infoWindowAnchor: opts.infoWindowAnchor && createSize(BMap2, opts.infoWindowAnchor),
- printImageUrl: opts.printImageUrl
- };
- deleteEmptyKey(iconOption);
- return new BMap2.Icon(url, createSize(BMap2, size), iconOption);
- }
- function createLabel(BMap2, options = {}) {
- const { content, opts } = options;
- let labelOption = {
- offset: opts.offset && createSize(BMap2, opts.offset),
- position: opts.position && createPoint(BMap2, opts.position),
- enableMassClear: opts.enableMassClear
- };
- deleteEmptyKey(labelOption);
- return new BMap2.Label(content, labelOption);
- }
- function createSymbol(BMap2, options = {}) {
- const { path, opts } = options;
- let symbolOption = {
- anchor: opts.anchor && createSize(BMap2, opts.anchor),
- fillColor: opts.fillColor,
- fillOpacity: opts.fillOpacity,
- scale: opts.scale,
- rotation: opts.rotation,
- strokeColor: opts.strokeColor,
- strokeOpacity: opts.strokeOpacity,
- strokeWeight: opts.strokeWeight
- };
- deleteEmptyKey(symbolOption);
- return new BMap2.Symbol(window[path] || path, symbolOption);
- }
- function createIconSequence(BMap2, options = {}) {
- const { symbol, offset, repeat, fixedRotation } = options;
- return new BMap2.IconSequence(symbol && createSymbol(BMap2, symbol), offset, repeat, fixedRotation);
- }
- var isPoint = (obj) => obj.lng && obj.lat;
- var checkType = (val) => Object.prototype.toString.call(val).slice(8, -1);
- var getPosition = (BMap2, point) => isPoint(point) ? createPoint(BMap2, point) : point;
- var deleteEmptyKey = (obj) => {
- Object.keys(obj).forEach((key) => {
- if (typeof obj[key] === "undefined") {
- delete obj[key];
- }
- });
- };
- var config = {
- v: "3.0",
- type: "API"
- };
- var setConfig = (options = {}) => {
- config = Object.assign(config, options);
- if (!config.ak) {
- console.error("请配置ak:百度地图开发者平台申请的密钥");
- }
- };
- var getConfig = () => {
- return config;
- };
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
- var tinyEmitter = { exports: {} };
- function E$1() {
- }
- E$1.prototype = {
- on: function(name, callback, ctx) {
- var e = this.e || (this.e = {});
- (e[name] || (e[name] = [])).push({
- fn: callback,
- ctx
- });
- return this;
- },
- once: function(name, callback, ctx) {
- var self2 = this;
- function listener() {
- self2.off(name, listener);
- callback.apply(ctx, arguments);
- }
- listener._ = callback;
- return this.on(name, listener, ctx);
- },
- emit: function(name) {
- var data = [].slice.call(arguments, 1);
- var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
- var i = 0;
- var len = evtArr.length;
- for (i; i < len; i++) {
- evtArr[i].fn.apply(evtArr[i].ctx, data);
- }
- return this;
- },
- off: function(name, callback) {
- var e = this.e || (this.e = {});
- var evts = e[name];
- var liveEvents = [];
- if (evts && callback) {
- for (var i = 0, len = evts.length; i < len; i++) {
- if (evts[i].fn !== callback && evts[i].fn._ !== callback)
- liveEvents.push(evts[i]);
- }
- }
- liveEvents.length ? e[name] = liveEvents : delete e[name];
- return this;
- }
- };
- tinyEmitter.exports = E$1;
- tinyEmitter.exports.TinyEmitter = E$1;
- var E = tinyEmitter.exports;
- var instance = new E();
- var EvenBus = {
- $on: (...args) => instance.on(...args),
- $once: (...args) => instance.once(...args),
- $off: (...args) => instance.off(...args),
- $emit: (...args) => instance.emit(...args)
- };
- var methods = {
- "API": {
- "2.0": {
- setMapStyle: "setMapStyle",
- NavigationControl: "NavigationControl"
- },
- "3.0": {
- setMapStyle: "setMapStyleV2",
- NavigationControl: "NavigationControl"
- }
- },
- "WebGL": {
- setMapStyle: "setMapStyleV2",
- NavigationControl: "NavigationControl3D"
- }
- };
- var getMapMethod = (method) => {
- const config2 = getConfig();
- if (config2.type == "WebGL") {
- return methods[config2.type][method];
- } else {
- return methods[config2.type][config2.v][method];
- }
- };
- var mapLoadResolve;
- var mapLoadPromise = new Promise((resolve) => {
- mapLoadResolve = resolve;
- });
- var getBMap = () => {
- return mapLoadPromise;
- };
- function getParamsStrByObject(obj) {
- let arr = [];
- Object.keys(obj).forEach((key) => {
- arr.push(key + "=" + obj[key]);
- });
- return arr.join("&");
- }
- function getAddressByPoints(config2, aks = []) {
- if (!config2.location || !config2.location.length) {
- console.error("请传入location");
- }
- const appConfig = getConfig();
- if (appConfig.ak) {
- aks.push(appConfig.ak);
- }
- return new Promise((resolve, reject) => {
- if (aks.length) {
- let params = Object.assign({
- location: [],
- extensions_poi: 1,
- output: "json",
- coordtype: "wgs84ll",
- timeout: 60
- }, config2);
- let num = 0;
- const requestBaidu = () => {
- var _a;
- const timer = setTimeout(() => {
- reject(new Error("查询超时"));
- }, params.timeout * 1e3);
- const callbackName = "baiduReverse" + Math.floor(Math.random() * 1e6);
- params.callback = callbackName;
- window[callbackName] = (res) => {
- var _a2;
- clearTimeout(timer);
- window[callbackName] = null;
- (_a2 = document.getElementById(callbackName)) == null ? void 0 : _a2.remove();
- if (!res.status) {
- resolve(res.result);
- } else {
- if (num < aks.length * 4) {
- num++;
- requestBaidu();
- } else {
- reject(new Error("查询失败"));
- }
- }
- };
- params.ak = aks[num % aks.length];
- let script = document.createElement("script");
- script.id = callbackName;
- script.src = `https://api.map.baidu.com/reverse_geocoding/v3/?${getParamsStrByObject(params)}`;
- (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
- };
- requestBaidu();
- } else {
- console.error("请配置百度ak!");
- reject(new Error("请配置百度ak!"));
- }
- });
- }
- function getPointByAddress(config2, aks = []) {
- if (!config2.address) {
- console.error("请传入address");
- }
- const appConfig = getConfig();
- if (appConfig.ak) {
- aks.push(appConfig.ak);
- }
- return new Promise((resolve, reject) => {
- if (aks.length) {
- let params = Object.assign({
- address: "",
- output: "json",
- timeout: 60
- }, config2);
- let num = 0;
- const requestBaidu = () => {
- var _a;
- const timer = setTimeout(() => {
- reject(new Error("查询超时"));
- }, params.timeout * 1e3);
- const callbackName = "baidugeocoding" + Math.floor(Math.random() * 1e6);
- params.callback = callbackName;
- window[callbackName] = (res) => {
- var _a2;
- clearTimeout(timer);
- window[callbackName] = null;
- (_a2 = document.getElementById(callbackName)) == null ? void 0 : _a2.remove();
- if (!res.status) {
- resolve(res.result);
- } else {
- if (num < aks.length * 4) {
- num++;
- requestBaidu();
- } else {
- reject(new Error("查询失败"));
- }
- }
- };
- params.ak = aks[num % aks.length];
- let script = document.createElement("script");
- script.id = callbackName;
- script.src = `https://api.map.baidu.com/geocoding/v3/?${getParamsStrByObject(params)}`;
- (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
- };
- requestBaidu();
- } else {
- console.error("请配置百度ak!");
- reject(new Error("请配置百度ak!"));
- }
- });
- }
- function getPointsTransfer(config2, aks = []) {
- if (!config2.locations || !config2.locations.length) {
- console.error("请传入locations");
- }
- const appConfig = getConfig();
- if (appConfig.ak) {
- aks.push(appConfig.ak);
- }
- return new Promise((resolve, reject) => {
- if (aks.length) {
- let params = Object.assign({
- locations: [],
- from: 1,
- to: 5,
- timeout: 60
- }, config2);
- let num = 0;
- const requestBaidu = () => {
- var _a;
- const timer = setTimeout(() => {
- reject(new Error("查询超时"));
- }, params.timeout * 1e3);
- const callbackName = "baidugeoconv" + Math.floor(Math.random() * 1e6);
- params.callback = callbackName;
- window[callbackName] = (res) => {
- var _a2;
- clearTimeout(timer);
- window[callbackName] = null;
- (_a2 = document.getElementById(callbackName)) == null ? void 0 : _a2.remove();
- if (!res.status) {
- resolve(res.result);
- } else {
- if (num < aks.length * 4) {
- num++;
- requestBaidu();
- } else {
- reject(new Error("查询失败"));
- }
- }
- };
- params.ak = aks[num % aks.length];
- params.coords = params.locations.join(";");
- let script = document.createElement("script");
- script.id = callbackName;
- script.src = `https://api.map.baidu.com/geoconv/v1/?${getParamsStrByObject(params)}`;
- (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
- };
- requestBaidu();
- } else {
- console.error("请配置百度ak!");
- reject(new Error("请配置百度ak!"));
- }
- });
- }
- var _export_sfc = (sfc, props) => {
- const target = sfc.__vccOpts || sfc;
- for (const [key, val] of props) {
- target[key] = val;
- }
- return target;
- };
- var _sfc_main$x = {
- name: "bm-map",
- inheritAttrs: false,
- emits: ["ready", "init", "animationed"],
- props: {
- ak: {
- type: String
- },
- v: {
- type: String
- },
- type: {
- type: String
- },
- center: {
- type: [Object, String]
- },
- zoom: {
- type: Number
- },
- minZoom: {
- type: Number
- },
- maxZoom: {
- type: Number
- },
- highResolution: {
- type: Boolean,
- default: true
- },
- mapClick: {
- type: Boolean,
- default: true
- },
- mapType: {
- type: String
- },
- dragging: {
- type: Boolean,
- default: true
- },
- scrollWheelZoom: {
- type: Boolean,
- default: false
- },
- doubleClickZoom: {
- type: Boolean,
- default: true
- },
- keyboard: {
- type: Boolean,
- default: true
- },
- inertialDragging: {
- type: Boolean,
- default: true
- },
- continuousZoom: {
- type: Boolean,
- default: true
- },
- pinchToZoom: {
- type: Boolean,
- default: true
- },
- autoResize: {
- type: Boolean,
- default: true
- },
- theme: {
- type: Array
- },
- mapStyle: {
- type: Object
- },
- hasAnimation: {
- type: Boolean,
- default: true
- },
- defaultAnimation: {
- type: Boolean,
- default: true
- }
- },
- watch: {
- center(val, oldVal) {
- const { map, zoom } = this;
- if (checkType(val) === "String" && val !== oldVal) {
- this.setCenterZoom(map, val, zoom);
- }
- },
- "center.lng"(val, oldVal) {
- const { BMap: BMap2, map, zoom, center } = this;
- if (val !== oldVal && val >= -180 && val <= 180) {
- this.setCenterZoom(map, new BMap2.Point(val, center.lat), zoom);
- }
- },
- "center.lat"(val, oldVal) {
- const { BMap: BMap2, map, zoom, center } = this;
- if (val !== oldVal && val >= -74 && val <= 74) {
- this.setCenterZoom(map, new BMap2.Point(center.lng, val), zoom);
- }
- },
- zoom(val, oldVal) {
- const { map } = this;
- if (val !== oldVal && val >= 3 && val <= 19) {
- map.setZoom(val);
- }
- },
- minZoom(val) {
- const { map } = this;
- map.setMinZoom(val);
- },
- maxZoom(val) {
- const { map } = this;
- map.setMaxZoom(val);
- },
- highResolution() {
- this.reset();
- },
- mapClick() {
- this.reset();
- },
- mapType(val) {
- const { map } = this;
- map.setMapType(window[val]);
- },
- dragging(val) {
- const { map } = this;
- val ? map.enableDragging() : map.disableDragging();
- },
- scrollWheelZoom(val) {
- const { map } = this;
- val ? map.enableScrollWheelZoom() : map.disableScrollWheelZoom();
- },
- doubleClickZoom(val) {
- const { map } = this;
- val ? map.enableDoubleClickZoom() : map.disableDoubleClickZoom();
- },
- keyboard(val) {
- const { map } = this;
- val ? map.enableKeyboard() : map.disableKeyboard();
- },
- inertialDragging(val) {
- const { map } = this;
- val ? map.enableInertialDragging() : map.disableInertialDragging();
- },
- continuousZoom(val) {
- const { map } = this;
- val ? map.enableContinuousZoom() : map.disableContinuousZoom();
- },
- pinchToZoom(val) {
- const { map } = this;
- val ? map.enablePinchToZoom() : map.disablePinchToZoom();
- },
- autoResize(val) {
- const { map } = this;
- val ? map.enableAutoResize() : map.disableAutoResize();
- },
- theme(val) {
- const { map } = this;
- map[getMapMethod("setMapStyle")]({ styleJson: val });
- },
- mapStyle: {
- handler(val) {
- const { map, theme } = this;
- !theme && map[getMapMethod("setMapStyle")](val);
- },
- deep: true
- }
- },
- methods: {
- setMapOptions() {
- const { map, minZoom, maxZoom, mapType, dragging, scrollWheelZoom, doubleClickZoom, keyboard, inertialDragging, continuousZoom, pinchToZoom, autoResize } = this;
- minZoom && map.setMinZoom(minZoom);
- maxZoom && map.setMaxZoom(maxZoom);
- mapType && map.setMapType(window[mapType]);
- dragging ? map.enableDragging() : map.disableDragging();
- scrollWheelZoom ? map.enableScrollWheelZoom() : map.disableScrollWheelZoom();
- doubleClickZoom ? map.enableDoubleClickZoom() : map.disableDoubleClickZoom();
- keyboard ? map.enableKeyboard() : map.disableKeyboard();
- inertialDragging ? map.enableInertialDragging() : map.disableInertialDragging();
- continuousZoom ? map.enableContinuousZoom() : map.disableContinuousZoom();
- pinchToZoom ? map.enablePinchToZoom() : map.disablePinchToZoom();
- autoResize ? map.enableAutoResize() : map.disableAutoResize();
- },
- init(BMap2) {
- if (this.map) {
- return;
- }
- let $el = this.$refs.view;
- if (this.$slots.default)
- ;
- const map = new BMap2.Map($el, { enableHighResolution: this.highResolution, enableMapClick: this.mapClick });
- this.map = map;
- const { setMapOptions, zoom, getCenterPoint, theme, mapStyle } = this;
- setMapOptions();
- bindEvents.call(this, map);
- map.reset();
- this.setCenterZoom(map, getCenterPoint(), zoom);
- theme ? map[getMapMethod("setMapStyle")]({ styleJson: theme }) : mapStyle && map[getMapMethod("setMapStyle")](mapStyle);
- let loadNum = 0;
- this.$emit("init", { BMap: BMap2, map });
- EvenBus.$emit("init", { BMap: BMap2, map });
- map.addEventListener("tilesloaded", () => {
- if (!loadNum) {
- loadNum++;
- this.$emit("ready", { BMap: BMap2, map });
- EvenBus.$emit("ready", { BMap: BMap2, map });
- }
- });
- map.addEventListener("loaded", () => {
- this.$emit("loaded", { BMap: BMap2, map });
- EvenBus.$emit("loaded", { BMap: BMap2, map });
- });
- },
- setCenterZoom(map, center, zoom) {
- if (getConfig().type === "WebGL") {
- if (!this.hasAnimation || !this.defaultAnimation) {
- map.setCenter(center, {
- noAnimation: !this.hasAnimation,
- callback: () => {
- map.setZoom(zoom, {
- noAnimation: !this.hasAnimation,
- zoomCenter: center,
- callback: () => {
- this.$emit("animationed", { BMap: this.BMap, map });
- }
- });
- }
- });
- } else {
- map.centerAndZoom(center, zoom);
- }
- } else {
- map.centerAndZoom(center, zoom);
- }
- },
- getCenterPoint() {
- const { center, BMap: BMap2 } = this;
- switch (checkType(center)) {
- case "String":
- return center;
- case "Object":
- return new BMap2.Point(center.lng, center.lat);
- default:
- return new BMap2.Point();
- }
- },
- initMap(BMap2) {
- this.BMap = BMap2;
- this.init(BMap2);
- mapLoadResolve(BMap2);
- },
- getMapScript() {
- if (!window.BMap) {
- window.BMap = {};
- window.BMap._preloader = new Promise((resolve, reject) => {
- window._initBaiduMap = function() {
- window.BMap = getConfig().type == "WebGL" ? window.BMapGL : window.BMap;
- resolve(window.BMap);
- window.document.body.removeChild($script);
- window.BMap._preloader = null;
- window._initBaiduMap = null;
- };
- const $script = document.createElement("script");
- window.document.body.appendChild($script);
- switch (getConfig().type) {
- case "WebGL":
- $script.src = `https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${getConfig().ak}&callback=_initBaiduMap`;
- break;
- default:
- $script.src = `https://api.map.baidu.com/api?v=${getConfig().v}&ak=${getConfig().ak}&callback=_initBaiduMap`;
- }
- });
- return window.BMap._preloader;
- } else if (!window.BMap._preloader) {
- return Promise.resolve(window.BMap);
- } else {
- return window.BMap._preloader;
- }
- },
- reset() {
- const { getMapScript, initMap } = this;
- getMapScript().then(initMap);
- }
- },
- created() {
- const options = {};
- this.ak && (options.ak = this.ak);
- this.v && (options.v = this.v);
- this.type && (options.type = this.type);
- setConfig(options);
- },
- mounted() {
- this.reset();
- },
- data() {
- return {
- hasBmView: false,
- map: null,
- BMap: null,
- name: "bm-map"
- };
- }
- };
- var _hoisted_1$2 = {
- key: 0,
- ref: "view",
- style: { "width": "100%", "height": "100%" }
- };
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", {
- class: normalizeClass(_ctx.$attrs.class),
- style: normalizeStyle(_ctx.$attrs.style)
- }, [
- !$data.hasBmView ? (openBlock(), createElementBlock("div", _hoisted_1$2, null, 512)) : createCommentVNode("", true),
- renderSlot(_ctx.$slots, "default")
- ], 6);
- }
- var BaiduMap = _export_sfc(_sfc_main$x, [["render", _sfc_render$e]]);
- var types = {
- control: {
- unload: "removeControl"
- },
- layer: {
- unload: "removeTileLayer"
- },
- overlay: {
- unload: "removeOverlay"
- },
- contextMenu: {
- unload: "removeContextMenu"
- }
- };
- var getParent = ($component) => {
- return $component.abstract || $component.name !== "bm-map" ? getParent($component.$parent) : $component;
- };
- function destroyInstance() {
- const { unload, renderByParent, $parent, ready } = this;
- EvenBus.$off("ready", ready);
- if (renderByParent) {
- $parent.reload();
- }
- unload();
- }
- var getMixin = (prop = {}) => {
- return {
- emits: ["ready"],
- computed: {
- renderByParent() {
- return this.$parent.preventChildrenRender;
- }
- },
- created() {
- const $parent = getParent(this.$parent);
- const map = $parent.map;
- const { ready } = this;
- map ? ready() : EvenBus.$on("ready", ready);
- map ? this.init({ BMap: $parent.BMap, map }) : EvenBus.$on("init", this.init);
- },
- mounted() {
- const $parent = getParent(this.$parent);
- const map = $parent.map;
- const { mountedReady } = this;
- map ? mountedReady() : EvenBus.$on("ready", mountedReady);
- },
- unmounted: destroyInstance,
- methods: {
- init() {
- },
- ready() {
- const $parent = getParent(this.$parent);
- const BMap2 = this.BMap = $parent.BMap;
- const map = this.map = $parent.map;
- this.load();
- this.$emit("ready", {
- BMap: BMap2,
- map
- });
- },
- mountedReady() {
- this.mountedLoad();
- },
- transmitEvent(e) {
- this.$emit(e.type.replace(/^on/, ""), e);
- },
- reload() {
- this && this.BMap && this.$nextTick(() => {
- this.unload();
- this.$nextTick(() => {
- this.load();
- this.mountedLoad();
- });
- });
- },
- unload() {
- const { map, originInstance } = this;
- try {
- switch (prop.type) {
- case "search":
- return originInstance.clearResults();
- case "autoComplete":
- case "lushu":
- return originInstance.dispose();
- case "markerClusterer":
- return originInstance.clearMarkers();
- default:
- map[types[prop.type].unload](originInstance);
- }
- } catch (e) {
- }
- },
- mountedLoad() {
- }
- }
- };
- };
- var commonMixin = (type) => getMixin({ type });
- var _sfc_main$w = {
- name: "bm-scale",
- render() {
- },
- mixins: [commonMixin("control")],
- props: {
- anchor: {
- type: String
- },
- offset: {
- type: Object
- }
- },
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, offset } = this;
- this.originInstance = new BMap2.ScaleControl({
- anchor: window[anchor],
- offset: offset && createSize(BMap2, offset)
- });
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$v = {
- name: "bm-navigation",
- render() {
- },
- mixins: [commonMixin("control")],
- props: {
- anchor: {
- type: String
- },
- offset: {
- type: Object
- },
- type: {
- type: String
- },
- showZoomInfo: {
- type: Boolean
- },
- enableGeolocation: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- },
- type() {
- this.reload();
- },
- showZoomInfo() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, offset, type, showZoomInfo, enableGeolocation } = this;
- let navigationOption = {
- anchor: window[anchor],
- offset: offset && createSize(BMap2, offset),
- type: window[type],
- showZoomInfo,
- enableGeolocation
- };
- deleteEmptyKey(navigationOption);
- this.originInstance = new BMap2[getMapMethod("NavigationControl")](navigationOption);
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$u = {
- name: "bm-map-type",
- render() {
- },
- mixins: [commonMixin("control")],
- props: ["type", "mapTypes", "anchor", "offset"],
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- },
- type() {
- this.reload();
- },
- mapTypes() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, offset, type } = this;
- const mapTypes = [];
- this.mapTypes && this.mapTypes.forEach((item) => mapTypes.push(window[item]));
- let maptypeControlOption = {
- anchor: window[anchor],
- offset: offset && createSize(BMap2, offset),
- type: window[type],
- mapTypes
- };
- deleteEmptyKey(maptypeControlOption);
- this.originInstance = new BMap2.MapTypeControl(maptypeControlOption);
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$t = {
- name: "bm-overview-map",
- mixins: [commonMixin("control")],
- render() {
- },
- props: {
- anchor: {
- type: String
- },
- offset: {
- type: Object
- },
- size: {
- type: Object
- },
- isOpen: {
- type: Boolean
- }
- },
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- },
- size() {
- this.reload();
- },
- isOpen() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, isOpen, size, offset, anchor } = this;
- this.mapTypes && this.mapTypes.forEach((item) => {
- });
- let overviewOption = {
- anchor: window[anchor],
- offset: createSize(BMap2, offset),
- size: createSize(BMap2, size),
- isOpen
- };
- deleteEmptyKey(overviewOption);
- this.originInstance = new BMap2.OverviewMapControl(overviewOption);
- bindEvents.call(this, this.originInstance);
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$s = {
- name: "bm-geolocation",
- render() {
- },
- mixins: [commonMixin("control")],
- props: {
- anchor: {
- type: String
- },
- offset: {
- type: Object
- },
- showAddressBar: {
- type: Boolean
- },
- autoLocation: {
- type: Boolean
- },
- locationIcon: {
- type: Object
- }
- },
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- },
- showAddressBar() {
- this.reload();
- },
- autoLocation() {
- this.reload();
- },
- locationIcon() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, showAddressBar, autoLocation, locationIcon, offset } = this;
- let geoLocationOption = {
- anchor: window[anchor],
- showAddressBar,
- enableAutoLocation: autoLocation,
- offset: offset && createSize(BMap2, offset),
- locationIcon: locationIcon && createIcon(BMap2, locationIcon)
- };
- deleteEmptyKey(geoLocationOption);
- switch (getConfig().type) {
- case "WebGL":
- this.originInstance = new BMap2.LocationControl(geoLocationOption);
- break;
- default:
- this.originInstance = new BMap2.GeolocationControl(geoLocationOption);
- }
- bindEvents.call(this, this.originInstance);
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$r = {
- name: "bm-copyright",
- render() {
- },
- mixins: [commonMixin("control")],
- props: ["anchor", "offset", "copyright"],
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- },
- copyright() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, offset, anchor, updateCopyrightList } = this;
- this.originInstance = new BMap2.CopyrightControl({
- anchor: window[anchor],
- offset: offset && createSize(BMap2, offset)
- });
- updateCopyrightList();
- map.addControl(this.originInstance);
- },
- updateCopyrightList() {
- const { BMap: BMap2, map } = this;
- const { removeCopyright, getCopyrightCollection } = this.originInstance;
- const copyrightList = getCopyrightCollection();
- copyrightList && copyrightList.forEach((item) => {
- removeCopyright(item.id);
- });
- this.copyright && this.copyright.forEach((item) => {
- 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();
- this.originInstance.addCopyright({
- id: item.id,
- content: item.content,
- bounds
- });
- });
- }
- }
- };
- var _sfc_main$q = {
- name: "bm-city-list",
- render() {
- },
- emits: ["changeBefore", "changeAfter"],
- mixins: [commonMixin("control")],
- props: {
- anchor: {
- type: String
- },
- offset: {
- type: Object
- }
- },
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, offset } = this;
- const self2 = this;
- this.originInstance = new BMap2.CityListControl({
- anchor: window[anchor],
- offset: offset && createSize(BMap2, offset),
- onChangeBefore() {
- self2.$emit("changeBefore");
- },
- onChangeAfter() {
- self2.$emit("changeAfter");
- }
- });
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$p = {
- name: "bm-panorama",
- mixins: [commonMixin("control")],
- render() {
- },
- props: ["anchor", "offset"],
- watch: {
- anchor() {
- this.reload();
- },
- offset() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, offset } = this;
- this.originInstance = new BMap2.PanoramaControl({
- anchor: window[anchor],
- offset: offset && createSize(BMap2, offset)
- });
- map.addControl(this.originInstance);
- }
- }
- };
- var _sfc_main$o = {
- name: "bm-control",
- mixins: [commonMixin("control")],
- props: ["anchor", "offset"],
- watch: {
- anchor(val) {
- this.originInstance.setAnchor(val);
- },
- offset(val) {
- this.originInstance.setOffset(val);
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, anchor, offset, $el } = this;
- const Control = function() {
- this.defaultAnchor = window[anchor || "BMAP_ANCHOR_TOP_LEFT"];
- this.defaultOffset = createSize(BMap2, offset);
- };
- Control.prototype = new BMap2.Control();
- Control.prototype.initialize = (map2) => map2.getContainer().appendChild($el);
- this.originInstance = new Control(anchor, offset);
- map.addControl(this.originInstance);
- }
- }
- };
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ]);
- }
- var BmControl = _export_sfc(_sfc_main$o, [["render", _sfc_render$d]]);
- var _sfc_main$n = {
- name: "bm-marker",
- mixins: [commonMixin("overlay")],
- inject: {
- Cluster: {
- default: () => ({})
- }
- },
- props: {
- position: {},
- offset: {},
- icon: {},
- massClear: {
- type: Boolean,
- default: true
- },
- dragging: {
- type: Boolean,
- default: false
- },
- clicking: {
- type: Boolean,
- default: true
- },
- raiseOnDrag: {
- type: Boolean,
- default: false
- },
- draggingCursor: {
- type: String
- },
- rotation: {
- type: Number
- },
- shadow: {
- type: Object
- },
- title: {
- type: String
- },
- label: {
- type: Object
- },
- animation: {
- type: String
- },
- top: {
- type: Boolean,
- default: false
- },
- zIndex: {
- type: Number,
- default: 0
- }
- },
- watch: {
- "position.lng"(val, oldVal) {
- const { BMap: BMap2, originInstance, position, renderByParent, $parent } = this;
- if (val !== oldVal && val >= -180 && val <= 180) {
- originInstance.setPosition(createPoint(BMap2, { lng: val, lat: position.lat }));
- }
- renderByParent && $parent.reload();
- },
- "position.lat"(val, oldVal) {
- const { BMap: BMap2, originInstance, position, renderByParent, $parent } = this;
- if (val !== oldVal && val >= -74 && val <= 74) {
- originInstance.setPosition(createPoint(BMap2, { lng: position.lng, lat: val }));
- }
- renderByParent && $parent.reload();
- },
- "offset.width"(val, oldVal) {
- const { BMap: BMap2, originInstance } = this;
- if (val !== oldVal) {
- originInstance.setOffset(new BMap2.Size(val, this.offset.height));
- }
- },
- "offset.height"(val, oldVal) {
- const { BMap: BMap2, originInstance } = this;
- if (val !== oldVal) {
- originInstance.setOffset(new BMap2.Size(this.offset.width, val));
- }
- },
- icon: {
- deep: true,
- handler(val) {
- const { BMap: BMap2, originInstance, rotation } = this;
- originInstance && originInstance.setIcon(createIcon(BMap2, val));
- rotation && originInstance && originInstance.setRotation(rotation);
- }
- },
- massClear(val) {
- val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
- },
- dragging(val) {
- val ? this.originInstance.enableDragging() : this.originInstance.disableDragging();
- },
- clicking() {
- this.reload();
- },
- raiseOnDrag() {
- this.reload();
- },
- draggingCursor(val) {
- this.originInstance.setDraggingCursor(val);
- },
- rotation(val) {
- this.originInstance.setRotation(val);
- },
- shadow(val) {
- this.originInstance.setShadow(val);
- },
- title(val) {
- this.originInstance.setTitle(val);
- },
- label(val) {
- this.reload();
- },
- animation(val) {
- this.originInstance.setAnimation(window[val]);
- },
- top(val) {
- this.originInstance.setTop(val);
- },
- zIndex(val) {
- this.originInstance.setZIndex(val);
- }
- },
- methods: {
- load() {
- var _a, _b;
- const { BMap: BMap2, map, position, offset, icon, massClear, dragging, clicking, raiseOnDrag, draggingCursor, rotation, shadow, title, label, animation, top, renderByParent, $parent, zIndex } = this;
- let makerOption = {
- offset,
- icon: icon && createIcon(BMap2, icon),
- enableMassClear: massClear,
- enableDragging: dragging,
- enableClicking: clicking,
- raiseOnDrag,
- draggingCursor,
- rotation,
- shadow,
- title
- };
- deleteEmptyKey(makerOption);
- const overlay = new BMap2.Marker(new BMap2.Point(position.lng, position.lat), makerOption);
- this.originInstance = overlay;
- label && overlay && overlay.setLabel(createLabel(BMap2, label));
- overlay.setTop(top);
- overlay.setZIndex(zIndex);
- bindEvents.call(this, overlay);
- if (renderByParent) {
- $parent.reload();
- } else {
- map.addOverlay(overlay);
- }
- overlay.setAnimation(window[animation]);
- (_b = (_a = this.Cluster) == null ? void 0 : _a.addMaker) == null ? void 0 : _b.call(_a, this);
- }
- },
- beforeUnmount() {
- var _a, _b;
- (_b = (_a = this.Cluster) == null ? void 0 : _a.removeMaker) == null ? void 0 : _b.call(_a, this);
- }
- };
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ]);
- }
- var BmMarker = _export_sfc(_sfc_main$n, [["render", _sfc_render$c]]);
- var _sfc_main$m = {
- render() {
- },
- name: "bm-point-collection",
- mixins: [commonMixin("overlay")],
- props: {
- points: {
- type: Array,
- default() {
- return [];
- }
- },
- shape: {
- type: String,
- default: "BMAP_POINT_SHAPE_CIRCLE"
- },
- color: {
- type: String
- },
- size: {
- type: String,
- default: "BMAP_POINT_SIZE_NORMAL"
- }
- },
- watch: {
- shape(val) {
- const { originInstance, color, size } = this;
- originInstance.setStyles({
- shape: window[val],
- color,
- size: window[size]
- });
- },
- size(val) {
- const { originInstance, color, shape } = this;
- originInstance.setStyles({
- shape: window[shape],
- color,
- size: window[val]
- });
- },
- color(val) {
- const { originInstance, shape, size } = this;
- originInstance.setStyles({
- shape: window[shape],
- color: val,
- size: window[size]
- });
- },
- points: {
- deep: true,
- handler(val) {
- const { originInstance } = this;
- originInstance.clear();
- originInstance.setPoints(val);
- }
- }
- },
- methods: {
- load() {
- },
- init({ BMap: BMap2, map }) {
- this.$emit("init", {
- BMap: BMap2,
- map
- });
- const { points, shape, color, size } = this;
- let pointCollectionOption = {
- shape: window[shape],
- color,
- size: window[size]
- };
- deleteEmptyKey(pointCollectionOption);
- const overlay = this.originInstance = new BMap2.PointCollection(points.map((p) => createPoint(BMap2, p)), pointCollectionOption);
- bindEvents.call(this, overlay);
- map.addOverlay(overlay);
- }
- }
- };
- var _sfc_main$l = {
- name: "bm-polyline",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- path: {
- type: Array
- },
- strokeColor: {
- type: String,
- default: "blue"
- },
- strokeWeight: {
- type: Number,
- default: 2
- },
- strokeOpacity: {
- type: Number,
- default: 0.5
- },
- strokeStyle: {
- type: String,
- default: "solid"
- },
- massClear: {
- type: Boolean,
- default: true
- },
- clicking: {
- type: Boolean,
- default: true
- },
- editing: {
- type: Boolean,
- default: false
- },
- icons: {
- type: Array,
- default() {
- return [];
- }
- }
- },
- watch: {
- path: {
- handler(val, oldVal) {
- this.reload();
- },
- deep: true
- },
- icons: {
- handler(val, oldVal) {
- this.reload();
- },
- deep: true
- },
- strokeColor(val) {
- this.originInstance.setStrokeColor(val);
- },
- strokeOpacity(val) {
- this.originInstance.setStrokeOpacity(val);
- },
- strokeWeight(val) {
- this.originInstance.setStrokeWeight(val);
- },
- strokeStyle(val) {
- this.originInstance.setStrokeStyle(val);
- },
- editing(val) {
- val ? this.originInstance.enableEditing() : this.originInstance.disableEditing();
- },
- massClear(val) {
- val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
- },
- clicking(val) {
- this.reload();
- }
- },
- computed: {
- iconSequences() {
- const { BMap: BMap2, icons } = this;
- return icons.map((item) => {
- return createIconSequence(BMap2, item);
- });
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking, iconSequences } = this;
- let polyLineOption = {
- strokeColor,
- strokeWeight,
- strokeOpacity,
- strokeStyle,
- enableEditing: editing,
- enableMassClear: massClear,
- enableClicking: clicking,
- icons: iconSequences
- };
- deleteEmptyKey(polyLineOption);
- const overlay = new BMap2.Polyline(path.map((item) => createPoint(BMap2, { lng: item.lng, lat: item.lat })), polyLineOption);
- this.originInstance = overlay;
- map.addOverlay(overlay);
- bindEvents.call(this, overlay);
- }
- }
- };
- var _sfc_main$k = {
- name: "bm-polygon",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- path: {
- type: Array,
- default() {
- return [];
- }
- },
- strokeColor: {
- type: String
- },
- strokeWeight: {
- type: Number
- },
- strokeOpacity: {
- type: Number
- },
- strokeStyle: {
- type: String
- },
- fillColor: {
- type: String
- },
- fillOpacity: {
- type: Number
- },
- massClear: {
- type: Boolean,
- default: true
- },
- clicking: {
- type: Boolean,
- default: true
- },
- editing: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- path: {
- handler(val, oldVal) {
- this.reload();
- },
- deep: true
- },
- strokeColor(val) {
- this.originInstance.setStrokeColor(val);
- },
- strokeOpacity(val) {
- this.originInstance.setStrokeOpacity(val);
- },
- strokeWeight(val) {
- this.originInstance.setStrokeWeight(val);
- },
- strokeStyle(val) {
- this.originInstance.setStrokeStyle(val);
- },
- fillColor(val) {
- this.originInstance.setFillColor(val);
- },
- fillOpacity(val) {
- this.originInstance.setFillOpacity(val);
- },
- editing(val) {
- val ? this.originInstance.enableEditing() : this.originInstance.disableEditing();
- },
- massClear(val) {
- val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
- },
- clicking(val) {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, fillColor, fillOpacity, editing, massClear, clicking } = this;
- let polygonOption = {
- strokeColor,
- strokeWeight,
- strokeOpacity,
- strokeStyle,
- fillColor,
- fillOpacity,
- enableMassClear: massClear,
- enableClicking: clicking
- };
- deleteEmptyKey(polygonOption);
- const overlay = new BMap2.Polygon(path.map((item) => createPoint(BMap2, { lng: item.lng, lat: item.lat })), polygonOption);
- this.originInstance = overlay;
- map.addOverlay(overlay);
- bindEvents.call(this, overlay);
- editing ? overlay.enableEditing() : overlay.disableEditing();
- }
- }
- };
- var _sfc_main$j = {
- name: "bm-circle",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- center: {},
- radius: {},
- strokeColor: {
- type: String
- },
- strokeWeight: {
- type: Number
- },
- strokeOpacity: {
- type: Number
- },
- strokeStyle: {
- type: String
- },
- fillColor: {
- type: String
- },
- fillOpacity: {
- type: Number
- },
- massClear: {
- type: Boolean,
- default: true
- },
- clicking: {
- type: Boolean,
- default: true
- },
- editing: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- "center.lng"(val, oldVal) {
- const { BMap: BMap2, originInstance, isEditing, disableEditing, enableEditing, center, editing } = this;
- if (!isEditing) {
- disableEditing();
- const lng = val;
- if (val.toString() !== oldVal.toString() && lng >= -180 && lng <= 180) {
- originInstance.setCenter(createPoint(BMap2, { lng, lat: center.lat }));
- }
- editing && enableEditing();
- }
- },
- "center.lat"(val, oldVal) {
- const { BMap: BMap2, originInstance, isEditing, disableEditing, enableEditing, center, editing } = this;
- if (!isEditing) {
- disableEditing();
- const lat = val;
- if (val.toString() !== oldVal.toString() && lat >= -74 && lat <= 74) {
- originInstance.setCenter(createPoint(BMap2, { lng: center.lng, lat }));
- }
- editing && enableEditing();
- }
- },
- radius(val, oldVal) {
- const { originInstance, isEditing, disableEditing, enableEditing, editing } = this;
- if (!isEditing) {
- disableEditing();
- originInstance.setRadius(val);
- editing && enableEditing();
- }
- },
- strokeColor(val) {
- this.originInstance.setStrokeColor(val);
- },
- strokeOpacity(val) {
- this.originInstance.setStrokeOpacity(val);
- },
- strokeWeight(val) {
- this.originInstance.setStrokeWeight(val);
- },
- strokeStyle(val) {
- this.originInstance.setStrokeStyle(val);
- },
- fillColor(val) {
- this.originInstance.setFillColor(val);
- },
- fillOpacity(val) {
- this.originInstance.setFillOpacity(val);
- },
- editing(val) {
- val ? this.enableEditing() : this.disableEditing();
- },
- massClear(val) {
- val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
- },
- clicking(val) {
- this.reload();
- }
- },
- methods: {
- dragStartHandler() {
- this.isEditing = true;
- },
- dragEndHandler() {
- this.isEditing = false;
- this.bindEditingNodeEvents();
- },
- bindEditingNodeEvents() {
- const { originInstance, editingKey, dragStartHandler, dragEndHandler } = this;
- if (originInstance[editingKey]) {
- originInstance[editingKey].forEach(($node) => {
- $node.addEventListener("dragstart", dragStartHandler);
- $node.addEventListener("dragend", dragEndHandler);
- });
- }
- },
- enableEditing() {
- const { originInstance, bindEditingNodeEvents } = this;
- originInstance.enableEditing();
- bindEditingNodeEvents();
- },
- disableEditing() {
- const { originInstance } = this;
- originInstance.disableEditing();
- },
- getEditingKey(overlay) {
- const stack = [];
- overlay.enableEditing();
- setTimeout(() => {
- for (const key in overlay) {
- if (overlay[key] && overlay[key].length === 2) {
- stack.push(key);
- }
- }
- overlay.disableEditing();
- for (const key in overlay) {
- if (overlay[key] && overlay[key].length === 0 && ~stack.indexOf(key)) {
- this.editingKey = key;
- }
- }
- }, 0);
- },
- load() {
- const { BMap: BMap2, map, center, radius, strokeColor, strokeWeight, strokeOpacity, strokeStyle, fillColor, fillOpacity, editing, massClear, clicking, enableEditing, disableEditing, getEditingKey, editingKey } = this;
- let overlayOption = {
- strokeColor,
- strokeWeight,
- strokeOpacity,
- strokeStyle,
- fillColor,
- fillOpacity,
- enableMassClear: massClear,
- enableClicking: clicking
- };
- deleteEmptyKey(overlayOption);
- const overlay = new BMap2.Circle(createPoint(BMap2, { lng: center.lng, lat: center.lat }), radius, overlayOption);
- this.originInstance = overlay;
- map.addOverlay(overlay);
- bindEvents.call(this, overlay);
- !editingKey && getEditingKey(overlay);
- setTimeout(() => {
- editing ? enableEditing() : disableEditing();
- }, 0);
- }
- }
- };
- var _sfc_main$i = {
- name: "bm-ground",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- bounds: {
- type: Object
- },
- opacity: {
- type: Number
- },
- imageURL: {
- type: String
- },
- displayOnMinLevel: {
- type: Number
- },
- displayOnMaxLevel: {
- type: Number
- }
- },
- watch: {
- bounds: {
- handler(val) {
- const { BMap: BMap2 } = this;
- this.originInstance.setBounds(createBounds(BMap2, val));
- },
- deep: true
- },
- opacity(val) {
- this.originInstance.setOpacity(val);
- },
- imageURL(val) {
- this.originInstance.setImageURL(val);
- },
- displayOnMinLevel(val) {
- this.originInstance.setDisplayOnMinLevel(val);
- },
- displayOnMaxLevel(val) {
- this.originInstance.setDisplayOnMaxLevel(val);
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, bounds, opacity, imageURL, displayOnMinLevel, displayOnMaxLevel } = this;
- let groundOption = {
- opacity,
- imageURL,
- displayOnMaxLevel,
- displayOnMinLevel
- };
- deleteEmptyKey(groundOption);
- const overlay = new BMap2.GroundOverlay(bounds && createBounds(BMap2, bounds), groundOption);
- overlay.setImageURL(imageURL);
- this.originInstance = overlay;
- bindEvents.call(this, overlay);
- map.addOverlay(overlay);
- }
- }
- };
- var _sfc_main$h = {
- name: "bm-label",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- content: {
- type: String
- },
- title: {
- type: String
- },
- offset: {},
- position: {},
- labelStyle: {},
- zIndex: {
- type: Number,
- default: 0
- },
- massClear: {
- type: Boolean,
- default: true
- }
- },
- watch: {
- content(val) {
- this.originInstance.setContent(val);
- },
- title(val) {
- this.originInstance.setTitle(val);
- },
- "offset.width"(val, oldVal) {
- const { BMap: BMap2 } = this;
- if (val.toString() !== oldVal.toString()) {
- this.originInstance.setOffset(createSize(BMap2, { width: val, height: this.offset.height }));
- }
- },
- "offset.height"(val, oldVal) {
- const { BMap: BMap2 } = this;
- if (val.toString() !== oldVal.toString()) {
- this.originInstance.setOffset(createSize(BMap2, {
- width: this.offset.width,
- height: val
- }));
- }
- },
- "position.lng"(val, oldVal) {
- const { BMap: BMap2 } = this;
- const lng = val;
- if (val.toString() !== oldVal.toString() && lng >= -180 && lng <= 180) {
- this.originInstance.setPosition(createPoint(BMap2, { lng, lat: this.position.lat }));
- }
- },
- "position.lat"(val, oldVal) {
- const { BMap: BMap2 } = this;
- const lat = val;
- if (val.toString() !== oldVal.toString() && lat >= -74 && lat <= 74) {
- this.originInstance.setPosition(createPoint(BMap2, { lng: this.position.lng, lat }));
- }
- },
- labelStyle: {
- handler(val) {
- this.originInstance.setStyle(val);
- },
- deep: true
- },
- zIndex(val) {
- this.originInstance.setZIndex(val);
- },
- massClear(val) {
- val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, content, title, offset, position, labelStyle, zIndex, massClear, $parent } = this;
- let labelOption = {
- offset: createSize(BMap2, offset),
- position: createPoint(BMap2, position),
- enableMassClear: massClear
- };
- deleteEmptyKey(labelOption);
- const overlay = new BMap2.Label(content, labelOption);
- this.originInstance = overlay;
- try {
- $parent.originInstance.setLabel(overlay);
- } catch (e) {
- map.addOverlay(overlay);
- }
- title && overlay.setTitle(title);
- labelStyle && overlay.setStyle(labelStyle);
- zIndex && overlay.setZIndex(zIndex);
- bindEvents.call(this, overlay);
- }
- }
- };
- var _sfc_main$g = {
- name: "bm-info-window",
- mixins: [commonMixin("overlay")],
- props: {
- show: {
- type: Boolean
- },
- position: {
- type: Object
- },
- title: {
- type: String
- },
- width: {
- type: Number
- },
- height: {
- type: Number
- },
- maxWidth: {
- type: Number
- },
- offset: {
- type: Object
- },
- maximize: {
- type: Boolean
- },
- autoPan: {
- type: Boolean
- },
- closeOnClick: {
- type: Boolean,
- default: true
- },
- message: {
- type: String
- }
- },
- watch: {
- show(val) {
- val ? this.openInfoWindow() : this.closeInfoWindow();
- },
- "position.lng"(val, oldVal) {
- this.reload();
- },
- "position.lat"(val, oldVal) {
- this.reload();
- },
- "offset.width"(val, oldVal) {
- this.reload();
- },
- "offset.height"(val) {
- this.reload();
- },
- maxWidth() {
- this.reload();
- },
- width(val) {
- this.originInstance.setWidth(val);
- },
- height(val) {
- this.originInstance.setHeight(val);
- },
- title(val) {
- this.originInstance.setTitle(val);
- },
- maximize(val) {
- val ? this.originInstance.enableMaximize() : this.originInstance.disableMaximize();
- },
- autoPan(val) {
- val ? this.originInstance.enableAutoPan() : this.originInstance.disableAutoPan();
- },
- closeOnClick(val) {
- val ? this.originInstance.enableCloseOnClick() : this.originInstance.disableCloseOnClick();
- }
- },
- methods: {
- redraw() {
- this.originInstance.redraw();
- },
- load() {
- const { BMap: BMap2, map, show, title, width, height, maxWidth, offset, autoPan, closeOnClick, message, maximize, bindObserver, $parent } = this;
- const $content = this.$el;
- let infoWindowOption = {
- width,
- height,
- title,
- maxWidth,
- offset: offset && createSize(BMap2, offset),
- enableAutoPan: autoPan,
- enableCloseOnClick: closeOnClick,
- enableMessage: typeof message === "undefined",
- message
- };
- deleteEmptyKey(infoWindowOption);
- const overlay = new BMap2.InfoWindow($content, infoWindowOption);
- maximize ? overlay.enableMaximize() : overlay.disableMaximize();
- bindEvents.call(this, overlay);
- this.originInstance = overlay;
- overlay.redraw();
- [].forEach.call($content.querySelectorAll("img"), ($img) => {
- $img.onload = () => overlay.redraw();
- });
- bindObserver();
- this.$container = $parent.originInstance && $parent.originInstance.openInfoWindow ? $parent.originInstance : map;
- show && this.openInfoWindow();
- },
- bindObserver() {
- const MutationObserver = window.MutationObserver;
- if (!MutationObserver) {
- return;
- }
- const { $el, originInstance } = this;
- this.observer = new MutationObserver((mutations) => originInstance.redraw());
- this.observer.observe($el, { attributes: true, childList: true, characterData: true, subtree: true });
- },
- openInfoWindow() {
- const { BMap: BMap2, $container, position, originInstance } = this;
- $container.openInfoWindow(originInstance, createPoint(BMap2, position || this.$parent.position));
- },
- closeInfoWindow() {
- this.$container.closeInfoWindow(this.originInstance);
- }
- }
- };
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
- return withDirectives((openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ], 512)), [
- [vShow, $props.show]
- ]);
- }
- var BmInfoWindow = _export_sfc(_sfc_main$g, [["render", _sfc_render$b]]);
- var _sfc_main$f = {
- name: "bm-overlay",
- emits: ["initialize", "draw"],
- mixins: [commonMixin("overlay")],
- props: {
- pane: {
- type: String
- }
- },
- watch: {
- pane() {
- this.reload();
- }
- },
- methods: {
- load() {
- },
- mountedLoad() {
- const { BMap: BMap2, map, $el, pane } = this;
- const $emit = this.$emit.bind(this);
- class CustomOverlay extends BMap2.Overlay {
- initialize() {
- $emit("initialize", {
- BMap: BMap2,
- map,
- el: $el,
- overlay: this
- });
- try {
- map.getPanes()[pane].appendChild($el);
- } catch (e) {
- }
- return $el;
- }
- draw() {
- $emit("draw", {
- BMap: BMap2,
- map,
- el: $el,
- overlay: this
- });
- }
- }
- const overlay = new CustomOverlay();
- this.originInstance = overlay;
- map.addOverlay(overlay);
- }
- }
- };
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ]);
- }
- var BmOverlay = _export_sfc(_sfc_main$f, [["render", _sfc_render$a]]);
- var _sfc_main$e = {
- name: "bm-context-menu",
- props: {
- width: {
- type: Number
- }
- },
- mixins: [commonMixin("contextMenu")],
- methods: {
- load() {
- const { width, BMap: BMap2, map, $parent } = this;
- const parent = this.parent = $parent.originInstance || map;
- if (this.originInstance) {
- parent.removeContextMenu(this.originInstance);
- }
- const menu = this.originInstance = new BMap2.ContextMenu();
- if (this.$slots.default) {
- for (const item of this.$slots.default() || []) {
- const props = item.props;
- if (props.seperator) {
- menu.addSeparator();
- continue;
- }
- const menuItem = new BMap2.MenuItem(props.text, function(point, pixel) {
- props.callback && props.callback({
- point,
- pixel,
- BMap: BMap2,
- map,
- target: parent
- });
- }, {
- width,
- id: props.id,
- iconUrl: props.iconUrl
- });
- props.disabled ? menuItem.disable() : menuItem.enable();
- props.originInstance = menuItem;
- menu.addItem(menuItem);
- }
- }
- parent.addContextMenu(menu);
- }
- }
- };
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ]);
- }
- var BmContextMenu = _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
- var _sfc_main$d = {
- name: "bm-context-menu-item",
- props: {
- callback: {
- type: Function,
- default: function() {
- }
- },
- text: {
- type: String
- },
- iconUrl: {
- type: String
- },
- id: {
- type: String
- },
- disabled: {
- type: Boolean
- },
- seperator: {
- type: Boolean
- },
- originInstance: {}
- },
- methods: {
- reload() {
- this.$parent.map && this.$parent.load();
- }
- },
- watch: {
- text() {
- this.reload();
- },
- iconUrl() {
- this.reload();
- },
- id() {
- this.reload();
- },
- disabled() {
- this.reload();
- },
- iseperator() {
- this.reload();
- },
- callback() {
- this.reload();
- }
- },
- destroyed() {
- this.reload();
- },
- mounted() {
- this.reload();
- }
- };
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("span", null, [
- renderSlot(_ctx.$slots, "default")
- ]);
- }
- var BmContextMenuItem = _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
- var _sfc_main$c = {
- name: "bm-local-search",
- emits: ["markersset", "infohtmlset", "resultshtmlset", "searchcomplete"],
- mixins: [commonMixin("search")],
- props: {
- location: {
- type: [Object, String]
- },
- keyword: {
- type: [Array, String]
- },
- panel: {
- type: Boolean,
- default: true
- },
- forceLocal: {
- type: Boolean
- },
- customData: {
- type: Object
- },
- bounds: {
- type: Object
- },
- nearby: {
- type: Object
- },
- pageCapacity: {
- type: Number
- },
- autoViewport: {
- type: Boolean
- },
- selectFirstResult: {
- type: Boolean
- }
- },
- watch: {
- location: {
- handler(val) {
- const { originInstance, search } = this;
- originInstance.setLocation(val || this.map);
- search();
- },
- deep: true
- },
- keyword() {
- this.search();
- },
- bounds: {
- handler(val) {
- const { searchInBounds } = this;
- searchInBounds(val);
- },
- deep: true
- },
- nearby: {
- handler(val) {
- const { searchNearby } = this;
- searchNearby(val);
- },
- deep: true
- },
- forceLocal() {
- this.reload();
- },
- customData: {
- deep: true,
- handler() {
- this.reload();
- }
- },
- pageCapacity(val) {
- this.originInstance && this.originInstance.setPageCapacity(val);
- },
- autoViewport(val) {
- this.originInstance && (val ? this.originInstance.enableAutoViewport() : this.originInstance.disableAutoViewport());
- },
- selectFirstResult(val) {
- this.originInstance && (val ? this.originInstance.enableFirstResultSelection() : this.originInstance.disableFirstResultSelection());
- },
- highlightMode() {
- this.reload();
- }
- },
- methods: {
- searchNearby(nearby) {
- const { originInstance, keyword, customData, BMap: BMap2 } = this;
- originInstance.searchNearby(keyword, createPoint(BMap2, nearby.center), nearby.radius, customData);
- },
- searchInBounds(bounds) {
- const { originInstance, keyword, customData, BMap: BMap2 } = this;
- originInstance.searchInBounds(keyword, createBounds(BMap2, bounds), customData);
- },
- search() {
- const { originInstance, keyword, forceLocal, customData, nearby, bounds, searchNearby, searchInBounds } = this;
- nearby ? searchNearby(nearby) : bounds ? searchInBounds(bounds) : originInstance.search(keyword, {
- forceLocal,
- customData
- });
- },
- load() {
- const instance2 = this;
- const { map, BMap: BMap2, search, pageCapacity, autoViewport, selectFirstResult, highlightMode, location, originInstance } = this;
- const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
- const route = this.originInstance = new BMap2.LocalSearch(_location, {
- onMarkersSet(e) {
- instance2.$emit("markersset", e);
- },
- onInfoHtmlSet(e) {
- instance2.$emit("infohtmlset", e);
- },
- onResultsHtmlSet(e) {
- instance2.$emit("resultshtmlset", e);
- },
- onSearchComplete(e) {
- if (originInstance && originInstance !== route) {
- originInstance.clearResults();
- }
- instance2.$emit("searchcomplete", e);
- },
- pageCapacity,
- renderOptions: {
- map,
- panel: this.$el,
- selectFirstResult,
- autoViewport,
- highlightMode
- }
- });
- search();
- }
- }
- };
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
- return withDirectives((openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ], 512)), [
- [vShow, $props.panel]
- ]);
- }
- var BmLocalSearch = _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
- var _sfc_main$b = {
- name: "bm-transit",
- emits: ["searchcomplete", "markersset", "infohtmlset", "polylinesset", "resultshtmlset"],
- mixins: [commonMixin("search")],
- props: {
- location: {
- type: [Object, String]
- },
- start: {
- type: [Object, String]
- },
- end: {
- type: [Object, String]
- },
- panel: {
- type: Boolean,
- default: true
- },
- policy: {
- type: String
- },
- pageCapacity: {
- type: Number
- },
- autoViewport: {
- type: Boolean
- },
- selectFirstResult: {
- type: Boolean
- }
- },
- watch: {
- location: {
- handler(val) {
- const { originInstance, map } = this;
- originInstance.setLocation(val || map);
- },
- deep: true
- },
- start: {
- handler(val) {
- const { originInstance, end, BMap: BMap2 } = this;
- originInstance.search(getPosition(BMap2, val), getPosition(BMap2, end));
- },
- deep: true
- },
- end: {
- handler(val) {
- const { originInstance, start, BMap: BMap2 } = this;
- originInstance.search(getPosition(BMap2, start), getPosition(BMap2, val));
- },
- deep: true
- },
- panel() {
- this.reload();
- },
- policy(val) {
- this.originInstance.setPolicy(window[val]);
- },
- pageCapacity(val) {
- this.originInstance && this.originInstance.setPageCapacity(val);
- },
- autoViewport(val) {
- this.originInstance && (val ? this.originInstance.enableAutoViewport() : this.originInstance.disableAutoViewport());
- },
- selectFirstResult() {
- this.reload();
- },
- highlightMode() {
- this.reload();
- }
- },
- methods: {
- search(start, end) {
- const { originInstance } = this;
- originInstance.search(start, end);
- },
- load() {
- const instance2 = this;
- const { map, BMap: BMap2, location, policy, pageCapacity, selectFirstResult, autoViewport, highlightMode, search, start, end, originInstance } = this;
- const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
- const route = this.originInstance = new BMap2.TransitRoute(_location, {
- renderOptions: {
- map,
- panel: this.$el,
- selectFirstResult,
- autoViewport,
- highlightMode
- },
- policy: window[policy],
- pageCapacity,
- onSearchComplete(e) {
- if (originInstance && originInstance !== route) {
- originInstance.clearResults();
- }
- instance2.$emit("searchcomplete", e);
- },
- onMarkersSet(e) {
- instance2.$emit("markersset", e);
- },
- onInfoHtmlSet(e) {
- instance2.$emit("infohtmlset", e);
- },
- onPolylinesSet(e) {
- instance2.$emit("polylinesset", e);
- },
- onResultsHtmlSet(e) {
- instance2.$emit("resultshtmlset", e);
- }
- });
- search(isPoint(start) ? createPoint(BMap2, start) : start, isPoint(end) ? createPoint(BMap2, end) : end);
- }
- }
- };
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
- return withDirectives((openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ], 512)), [
- [vShow, $props.panel]
- ]);
- }
- var BmTransit = _export_sfc(_sfc_main$b, [["render", _sfc_render$6]]);
- var _sfc_main$a = {
- name: "bm-walking",
- emits: ["searchcomplete", "markersset", "infohtmlset", "polylinesset", "resultshtmlset"],
- mixins: [commonMixin("search")],
- props: {
- location: {
- type: [Object, String]
- },
- start: {
- type: [Object, String]
- },
- end: {
- type: [Object, String]
- },
- panel: {
- type: Boolean,
- default: true
- },
- pageCapacity: {
- type: Number
- },
- autoViewport: {
- type: Boolean
- },
- selectFirstResult: {
- type: Boolean
- }
- },
- watch: {
- location: {
- handler(val) {
- const { originInstance, map } = this;
- originInstance.setLocation(val || map);
- },
- deep: true
- },
- start: {
- handler(val) {
- const { originInstance, end, BMap: BMap2 } = this;
- originInstance.search(getPosition(BMap2, val), getPosition(BMap2, end));
- },
- deep: true
- },
- end: {
- handler(val) {
- const { originInstance, start, BMap: BMap2 } = this;
- originInstance.search(getPosition(BMap2, start), getPosition(BMap2, val));
- },
- deep: true
- },
- panel() {
- this.reload();
- },
- autoViewport(val) {
- this.reload();
- },
- selectFirstResult(val) {
- this.reload();
- },
- highlightMode() {
- this.reload();
- }
- },
- methods: {
- search(start, end) {
- const { originInstance } = this;
- originInstance.search(start, end);
- },
- load() {
- const instance2 = this;
- const { map, BMap: BMap2, location, selectFirstResult, autoViewport, highlightMode, search, start, end, originInstance } = this;
- const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
- const route = this.originInstance = new BMap2.WalkingRoute(_location, {
- renderOptions: {
- map,
- panel: this.$el,
- selectFirstResult,
- autoViewport,
- highlightMode
- },
- onSearchComplete(e) {
- if (originInstance && originInstance !== route) {
- originInstance.clearResults();
- }
- instance2.$emit("searchcomplete", e);
- },
- onMarkersSet(e) {
- instance2.$emit("markersset", e);
- },
- onInfoHtmlSet(e) {
- instance2.$emit("infohtmlset", e);
- },
- onPolylinesSet(e) {
- instance2.$emit("polylinesset", e);
- },
- onResultsHtmlSet(e) {
- instance2.$emit("resultshtmlset", e);
- }
- });
- search(isPoint(start) ? createPoint(BMap2, start) : start, isPoint(end) ? createPoint(BMap2, end) : end);
- }
- }
- };
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
- return withDirectives((openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ], 512)), [
- [vShow, $props.panel]
- ]);
- }
- var BmWalking = _export_sfc(_sfc_main$a, [["render", _sfc_render$5]]);
- var _sfc_main$9 = {
- name: "bm-driving",
- emits: ["searchcomplete", "markersset", "infohtmlset", "polylinesset", "resultshtmlset"],
- mixins: [commonMixin("search")],
- props: {
- location: {
- type: [Object, String]
- },
- start: {
- type: [Object, String]
- },
- end: {
- type: [Object, String]
- },
- startCity: {
- type: [String, Number]
- },
- endCity: {
- type: [String, Number]
- },
- waypoints: {
- type: Array
- },
- policy: {
- type: String
- },
- panel: {
- type: Boolean,
- default: true
- },
- autoViewport: {
- type: Boolean
- },
- selectFirstResult: {
- type: Boolean
- }
- },
- watch: {
- location: {
- handler(val) {
- const { originInstance, map } = this;
- originInstance.setLocation(val || map);
- },
- deep: true
- },
- start: {
- handler(val) {
- const { originInstance, end, startCity, endCity, waypoints, BMap: BMap2, getWaypoints } = this;
- originInstance.search(getPosition(BMap2, val), getPosition(BMap2, end), {
- startCity,
- endCity,
- waypoints: getWaypoints(waypoints)
- });
- },
- deep: true
- },
- end: {
- handler(val) {
- const { originInstance, start, startCity, endCity, waypoints, BMap: BMap2, getWaypoints } = this;
- originInstance.search(getPosition(BMap2, start), getPosition(BMap2, val), {
- startCity,
- endCity,
- waypoints: getWaypoints(waypoints)
- });
- },
- deep: true
- },
- startCity(val) {
- const { originInstance, start, end, endCity, waypoints, getWaypoints } = this;
- originInstance.search(start, end, {
- val,
- endCity,
- waypoints: getWaypoints(waypoints)
- });
- },
- endCity(val) {
- const { originInstance, start, end, startCity, waypoints, getWaypoints } = this;
- originInstance.search(start, end, {
- startCity,
- val,
- waypoints: getWaypoints(waypoints)
- });
- },
- waypoints: {
- handler(val) {
- const { originInstance, start, end, startCity, endCity, getWaypoints } = this;
- originInstance.search(start, end, {
- startCity,
- endCity,
- waypoints: getWaypoints(val)
- });
- },
- deep: true
- },
- panel() {
- this.reload();
- },
- policy(val) {
- this.reload();
- },
- autoViewport() {
- this.reload();
- },
- selectFirstResult() {
- this.reload();
- },
- highlightMode() {
- this.reload();
- }
- },
- methods: {
- search(start, end, { startCity, endCity, waypoints }) {
- const { originInstance, getWaypoints } = this;
- originInstance.search(start, end, {
- startCity,
- endCity,
- waypoints: getWaypoints(waypoints)
- });
- },
- getWaypoints(waypoints) {
- const { BMap: BMap2 } = this;
- if (waypoints) {
- return waypoints.map((position) => getPosition(BMap2, position));
- }
- },
- load() {
- const instance2 = this;
- const { map, BMap: BMap2, location, policy, selectFirstResult, autoViewport, highlightMode, search, start, end, startCity, endCity, waypoints, originInstance, getWaypoints } = this;
- const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
- const route = this.originInstance = new BMap2.DrivingRoute(_location, {
- renderOptions: {
- map,
- panel: this.$el,
- selectFirstResult,
- autoViewport,
- highlightMode
- },
- policy: window[policy],
- onSearchComplete(e) {
- if (originInstance && originInstance !== route) {
- originInstance.clearResults();
- }
- instance2.$emit("searchcomplete", e);
- },
- onMarkersSet(e) {
- instance2.$emit("markersset", e);
- },
- onInfoHtmlSet(e) {
- instance2.$emit("infohtmlset", e);
- },
- onPolylinesSet(e) {
- instance2.$emit("polylinesset", e);
- },
- onResultsHtmlSet(e) {
- instance2.$emit("resultshtmlset", e);
- }
- });
- search(getPosition(BMap2, start), getPosition(BMap2, end), {
- startCity,
- endCity,
- waypoints: getWaypoints(waypoints)
- });
- }
- }
- };
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
- return withDirectives((openBlock(), createElementBlock("div", null, [
- renderSlot(_ctx.$slots, "default")
- ], 512)), [
- [vShow, $props.panel]
- ]);
- }
- var BmDriving = _export_sfc(_sfc_main$9, [["render", _sfc_render$4]]);
- var _sfc_main$8 = {
- name: "bm-bus",
- emits: ["getbuslistcomplete", "getbuslinecomplete", "buslisthtmlset", "buslinehtmlset", "markersset", "polylinesset"],
- mixins: [commonMixin("search")],
- props: {
- location: {
- type: [Object, String]
- },
- keyword: {
- type: String
- },
- panel: {
- type: Boolean,
- default: true
- },
- pageCapacity: {
- type: Number
- },
- autoViewport: {
- type: Boolean
- },
- selectFirstResult: {
- type: Boolean
- }
- },
- watch: {
- location: {
- handler(val) {
- const { originInstance, map } = this;
- originInstance.setLocation(val || map);
- },
- deep: true
- },
- keyword(val) {
- this.search(val);
- },
- panel() {
- this.reload();
- },
- autoViewport(val) {
- this.reload();
- },
- selectFirstResult(val) {
- this.reload();
- }
- },
- methods: {
- search(keyword) {
- const { originInstance } = this;
- originInstance.getBusList(keyword);
- },
- load() {
- const instance2 = this;
- const { location, selectFirstResult, autoViewport, highlightMode, keyword, search, BMap: BMap2, map, originInstance } = this;
- const _location = location ? isPoint(location) ? createPoint(BMap2, location) : location : map;
- const route = this.originInstance = new BMap2.BusLineSearch(_location, {
- renderOptions: {
- map,
- panel: this.$el,
- selectFirstResult,
- autoViewport,
- highlightMode
- },
- onGetBusListComplete(e) {
- if (originInstance && originInstance !== route) {
- originInstance.clearResults();
- }
- instance2.$emit("getbuslistcomplete", e);
- },
- onGetBusLineComplete(e) {
- if (originInstance && originInstance !== route) {
- originInstance.clearResults();
- }
- instance2.$emit("getbuslinecomplete", e);
- },
- onBusListHtmlSet(e) {
- instance2.$emit("buslisthtmlset", e);
- },
- onBusLineHtmlSet(e) {
- instance2.$emit("buslinehtmlset", e);
- },
- onMarkersSet(e) {
- instance2.$emit("markersset", e);
- },
- onPolylinesSet(e) {
- instance2.$emit("polylinesset", e);
- }
- });
- search(keyword);
- }
- }
- };
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
- return withDirectives((openBlock(), createElementBlock("div", null, null, 512)), [
- [vShow, $props.panel]
- ]);
- }
- var BmBus = _export_sfc(_sfc_main$8, [["render", _sfc_render$3]]);
- var _sfc_main$7 = {
- name: "bm-tile",
- render(h) {
- },
- mixins: [commonMixin("layer")],
- props: {
- transparentPng: {
- type: Boolean
- },
- tileUrlTemplate: {
- type: String
- },
- copyright: {},
- zIndex: {
- type: Number
- }
- },
- watch: {
- transparentPng() {
- this.reload();
- },
- tileUrlTemplate() {
- this.reload();
- },
- copyright() {
- this.reload();
- },
- zIndex() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, transparentPng, tileUrlTemplate, copyright, zIndex } = this;
- this.originInstance = new BMap2.TileLayer({
- transparentPng,
- tileUrlTemplate,
- copyright: copyright && {
- id: copyright.id,
- content: copyright.content,
- bounds: copyright.bounds && createBounds(copyright.bounds)
- },
- zIndex
- });
- map.addTileLayer(this.originInstance);
- }
- }
- };
- var _sfc_main$6 = {
- name: "bm-triffic",
- render(h) {
- },
- mixins: [commonMixin("layer")],
- props: {
- predictDate: {
- type: Object
- }
- },
- watch: {
- "pridictDate.weekday"() {
- this.reload();
- },
- "pridictDate.hour"() {
- this.reload();
- },
- pridictDate() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { pridictDate, BMap: BMap2, map } = this;
- this.originInstance = new BMap2.TrafficLayer({
- pridictDate
- });
- map.addTileLayer(this.originInstance);
- }
- }
- };
- var _sfc_main$5 = {
- mixins: [
- commonMixin("abstract")
- ],
- emits: ["click", "dblclick", "mousedown", "mouseup", "mouseout", "mouseover", "remove", "load"],
- props: ["name", "strokeColor", "strokeWeight", "strokeOpacity", "strokeStyle", "fillColor", "fillOpacity", "massClear", "clicking"],
- data() {
- return {
- paths: []
- };
- },
- components: {
- BmPolygon: _sfc_main$k
- },
- watch: {
- name() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, name } = this;
- const bd = new BMap2.Boundary();
- bd.get(name, (data) => {
- const paths = data.boundaries.map((boundary) => (boundary || []).split(";").map((point) => (([lng, lat]) => ({ lng, lat }))(point.split(",").map((p) => +p))));
- this.paths = paths;
- this.$emit("load", { boundaries: data.boundaries, paths: [...paths] });
- });
- }
- }
- };
- var _hoisted_1$1 = { key: 0 };
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
- const _component_bm_polygon = resolveComponent("bm-polygon");
- return $data.paths.length ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
- (openBlock(true), createElementBlock(Fragment, null, renderList($data.paths, (path, index2) => {
- return openBlock(), createBlock(_component_bm_polygon, {
- key: index2,
- path,
- "stroke-color": $props.strokeColor,
- "stroke-weight": $props.strokeWeight,
- "stroke-opacity": $props.strokeOpacity,
- "stroke-style": $props.strokeStyle,
- "fill-opacity": $props.fillOpacity,
- "fill-color": $props.fillColor,
- "mass-clear": $props.massClear,
- clicking: $props.clicking,
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click", $event)),
- onDblclick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("dblclick", $event)),
- onMousedown: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("mousedown", $event)),
- onMouseup: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("mouseup", $event)),
- onMouseout: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("mouseout", $event)),
- onMouseover: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("mouseover", $event)),
- onRemove: _cache[6] || (_cache[6] = ($event) => _ctx.$emit("remove", $event))
- }, null, 8, ["path", "stroke-color", "stroke-weight", "stroke-opacity", "stroke-style", "fill-opacity", "fill-color", "mass-clear", "clicking"]);
- }), 128))
- ])) : createCommentVNode("", true);
- }
- var BmBoundary = _export_sfc(_sfc_main$5, [["render", _sfc_render$2]]);
- var _sfc_main$4 = {
- name: "bm-autocomplete",
- mixins: [commonMixin("autoComplete")],
- emits: ["update:modelValue", "searchcomplete"],
- props: {
- types: {
- type: String
- },
- location: {
- type: String
- },
- sugStyle: {
- type: Object,
- default() {
- return {};
- }
- },
- modelValue: {}
- },
- watch: {
- types() {
- this.reload();
- },
- location() {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, $el, types: types2, location, sugStyle } = this;
- const input = $el.querySelector("input");
- if (!input) {
- return;
- }
- this.originInstance = new BMap2.Autocomplete({
- input,
- types: types2,
- location: location || map,
- onSearchComplete: (e) => {
- const $sugs = document.querySelectorAll(".tangram-suggestion-main");
- for (const $sug of $sugs) {
- for (const name in sugStyle) {
- $sug.style[name] = sugStyle[name].toString();
- }
- }
- this.$emit("searchcomplete", e);
- }
- });
- this.originInstance.addEventListener("onconfirm", (e) => {
- const val = e.item.value;
- this.$emit("update:modelValue", val.province + val.city + val.district + val.street + val.business);
- });
- bindEvents.call(this, this.originInstance);
- }
- }
- };
- var _hoisted_1 = createBaseVNode("input", null, null, -1);
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("span", null, [
- renderSlot(_ctx.$slots, "default", {}, () => [
- _hoisted_1
- ])
- ]);
- }
- var BmAutoComplete = _export_sfc(_sfc_main$4, [["render", _sfc_render$1]]);
- var bmaplib_markerclusterer = { exports: {} };
- (function(module, exports) {
- (function(global2, factory) {
- module.exports = factory();
- })(commonjsGlobal, function() {
- var __commonjs_global = typeof window !== "undefined" ? window : typeof commonjsGlobal !== "undefined" ? commonjsGlobal : this;
- function __commonjs(fn, module2) {
- return module2 = { exports: {} }, fn(module2, module2.exports, __commonjs_global), module2.exports;
- }
- var index$1 = __commonjs(function(module2, exports2, global2) {
- (function(root, factory) {
- if (typeof exports2 === "object") {
- module2.exports = factory();
- } else {
- root.BMapLib = root.BMapLib || {};
- root.BMapLib.TextIconOverlay = root.BMapLib.TextIconOverlay || factory();
- }
- })(__commonjs_global, function() {
- var T, baidu = T = baidu || { version: "1.3.8" };
- var context = {};
- baidu.guid = "$BAIDU$";
- context[baidu.guid] = context[baidu.guid] || {};
- baidu.dom = baidu.dom || {};
- baidu.dom.g = function(id) {
- if (typeof id == "string" || id instanceof String) {
- return document.getElementById(id);
- } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) {
- return id;
- }
- return null;
- };
- baidu.g = baidu.G = baidu.dom.g;
- baidu.dom.getDocument = function(element) {
- element = baidu.dom.g(element);
- return element.nodeType == 9 ? element : element.ownerDocument || element.document;
- };
- baidu.lang = baidu.lang || {};
- baidu.lang.isString = function(source) {
- return Object.prototype.toString.call(source) == "[object String]";
- };
- baidu.isString = baidu.lang.isString;
- baidu.dom._g = function(id) {
- if (baidu.lang.isString(id)) {
- return document.getElementById(id);
- }
- return id;
- };
- baidu._g = baidu.dom._g;
- baidu.browser = baidu.browser || {};
- if (/msie (\d+\.\d)/i.test(navigator.userAgent)) {
- baidu.browser.ie = baidu.ie = document.documentMode || +RegExp["$1"];
- }
- baidu.dom.getComputedStyle = function(element, key) {
- element = baidu.dom._g(element);
- var doc = baidu.dom.getDocument(element), styles;
- if (doc.defaultView && doc.defaultView.getComputedStyle) {
- styles = doc.defaultView.getComputedStyle(element, null);
- if (styles) {
- return styles[key] || styles.getPropertyValue(key);
- }
- }
- return "";
- };
- baidu.dom._styleFixer = baidu.dom._styleFixer || {};
- baidu.dom._styleFilter = baidu.dom._styleFilter || [];
- baidu.dom._styleFilter.filter = function(key, value, method) {
- for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) {
- if (filter = filter[method]) {
- value = filter(key, value);
- }
- }
- return value;
- };
- baidu.string = baidu.string || {};
- baidu.string.toCamelCase = function(source) {
- if (source.indexOf("-") < 0 && source.indexOf("_") < 0) {
- return source;
- }
- return source.replace(/[-_][^-_]/g, function(match) {
- return match.charAt(1).toUpperCase();
- });
- };
- baidu.dom.getStyle = function(element, key) {
- var dom = baidu.dom;
- element = dom.g(element);
- key = baidu.string.toCamelCase(key);
- var value = element.style[key] || (element.currentStyle ? element.currentStyle[key] : "") || dom.getComputedStyle(element, key);
- if (!value) {
- var fixer = dom._styleFixer[key];
- if (fixer) {
- value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer);
- }
- }
- if (fixer = dom._styleFilter) {
- value = fixer.filter(key, value, "get");
- }
- return value;
- };
- baidu.getStyle = baidu.dom.getStyle;
- if (/opera\/(\d+\.\d)/i.test(navigator.userAgent)) {
- baidu.browser.opera = +RegExp["$1"];
- }
- baidu.browser.isWebkit = /webkit/i.test(navigator.userAgent);
- baidu.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent);
- baidu.browser.isStrict = document.compatMode == "CSS1Compat";
- baidu.dom.getPosition = function(element) {
- element = baidu.dom.g(element);
- var doc = baidu.dom.getDocument(element), browser = baidu.browser, getStyle = baidu.dom.getStyle;
- browser.isGecko > 0 && doc.getBoxObjectFor && getStyle(element, "position") == "absolute" && (element.style.top === "" || element.style.left === "");
- var pos = { "left": 0, "top": 0 }, viewport = browser.ie && !browser.isStrict ? doc.body : doc.documentElement, parent, box;
- if (element == viewport) {
- return pos;
- }
- if (element.getBoundingClientRect) {
- box = element.getBoundingClientRect();
- pos.left = Math.floor(box.left) + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
- pos.top = Math.floor(box.top) + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
- pos.left -= doc.documentElement.clientLeft;
- pos.top -= doc.documentElement.clientTop;
- var htmlDom = doc.body, htmlBorderLeftWidth = parseInt(getStyle(htmlDom, "borderLeftWidth")), htmlBorderTopWidth = parseInt(getStyle(htmlDom, "borderTopWidth"));
- if (browser.ie && !browser.isStrict) {
- pos.left -= isNaN(htmlBorderLeftWidth) ? 2 : htmlBorderLeftWidth;
- pos.top -= isNaN(htmlBorderTopWidth) ? 2 : htmlBorderTopWidth;
- }
- } else {
- parent = element;
- do {
- pos.left += parent.offsetLeft;
- pos.top += parent.offsetTop;
- if (browser.isWebkit > 0 && getStyle(parent, "position") == "fixed") {
- pos.left += doc.body.scrollLeft;
- pos.top += doc.body.scrollTop;
- break;
- }
- parent = parent.offsetParent;
- } while (parent && parent != element);
- if (browser.opera > 0 || browser.isWebkit > 0 && getStyle(element, "position") == "absolute") {
- pos.top -= doc.body.offsetTop;
- }
- parent = element.offsetParent;
- while (parent && parent != doc.body) {
- pos.left -= parent.scrollLeft;
- if (!browser.opera || parent.tagName != "TR") {
- pos.top -= parent.scrollTop;
- }
- parent = parent.offsetParent;
- }
- }
- return pos;
- };
- baidu.event = baidu.event || {};
- baidu.event._listeners = baidu.event._listeners || [];
- baidu.event.on = function(element, type, listener) {
- type = type.replace(/^on/i, "");
- element = baidu.dom._g(element);
- var realListener = function(ev) {
- listener.call(element, ev);
- }, lis = baidu.event._listeners, filter = baidu.event._eventFilter, afterFilter, realType = type;
- type = type.toLowerCase();
- if (filter && filter[type]) {
- afterFilter = filter[type](element, type, realListener);
- realType = afterFilter.type;
- realListener = afterFilter.listener;
- }
- if (element.addEventListener) {
- element.addEventListener(realType, realListener, false);
- } else if (element.attachEvent) {
- element.attachEvent("on" + realType, realListener);
- }
- lis[lis.length] = [element, type, listener, realListener, realType];
- return element;
- };
- baidu.on = baidu.event.on;
- (function() {
- var guid = context[baidu.guid];
- baidu.lang.guid = function() {
- return "TANGRAM__" + (guid._counter++).toString(36);
- };
- guid._counter = guid._counter || 1;
- })();
- context[baidu.guid]._instances = context[baidu.guid]._instances || {};
- baidu.lang.isFunction = function(source) {
- return Object.prototype.toString.call(source) == "[object Function]";
- };
- baidu.lang.Class = function(guid) {
- this.guid = guid || baidu.lang.guid();
- context[baidu.guid]._instances[this.guid] = this;
- };
- context[baidu.guid]._instances = context[baidu.guid]._instances || {};
- baidu.lang.Class.prototype.dispose = function() {
- delete context[baidu.guid]._instances[this.guid];
- for (var property in this) {
- if (!baidu.lang.isFunction(this[property])) {
- delete this[property];
- }
- }
- this.disposed = true;
- };
- baidu.lang.Class.prototype.toString = function() {
- return "[object " + (this._className || "Object") + "]";
- };
- baidu.lang.Event = function(type, target) {
- this.type = type;
- this.returnValue = true;
- this.target = target || null;
- this.currentTarget = null;
- };
- baidu.lang.Class.prototype.addEventListener = function(type, handler, key) {
- if (!baidu.lang.isFunction(handler)) {
- return;
- }
- !this.__listeners && (this.__listeners = {});
- var t = this.__listeners, id;
- if (typeof key == "string" && key) {
- if (/[^\w\-]/.test(key)) {
- throw "nonstandard key:" + key;
- } else {
- handler.hashCode = key;
- id = key;
- }
- }
- type.indexOf("on") != 0 && (type = "on" + type);
- typeof t[type] != "object" && (t[type] = {});
- id = id || baidu.lang.guid();
- handler.hashCode = id;
- t[type][id] = handler;
- };
- baidu.lang.Class.prototype.removeEventListener = function(type, handler) {
- if (typeof handler != "undefined") {
- if (baidu.lang.isFunction(handler) && !(handler = handler.hashCode) || !baidu.lang.isString(handler)) {
- return;
- }
- }
- !this.__listeners && (this.__listeners = {});
- type.indexOf("on") != 0 && (type = "on" + type);
- var t = this.__listeners;
- if (!t[type]) {
- return;
- }
- if (typeof handler != "undefined") {
- t[type][handler] && delete t[type][handler];
- } else {
- for (var guid in t[type]) {
- delete t[type][guid];
- }
- }
- };
- baidu.lang.Class.prototype.dispatchEvent = function(event, options) {
- if (baidu.lang.isString(event)) {
- event = new baidu.lang.Event(event);
- }
- !this.__listeners && (this.__listeners = {});
- options = options || {};
- for (var i in options) {
- event[i] = options[i];
- }
- var i, t = this.__listeners, p = event.type;
- event.target = event.target || this;
- event.currentTarget = this;
- p.indexOf("on") != 0 && (p = "on" + p);
- baidu.lang.isFunction(this[p]) && this[p].apply(this, arguments);
- if (typeof t[p] == "object") {
- for (i in t[p]) {
- t[p][i].apply(this, arguments);
- }
- }
- return event.returnValue;
- };
- baidu.lang.inherits = function(subClass, superClass, className) {
- var key, proto, selfProps = subClass.prototype, clazz = new Function();
- clazz.prototype = superClass.prototype;
- proto = subClass.prototype = new clazz();
- for (key in selfProps) {
- proto[key] = selfProps[key];
- }
- subClass.prototype.constructor = subClass;
- subClass.superClass = superClass.prototype;
- if (typeof className == "string") {
- proto._className = className;
- }
- };
- baidu.inherits = baidu.lang.inherits;
- var _IMAGE_PATH = "http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m";
- var _IMAGE_EXTENSION = "png";
- var TextIconOverlay2 = function(position, text, options) {
- try {
- BMap;
- } catch (e) {
- throw Error("Baidu Map JS API is not ready yet!");
- }
- T.lang.inherits(TextIconOverlay2, BMap.Overlay, "TextIconOverlay");
- this._position = position;
- this._text = text;
- this._options = options || {};
- this._styles = this._options["styles"] || [];
- !this._styles.length && this._setupDefaultStyles();
- };
- TextIconOverlay2.prototype._setupDefaultStyles = function() {
- var sizes = [53, 56, 66, 78, 90];
- for (var i = 0, size; size = sizes[i]; i++) {
- this._styles.push({
- url: _IMAGE_PATH + i + "." + _IMAGE_EXTENSION,
- size: new BMap.Size(size, size)
- });
- }
- };
- TextIconOverlay2.prototype.initialize = function(map) {
- this._map = map;
- this._domElement = document.createElement("div");
- this._updateCss();
- this._updateText();
- this._updatePosition();
- this._bind();
- this._map.getPanes().markerMouseTarget.appendChild(this._domElement);
- return this._domElement;
- };
- TextIconOverlay2.prototype.draw = function() {
- this._map && this._updatePosition();
- };
- TextIconOverlay2.prototype.getText = function() {
- return this._text;
- };
- TextIconOverlay2.prototype.setText = function(text) {
- if (text && (!this._text || this._text.toString() != text.toString())) {
- this._text = text;
- this._updateText();
- this._updateCss();
- this._updatePosition();
- }
- };
- TextIconOverlay2.prototype.getPosition = function() {
- return this._position;
- };
- TextIconOverlay2.prototype.setPosition = function(position) {
- if (position && (!this._position || !this._position.equals(position))) {
- this._position = position;
- this._updatePosition();
- }
- };
- TextIconOverlay2.prototype.getStyleByText = function(text, styles) {
- var count = parseInt(text);
- var index2 = parseInt(count / 10);
- index2 = Math.max(0, index2);
- index2 = Math.min(index2, styles.length - 1);
- return styles[index2];
- };
- TextIconOverlay2.prototype._updateCss = function() {
- if (!this._domElement) {
- return;
- }
- var style = this.getStyleByText(this._text, this._styles);
- this._domElement.style.cssText = this._buildCssText(style);
- };
- TextIconOverlay2.prototype._updateText = function() {
- if (this._domElement) {
- this._domElement.innerHTML = this._text;
- }
- };
- TextIconOverlay2.prototype._updatePosition = function() {
- if (this._domElement && this._position) {
- var style = this._domElement.style;
- var pixelPosition = this._map.pointToOverlayPixel(this._position);
- pixelPosition.x -= Math.ceil(parseInt(style.width) / 2);
- pixelPosition.y -= Math.ceil(parseInt(style.height) / 2);
- style.left = pixelPosition.x + "px";
- style.top = pixelPosition.y + "px";
- }
- };
- TextIconOverlay2.prototype._buildCssText = function(style) {
- var url = style["url"];
- var size = style["size"];
- var anchor = style["anchor"];
- var offset = style["offset"];
- var textColor = style["textColor"] || "black";
- var textSize = style["textSize"] || 10;
- var csstext = [];
- if (T.browser["ie"] < 7) {
- csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="' + url + '");');
- } else {
- csstext.push("background-image:url(" + url + ");");
- var backgroundPosition = "0 0";
- offset instanceof BMap.Size && (backgroundPosition = offset.width + "px " + offset.height + "px");
- csstext.push("background-position:" + backgroundPosition + ";");
- }
- if (size instanceof BMap.Size) {
- if (anchor instanceof BMap.Size) {
- if (anchor.height > 0 && anchor.height < size.height) {
- csstext.push("height:" + (size.height - anchor.height) + "px; padding-top:" + anchor.height + "px;");
- }
- if (anchor.width > 0 && anchor.width < size.width) {
- csstext.push("width:" + (size.width - anchor.width) + "px; padding-left:" + anchor.width + "px;");
- }
- } else {
- csstext.push("height:" + size.height + "px; line-height:" + size.height + "px;");
- csstext.push("width:" + size.width + "px; text-align:center;");
- }
- }
- csstext.push("cursor:pointer; color:" + textColor + "; position:absolute; font-size:" + textSize + "px; font-family:Arial,sans-serif; font-weight:bold");
- return csstext.join("");
- };
- TextIconOverlay2.prototype._bind = function() {
- if (!this._domElement) {
- return;
- }
- var me = this;
- var map = this._map;
- var BaseEvent = T.lang.Event;
- function eventExtend(e, be) {
- var elem = e.srcElement || e.target;
- var x = e.clientX || e.pageX;
- var y = e.clientY || e.pageY;
- if (e && be && x && y && elem) {
- var offset = T.dom.getPosition(map.getContainer());
- be.pixel = new BMap.Pixel(x - offset.left, y - offset.top);
- be.point = map.pixelToPoint(be.pixel);
- }
- return be;
- }
- T.event.on(this._domElement, "mouseover", function(e) {
- me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseover")));
- });
- T.event.on(this._domElement, "mouseout", function(e) {
- me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseout")));
- });
- T.event.on(this._domElement, "click", function(e) {
- me.dispatchEvent(eventExtend(e, new BaseEvent("onclick")));
- });
- };
- return TextIconOverlay2;
- });
- });
- var TextIconOverlay = index$1 && typeof index$1 === "object" && "default" in index$1 ? index$1["default"] : index$1;
- var getExtendedBounds = function(map, bounds, gridSize) {
- bounds = cutBoundsInRange(bounds);
- var pixelNE = map.pointToPixel(bounds.getNorthEast());
- var pixelSW = map.pointToPixel(bounds.getSouthWest());
- pixelNE.x += gridSize;
- pixelNE.y -= gridSize;
- pixelSW.x -= gridSize;
- pixelSW.y += gridSize;
- var newNE = map.pixelToPoint(pixelNE);
- var newSW = map.pixelToPoint(pixelSW);
- return new BMap.Bounds(newSW, newNE);
- };
- var cutBoundsInRange = function(bounds) {
- var maxX = getRange(bounds.getNorthEast().lng, -180, 180);
- var minX = getRange(bounds.getSouthWest().lng, -180, 180);
- var maxY = getRange(bounds.getNorthEast().lat, -74, 74);
- var minY = getRange(bounds.getSouthWest().lat, -74, 74);
- return new BMap.Bounds(new BMap.Point(minX, minY), new BMap.Point(maxX, maxY));
- };
- var getRange = function(i, mix, max) {
- mix && (i = Math.max(i, mix));
- max && (i = Math.min(i, max));
- return i;
- };
- var isArray = function(source) {
- return Object.prototype.toString.call(source) === "[object Array]";
- };
- var indexOf = function(item, source) {
- var index2 = -1;
- if (isArray(source)) {
- if (source.indexOf) {
- index2 = source.indexOf(item);
- } else {
- for (var i = 0, m; m = source[i]; i++) {
- if (m === item) {
- index2 = i;
- break;
- }
- }
- }
- }
- return index2;
- };
- var MarkerClusterer2 = function(map, options) {
- try {
- BMap;
- } catch (e) {
- throw Error("Baidu Map JS API is not ready yet!");
- }
- if (!map) {
- return;
- }
- this._map = map;
- this._markers = [];
- this._clusters = [];
- var opts = options || {};
- this._gridSize = opts["gridSize"] || 60;
- this._maxZoom = opts["maxZoom"] || 18;
- this._minClusterSize = opts["minClusterSize"] || 2;
- this._isAverageCenter = false;
- if (opts["isAverageCenter"] != void 0) {
- this._isAverageCenter = opts["isAverageCenter"];
- }
- this._styles = opts["styles"] || [];
- var that = this;
- this._map.addEventListener("zoomend", function() {
- that._redraw();
- });
- this._map.addEventListener("moveend", function() {
- that._redraw();
- });
- var mkrs = opts["markers"];
- isArray(mkrs) && this.addMarkers(mkrs);
- };
- MarkerClusterer2.prototype.addMarkers = function(markers2) {
- if (!markers2.length) {
- return;
- }
- for (var i = 0, len = markers2.length; i < len; i++) {
- this._pushMarkerTo(markers2[i]);
- }
- this._createClusters();
- };
- MarkerClusterer2.prototype._pushMarkerTo = function(marker) {
- var index2 = indexOf(marker, this._markers);
- if (index2 === -1) {
- marker.isInCluster = false;
- this._markers.push(marker);
- }
- };
- MarkerClusterer2.prototype.addMarker = function(marker) {
- this._pushMarkerTo(marker);
- this._createClusters();
- };
- MarkerClusterer2.prototype._createClusters = function() {
- var mapBounds = this._map.getBounds();
- if (!mapBounds.getCenter()) {
- return;
- }
- var extendedBounds = getExtendedBounds(this._map, mapBounds, this._gridSize);
- for (var i = 0, marker; marker = this._markers[i]; i++) {
- if (!marker.isInCluster && extendedBounds.containsPoint(marker.getPosition())) {
- this._addToClosestCluster(marker);
- }
- }
- };
- MarkerClusterer2.prototype._addToClosestCluster = function(marker) {
- var distance = 4e6;
- var clusterToAddTo = null;
- marker.getPosition();
- for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
- var center = cluster.getCenter();
- if (center) {
- var d = this._map.getDistance(center, marker.getPosition());
- if (d < distance) {
- distance = d;
- clusterToAddTo = cluster;
- }
- }
- }
- if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
- clusterToAddTo.addMarker(marker);
- } else {
- var cluster = new Cluster(this);
- cluster.addMarker(marker);
- this._clusters.push(cluster);
- }
- };
- MarkerClusterer2.prototype._clearLastClusters = function() {
- for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
- cluster.remove();
- }
- this._clusters = [];
- this._removeMarkersFromCluster();
- };
- MarkerClusterer2.prototype._removeMarkersFromCluster = function() {
- for (var i = 0, marker; marker = this._markers[i]; i++) {
- marker.isInCluster = false;
- }
- };
- MarkerClusterer2.prototype._removeMarkersFromMap = function() {
- for (var i = 0, marker; marker = this._markers[i]; i++) {
- marker.isInCluster = false;
- var label = marker.getLabel();
- this._map.removeOverlay(marker);
- marker.setLabel(label);
- }
- };
- MarkerClusterer2.prototype._removeMarker = function(marker) {
- var index2 = indexOf(marker, this._markers);
- if (index2 === -1) {
- return false;
- }
- this._map.removeOverlay(marker);
- this._markers.splice(index2, 1);
- return true;
- };
- MarkerClusterer2.prototype.removeMarker = function(marker) {
- var success = this._removeMarker(marker);
- if (success) {
- this._clearLastClusters();
- this._createClusters();
- }
- return success;
- };
- MarkerClusterer2.prototype.removeMarkers = function(markers2) {
- var success = false;
- for (var i = 0; i < markers2.length; i++) {
- var r = this._removeMarker(markers2[i]);
- success = success || r;
- }
- if (success) {
- this._clearLastClusters();
- this._createClusters();
- }
- return success;
- };
- MarkerClusterer2.prototype.clearMarkers = function() {
- this._clearLastClusters();
- this._removeMarkersFromMap();
- this._markers = [];
- };
- MarkerClusterer2.prototype._redraw = function() {
- this._clearLastClusters();
- this._createClusters();
- };
- MarkerClusterer2.prototype.getGridSize = function() {
- return this._gridSize;
- };
- MarkerClusterer2.prototype.setGridSize = function(size) {
- this._gridSize = size;
- this._redraw();
- };
- MarkerClusterer2.prototype.getMaxZoom = function() {
- return this._maxZoom;
- };
- MarkerClusterer2.prototype.setMaxZoom = function(maxZoom) {
- this._maxZoom = maxZoom;
- this._redraw();
- };
- MarkerClusterer2.prototype.getStyles = function() {
- return this._styles;
- };
- MarkerClusterer2.prototype.setStyles = function(styles) {
- this._styles = styles;
- this._redraw();
- };
- MarkerClusterer2.prototype.getMinClusterSize = function() {
- return this._minClusterSize;
- };
- MarkerClusterer2.prototype.setMinClusterSize = function(size) {
- this._minClusterSize = size;
- this._redraw();
- };
- MarkerClusterer2.prototype.isAverageCenter = function() {
- return this._isAverageCenter;
- };
- MarkerClusterer2.prototype.getMap = function() {
- return this._map;
- };
- MarkerClusterer2.prototype.getMarkers = function() {
- return this._markers;
- };
- MarkerClusterer2.prototype.getClustersCount = function() {
- var count = 0;
- for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
- cluster.isReal() && count++;
- }
- return count;
- };
- function Cluster(markerClusterer) {
- this._markerClusterer = markerClusterer;
- this._map = markerClusterer.getMap();
- this._minClusterSize = markerClusterer.getMinClusterSize();
- this._isAverageCenter = markerClusterer.isAverageCenter();
- this._center = null;
- this._markers = [];
- this._gridBounds = null;
- this._isReal = false;
- this._clusterMarker = new TextIconOverlay(this._center, this._markers.length, { "styles": this._markerClusterer.getStyles() });
- }
- Cluster.prototype.addMarker = function(marker) {
- if (this.isMarkerInCluster(marker)) {
- return false;
- }
- if (!this._center) {
- this._center = marker.getPosition();
- this.updateGridBounds();
- } else {
- if (this._isAverageCenter) {
- var l = this._markers.length + 1;
- var lat = (this._center.lat * (l - 1) + marker.getPosition().lat) / l;
- var lng = (this._center.lng * (l - 1) + marker.getPosition().lng) / l;
- this._center = new BMap.Point(lng, lat);
- this.updateGridBounds();
- }
- }
- marker.isInCluster = true;
- this._markers.push(marker);
- var len = this._markers.length;
- if (len < this._minClusterSize) {
- this._map.addOverlay(marker);
- return true;
- } else if (len === this._minClusterSize) {
- for (var i = 0; i < len; i++) {
- var label = this._markers[i].getLabel();
- this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]);
- this._markers[i].setLabel(label);
- }
- }
- this._map.addOverlay(this._clusterMarker);
- this._isReal = true;
- this.updateClusterMarker();
- return true;
- };
- Cluster.prototype.isMarkerInCluster = function(marker) {
- if (this._markers.indexOf) {
- return this._markers.indexOf(marker) != -1;
- } else {
- for (var i = 0, m; m = this._markers[i]; i++) {
- if (m === marker) {
- return true;
- }
- }
- }
- return false;
- };
- Cluster.prototype.isMarkerInClusterBounds = function(marker) {
- return this._gridBounds.containsPoint(marker.getPosition());
- };
- Cluster.prototype.isReal = function(marker) {
- return this._isReal;
- };
- Cluster.prototype.updateGridBounds = function() {
- var bounds = new BMap.Bounds(this._center, this._center);
- this._gridBounds = getExtendedBounds(this._map, bounds, this._markerClusterer.getGridSize());
- };
- Cluster.prototype.updateClusterMarker = function() {
- if (this._map.getZoom() > this._markerClusterer.getMaxZoom()) {
- this._clusterMarker && this._map.removeOverlay(this._clusterMarker);
- for (var i = 0, marker; marker = this._markers[i]; i++) {
- this._map.addOverlay(marker);
- }
- return;
- }
- if (this._markers.length < this._minClusterSize) {
- this._clusterMarker.hide();
- return;
- }
- this._clusterMarker.setPosition(this._center);
- this._clusterMarker.setText(this._markers.length);
- this._clusterMarker.addEventListener && !this._clusterMarker._hasClickEvent && this._clusterMarker.addEventListener("click", function(event) {
- this._clusterMarker._hasClickEvent = true;
- this._markers && this._map.setViewport(this.getBounds());
- }.bind(this));
- };
- Cluster.prototype.remove = function() {
- for (var i = 0; this._markers[i]; i++) {
- var label = this._markers[i].getLabel();
- this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]);
- this._markers[i].setLabel(label);
- }
- this._map.removeOverlay(this._clusterMarker);
- this._markers.length = 0;
- delete this._markers;
- };
- Cluster.prototype.getBounds = function() {
- var bounds = new BMap.Bounds(this._center, this._center);
- for (var i = 0, marker; marker = this._markers[i]; i++) {
- bounds.extend(marker.getPosition());
- }
- return bounds;
- };
- Cluster.prototype.getCenter = function() {
- return this._center;
- };
- return MarkerClusterer2;
- });
- })(bmaplib_markerclusterer);
- var MarkerClusterer$1 = bmaplib_markerclusterer.exports;
- var markers = [];
- var _sfc_main$3 = {
- name: "bml-marker-clusterer",
- mixins: [commonMixin("markerClusterer")],
- provide() {
- return {
- Cluster: this
- };
- },
- props: {
- gridSize: {
- type: Number
- },
- maxZoom: {
- type: Number
- },
- minClusterSize: {
- type: Number
- },
- styles: {
- type: Array,
- default() {
- return [];
- }
- },
- averageCenter: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {};
- },
- watch: {
- gridSize: {
- handler(val) {
- const { BMap: BMap2, originInstance } = this;
- originInstance.setGridSize(val);
- },
- deep: true
- },
- maxZoom(val) {
- const { originInstance } = this;
- originInstance.setMaxZoom(val);
- },
- minClusterSize: {
- handler(val) {
- const { BMap: BMap2, originInstance } = this;
- originInstance.setMinClusterSize(val);
- },
- deep: true
- },
- styles: {
- handler(val) {
- const { BMap: BMap2, originInstance } = this;
- const obj = JSON.parse(JSON.stringify(val)).map((item) => {
- item.size = item.size && createSize(BMap2, item.size);
- return item;
- });
- originInstance.setStyles(obj);
- },
- deep: true
- },
- averageCenter(val) {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, gridSize, minClusterSize, maxZoom, styles, averageCenter } = this;
- this.originInstance = new MarkerClusterer$1(map, {
- gridSize: gridSize || 60,
- maxZoom,
- minClusterSize: minClusterSize || 2,
- styles: styles.map((item) => {
- item.size = createSize(BMap2, item.size);
- return item;
- }),
- isAverageCenter: averageCenter
- });
- this.$nextTick(() => {
- const markersInstance = markers.map((inst) => inst.originInstance).filter((marker) => marker instanceof BMap2.Marker);
- this.originInstance.addMarkers(markersInstance);
- });
- },
- addMaker(maker) {
- markers.push(maker);
- },
- removeMaker(maker) {
- markers.splice(markers.indexOf(maker), 1);
- }
- },
- beforeCreate() {
- this.preventChildrenRender = true;
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("span", null, [
- renderSlot(_ctx.$slots, "default")
- ]);
- }
- var MarkerClusterer = _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
- var bmaplib_lushu = { exports: {} };
- (function(module, exports) {
- (function(root, factory) {
- {
- module.exports = factory();
- }
- })(commonjsGlobal, function() {
- var baidu = {};
- baidu.dom = {};
- baidu.dom.g = function(id) {
- if (typeof id == "string" || id instanceof String) {
- return document.getElementById(id);
- } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) {
- return id;
- }
- return null;
- };
- baidu.g = baidu.G = baidu.dom.g;
- baidu.lang = baidu.lang || {};
- baidu.lang.isString = function(source) {
- return Object.prototype.toString.call(source) == "[object String]";
- };
- baidu.isString = baidu.lang.isString;
- baidu.dom._g = function(id) {
- if (baidu.lang.isString(id)) {
- return document.getElementById(id);
- }
- return id;
- };
- baidu._g = baidu.dom._g;
- baidu.dom.getDocument = function(element) {
- element = baidu.dom.g(element);
- return element.nodeType == 9 ? element : element.ownerDocument || element.document;
- };
- baidu.browser = baidu.browser || {};
- baidu.browser.ie = baidu.ie = /msie (\d+\.\d+)/i.test(navigator.userAgent) ? document.documentMode || +RegExp["$1"] : void 0;
- baidu.dom.getComputedStyle = function(element, key) {
- element = baidu.dom._g(element);
- var doc = baidu.dom.getDocument(element), styles;
- if (doc.defaultView && doc.defaultView.getComputedStyle) {
- styles = doc.defaultView.getComputedStyle(element, null);
- if (styles) {
- return styles[key] || styles.getPropertyValue(key);
- }
- }
- return "";
- };
- baidu.dom._styleFixer = baidu.dom._styleFixer || {};
- baidu.dom._styleFilter = baidu.dom._styleFilter || [];
- baidu.dom._styleFilter.filter = function(key, value, method) {
- for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) {
- if (filter = filter[method]) {
- value = filter(key, value);
- }
- }
- return value;
- };
- baidu.string = baidu.string || {};
- baidu.string.toCamelCase = function(source) {
- if (source.indexOf("-") < 0 && source.indexOf("_") < 0) {
- return source;
- }
- return source.replace(/[-_][^-_]/g, function(match) {
- return match.charAt(1).toUpperCase();
- });
- };
- baidu.dom.getStyle = function(element, key) {
- var dom = baidu.dom;
- element = dom.g(element);
- key = baidu.string.toCamelCase(key);
- var value = element.style[key] || (element.currentStyle ? element.currentStyle[key] : "") || dom.getComputedStyle(element, key);
- if (!value) {
- var fixer = dom._styleFixer[key];
- if (fixer) {
- value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer);
- }
- }
- if (fixer = dom._styleFilter) {
- value = fixer.filter(key, value, "get");
- }
- return value;
- };
- baidu.getStyle = baidu.dom.getStyle;
- baidu.dom._NAME_ATTRS = function() {
- var result = {
- "cellpadding": "cellPadding",
- "cellspacing": "cellSpacing",
- "colspan": "colSpan",
- "rowspan": "rowSpan",
- "valign": "vAlign",
- "usemap": "useMap",
- "frameborder": "frameBorder"
- };
- if (baidu.browser.ie < 8) {
- result["for"] = "htmlFor";
- result["class"] = "className";
- } else {
- result["htmlFor"] = "for";
- result["className"] = "class";
- }
- return result;
- }();
- baidu.dom.setAttr = function(element, key, value) {
- element = baidu.dom.g(element);
- if (key == "style") {
- element.style.cssText = value;
- } else {
- key = baidu.dom._NAME_ATTRS[key] || key;
- element.setAttribute(key, value);
- }
- return element;
- };
- baidu.setAttr = baidu.dom.setAttr;
- baidu.dom.setAttrs = function(element, attributes) {
- element = baidu.dom.g(element);
- for (var key in attributes) {
- baidu.dom.setAttr(element, key, attributes[key]);
- }
- return element;
- };
- baidu.setAttrs = baidu.dom.setAttrs;
- baidu.dom.create = function(tagName, opt_attributes) {
- var el = document.createElement(tagName), attributes = opt_attributes || {};
- return baidu.dom.setAttrs(el, attributes);
- };
- baidu.object = baidu.object || {};
- baidu.extend = baidu.object.extend = function(target, source) {
- for (var p in source) {
- if (source.hasOwnProperty(p)) {
- target[p] = source[p];
- }
- }
- return target;
- };
- var LuShu = function(map, path, opts) {
- try {
- BMap;
- } catch (e) {
- throw Error("Baidu Map JS API is not ready yet!");
- }
- if (!path || path.length < 1) {
- return;
- }
- this._map = map;
- this._path = path;
- this.i = 0;
- this._setTimeoutQuene = [];
- this._projection = this._map.getMapType().getProjection();
- this._opts = {
- icon: null,
- speed: 4e3,
- defaultContent: "",
- showInfoWindow: false
- };
- this._setOptions(opts);
- this._rotation = 0;
- if (!this._opts.icon instanceof BMap.Icon) {
- this._opts.icon = defaultIcon;
- }
- };
- LuShu.prototype._setOptions = function(opts) {
- if (!opts) {
- return;
- }
- for (var p in opts) {
- if (opts.hasOwnProperty(p)) {
- this._opts[p] = opts[p];
- }
- }
- };
- LuShu.prototype.start = function() {
- var me = this, len = me._path.length;
- this._opts.onstart && this._opts.onstart(me);
- if (me.i && me.i < len - 1) {
- if (!me._fromPause) {
- return;
- } else if (!me._fromStop) {
- me._moveNext(++me.i);
- }
- } else {
- !me._marker && me._addMarker();
- me._timeoutFlag = setTimeout(function() {
- !me._overlay && me._addInfoWin();
- me._moveNext(me.i);
- }, 400);
- }
- this._fromPause = false;
- this._fromStop = false;
- }, LuShu.prototype.stop = function() {
- this.i = 0;
- this._fromStop = true;
- clearInterval(this._intervalFlag);
- this._clearTimeout();
- for (var i = 0, t = this._opts.landmarkPois, len = t.length; i < len; i++) {
- t[i].bShow = false;
- }
- this._opts.onstop && this._opts.onstop(this);
- };
- LuShu.prototype.pause = function() {
- clearInterval(this._intervalFlag);
- this._fromPause = true;
- this._clearTimeout();
- this._opts.onpause && this._opts.onpause(this);
- };
- LuShu.prototype.hideInfoWindow = function() {
- this._opts.showInfoWindow = false;
- this._overlay && (this._overlay._div.style.visibility = "hidden");
- };
- LuShu.prototype.showInfoWindow = function() {
- this._opts.showInfoWindow = true;
- this._overlay && (this._overlay._div.style.visibility = "visible");
- };
- LuShu.prototype.dispose = function() {
- clearInterval(this._intervalFlag);
- this._setTimeoutQuene && this._clearTimeout();
- if (this._map) {
- this._map.removeOverlay(this._overlay);
- this._map.removeOverlay(this._marker);
- }
- };
- baidu.object.extend(LuShu.prototype, {
- _addMarker: function(callback) {
- if (this._marker) {
- this.stop();
- this._map.removeOverlay(this._marker);
- clearTimeout(this._timeoutFlag);
- }
- this._overlay && this._map.removeOverlay(this._overlay);
- var marker = new BMap.Marker(this._path[0]);
- this._opts.icon && marker.setIcon(this._opts.icon);
- this._map.addOverlay(marker);
- marker.setAnimation(BMAP_ANIMATION_DROP);
- this._marker = marker;
- },
- _addInfoWin: function() {
- var me = this;
- !CustomOverlay.prototype.initialize && initCustomOverlay();
- var overlay = new CustomOverlay(me._marker.getPosition(), me._opts.defaultContent);
- overlay.setRelatedClass(this);
- this._overlay = overlay;
- this._map.addOverlay(overlay);
- this._opts.showInfoWindow ? this.showInfoWindow() : this.hideInfoWindow();
- },
- _getMercator: function(poi) {
- return this._map.getMapType().getProjection().lngLatToPoint(poi);
- },
- _getDistance: function(pxA, pxB) {
- return Math.sqrt(Math.pow(pxA.x - pxB.x, 2) + Math.pow(pxA.y - pxB.y, 2));
- },
- _move: function(initPos, targetPos, effect) {
- 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);
- if (count < 1) {
- me._moveNext(++me.i);
- return;
- }
- me._intervalFlag = setInterval(function() {
- if (currentCount >= count) {
- clearInterval(me._intervalFlag);
- if (me.i > me._path.length) {
- return;
- }
- me._moveNext(++me.i);
- } else {
- currentCount++;
- 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));
- if (currentCount == 1) {
- var proPos = null;
- if (me.i - 1 >= 0) {
- proPos = me._path[me.i - 1];
- }
- if (me._opts.enableRotation == true) {
- me.setRotation(proPos, initPos, targetPos);
- }
- if (me._opts.autoView) {
- if (!me._map.getBounds().containsPoint(pos)) {
- me._map.setCenter(pos);
- }
- }
- }
- me._marker.setPosition(pos);
- me._setInfoWin(pos);
- }
- }, timer);
- },
- setRotation: function(prePos, curPos, targetPos) {
- var me = this;
- var deg = 0;
- curPos = me._map.pointToPixel(curPos);
- targetPos = me._map.pointToPixel(targetPos);
- if (targetPos.x != curPos.x) {
- var tan = (targetPos.y - curPos.y) / (targetPos.x - curPos.x), atan = Math.atan(tan);
- deg = atan * 360 / (2 * Math.PI);
- if (targetPos.x < curPos.x) {
- deg = -deg + 90 + 90;
- } else {
- deg = -deg;
- }
- me._marker.setRotation(-deg);
- } else {
- var disy = targetPos.y - curPos.y;
- var bias = 0;
- if (disy > 0)
- bias = -1;
- else
- bias = 1;
- me._marker.setRotation(-bias * 90);
- }
- return;
- },
- linePixellength: function(from, to) {
- 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));
- },
- pointToPoint: function(from, to) {
- 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);
- },
- _moveNext: function(index2) {
- var me = this;
- if (index2 < this._path.length - 1) {
- me._move(me._path[index2], me._path[index2 + 1], me._tween.linear);
- } else {
- me.stop();
- }
- },
- _setInfoWin: function(pos) {
- var me = this;
- me._overlay.setPosition(pos, me._marker.getIcon().size);
- var index2 = me._troughPointIndex(pos);
- if (index2 != -1) {
- clearInterval(me._intervalFlag);
- me._overlay.setHtml(me._opts.landmarkPois[index2].html);
- me._overlay.setPosition(pos, me._marker.getIcon().size);
- me._pauseForView(index2);
- } else {
- me._overlay.setHtml(me._opts.defaultContent);
- }
- },
- _pauseForView: function(index2) {
- var me = this;
- var t = setTimeout(function() {
- me._moveNext(++me.i);
- }, me._opts.landmarkPois[index2].pauseTime * 1e3);
- me._setTimeoutQuene.push(t);
- },
- _clearTimeout: function() {
- for (var i in this._setTimeoutQuene) {
- clearTimeout(this._setTimeoutQuene[i]);
- }
- this._setTimeoutQuene.length = 0;
- },
- _tween: {
- linear: function(initPos, targetPos, currentCount, count) {
- var b = initPos, c = targetPos - initPos, t = currentCount, d = count;
- return c * t / d + b;
- }
- },
- _troughPointIndex: function(markerPoi) {
- var t = this._opts.landmarkPois, distance;
- for (var i = 0, len = t.length; i < len; i++) {
- if (!t[i].bShow) {
- distance = this._map.getDistance(new BMap.Point(t[i].lng, t[i].lat), markerPoi);
- if (distance < 10) {
- t[i].bShow = true;
- return i;
- }
- }
- }
- return -1;
- }
- });
- function CustomOverlay(point, html) {
- this._point = point;
- this._html = html;
- }
- function initCustomOverlay() {
- CustomOverlay.prototype = new BMap.Overlay();
- CustomOverlay.prototype.initialize = function(map) {
- 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;" });
- div.innerHTML = this._html;
- map.getPanes().floatPane.appendChild(div);
- this._map = map;
- return div;
- };
- CustomOverlay.prototype.draw = function() {
- this.setPosition(this.lushuMain._marker.getPosition(), this.lushuMain._marker.getIcon().size);
- };
- baidu.object.extend(CustomOverlay.prototype, {
- setPosition: function(poi, markerSize) {
- 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);
- parseInt(this._div.clientHeight || styleH, 10);
- this._div.style.left = px.x - overlayW / 2 + "px";
- this._div.style.bottom = -(px.y - markerSize.height) + "px";
- },
- setHtml: function(html) {
- this._div.innerHTML = html;
- },
- setRelatedClass: function(lushuMain) {
- this.lushuMain = lushuMain;
- }
- });
- }
- return LuShu;
- });
- })(bmaplib_lushu);
- var Lushu = bmaplib_lushu.exports;
- var _sfc_main$2 = {
- name: "bm-lushu",
- render(h) {
- },
- emits: ["start", "stop", "pause"],
- mixins: [commonMixin("lushu")],
- props: {
- path: {
- type: Array,
- default: []
- },
- landmarkPois: {
- type: Array,
- default() {
- return [];
- }
- },
- icon: {
- type: Object
- },
- speed: {
- type: Number,
- default: 4e3
- },
- content: {
- type: String,
- default: ""
- },
- autoView: {
- type: Boolean,
- default: false
- },
- rotation: {
- type: Boolean,
- default: false
- },
- infoWindow: {
- type: Boolean,
- default: true
- },
- play: {
- type: Boolean,
- default: true
- }
- },
- watch: {
- path: {
- handler(val) {
- this.reload();
- },
- deep: true
- },
- landmarkPois: {
- handler(val) {
- this.reload();
- },
- deep: true
- },
- icon: {
- handler(val) {
- const { originInstance, content } = this;
- const newMarker = createIcon(BMap, val);
- originInstance._opts.icon = newMarker;
- originInstance._marker = newMarker;
- },
- deep: true
- },
- speed(val) {
- const { originInstance, content } = this;
- originInstance._opts.speed = val;
- },
- content(val) {
- const { originInstance, infoWindow } = this;
- val && infoWindow ? originInstance.showInfoWindow() : originInstance.hideInfoWindow();
- originInstance._opts.defaultContent = val;
- originInstance._overlay && originInstance._overlay.setHtml(val);
- },
- autoView(val) {
- const { originInstance, content } = this;
- originInstance._opts.autoView = val;
- },
- rotation(val) {
- const { originInstance, content } = this;
- originInstance._opts.enableRotation = val;
- },
- infoWindow(val) {
- const { originInstance, content } = this;
- originInstance && val && content ? originInstance.showInfoWindow() : originInstance.hideInfoWindow();
- },
- play(val) {
- const { originInstance } = this;
- val && originInstance ? originInstance.start() : !this._isEnd && originInstance.pause();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, path, landmarkPois, icon, speed, content, autoView, rotation, infoWindow, play } = this;
- const lushu = this.originInstance = new Lushu(map, path, {
- enableRotation: rotation,
- landmarkPois,
- showInfoWindow: infoWindow,
- defaultContent: content,
- icon: icon && createIcon(BMap2, icon),
- speed,
- autoView,
- onstart: (e) => {
- this._isEnd = false;
- this.$emit("start");
- },
- onstop: (e) => {
- this._isEnd = true;
- this.$emit("stop");
- },
- onpause: (e) => this.$emit("pause")
- });
- play && path.length && lushu.start(this);
- path.length && (content && infoWindow ? lushu.showInfoWindow() : lushu.hideInfoWindow());
- }
- }
- };
- var bmaplib_heatmap = { exports: {} };
- (function(module, exports) {
- (function(root, factory) {
- {
- module.exports = factory();
- }
- })(commonjsGlobal, function() {
- function inherits(subClass, superClass, className) {
- var key, proto, selfProps = subClass.prototype, clazz = new Function();
- clazz.prototype = superClass.prototype;
- proto = subClass.prototype = new clazz();
- for (key in selfProps) {
- proto[key] = selfProps[key];
- }
- subClass.prototype.constructor = subClass;
- subClass.superClass = superClass.prototype;
- if (typeof className == "string") {
- proto._className = className;
- }
- }
- var heatmapFactory = function() {
- var store = function store2(hmap) {
- var _ = {
- data: [],
- heatmap: hmap
- };
- this.max = 1;
- this.get = function(key) {
- return _[key];
- };
- this.set = function(key, value) {
- _[key] = value;
- };
- };
- store.prototype = {
- addDataPoint: function(x, y) {
- if (x < 0 || y < 0)
- return;
- var me = this, heatmap2 = me.get("heatmap"), data = me.get("data");
- if (!data[x])
- data[x] = [];
- if (!data[x][y])
- data[x][y] = 0;
- data[x][y] += arguments.length < 3 ? 1 : arguments[2];
- me.set("data", data);
- if (me.max < data[x][y]) {
- heatmap2.get("actx").clearRect(0, 0, heatmap2.get("width"), heatmap2.get("height"));
- me.setDataSet({ max: data[x][y], data }, true);
- return;
- }
- heatmap2.drawAlpha(x, y, data[x][y], true);
- },
- setDataSet: function(obj, internal) {
- var me = this, heatmap2 = me.get("heatmap"), data = [], d = obj.data, dlen = d.length;
- heatmap2.clear();
- this.max = obj.max;
- heatmap2.get("legend") && heatmap2.get("legend").update(obj.max);
- if (internal != null && internal) {
- for (var one in d) {
- if (one === void 0)
- continue;
- for (var two in d[one]) {
- if (two === void 0)
- continue;
- heatmap2.drawAlpha(one, two, d[one][two], false);
- }
- }
- } else {
- while (dlen--) {
- var point = d[dlen];
- heatmap2.drawAlpha(point.x, point.y, point.count, false);
- if (!data[point.x])
- data[point.x] = [];
- if (!data[point.x][point.y])
- data[point.x][point.y] = 0;
- data[point.x][point.y] = point.count;
- }
- }
- heatmap2.colorize();
- this.set("data", d);
- },
- exportDataSet: function() {
- var me = this, data = me.get("data"), exportData = [];
- for (var one in data) {
- if (one === void 0)
- continue;
- for (var two in data[one]) {
- if (two === void 0)
- continue;
- exportData.push({ x: parseInt(one, 10), y: parseInt(two, 10), count: data[one][two] });
- }
- }
- return { max: me.max, data: exportData };
- },
- generateRandomDataSet: function(points) {
- var heatmap2 = this.get("heatmap"), w = heatmap2.get("width"), h = heatmap2.get("height");
- var randomset = {}, max = Math.floor(Math.random() * 1e3 + 1);
- randomset.max = max;
- var data = [];
- while (points--) {
- data.push({ x: Math.floor(Math.random() * w + 1), y: Math.floor(Math.random() * h + 1), count: Math.floor(Math.random() * max + 1) });
- }
- randomset.data = data;
- this.setDataSet(randomset);
- }
- };
- var legend = function legend2(config2) {
- this.config = config2;
- var _ = {
- element: null,
- labelsEl: null,
- gradientCfg: null,
- ctx: null
- };
- this.get = function(key) {
- return _[key];
- };
- this.set = function(key, value) {
- _[key] = value;
- };
- this.init();
- };
- legend.prototype = {
- init: function() {
- var me = this, config2 = me.config, title = config2.title || "Legend", position = config2.position, offset = config2.offset || 10;
- config2.gradient;
- var labelsEl = document.createElement("ul"), element, gradient, positionCss = "";
- me.processGradientObject();
- if (position.indexOf("t") > -1) {
- positionCss += "top:" + offset + "px;";
- } else {
- positionCss += "bottom:" + offset + "px;";
- }
- if (position.indexOf("l") > -1) {
- positionCss += "left:" + offset + "px;";
- } else {
- positionCss += "right:" + offset + "px;";
- }
- element = document.createElement("div");
- 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;";
- element.innerHTML = "<h3 style='padding:0;margin:0;text-align:center;font-size:16px;'>" + title + "</h3>";
- labelsEl.style.cssText = "position:relative;font-size:12px;display:block;list-style:none;list-style-type:none;margin:0;height:15px;";
- gradient = document.createElement("div");
- gradient.style.cssText = ["position:relative;display:block;width:256px;height:15px;border-bottom:1px solid black; background-image:url(", me.createGradientImage(), ");"].join("");
- element.appendChild(labelsEl);
- element.appendChild(gradient);
- me.set("element", element);
- me.set("labelsEl", labelsEl);
- me.update(1);
- },
- processGradientObject: function() {
- var me = this, gradientConfig = this.config.gradient, gradientArr = [];
- for (var key in gradientConfig) {
- if (gradientConfig.hasOwnProperty(key)) {
- gradientArr.push({ stop: key, value: gradientConfig[key] });
- }
- }
- gradientArr.sort(function(a, b) {
- return a.stop - b.stop;
- });
- gradientArr.unshift({ stop: 0, value: "rgba(0,0,0,0)" });
- me.set("gradientArr", gradientArr);
- },
- createGradientImage: function() {
- var me = this, gradArr = me.get("gradientArr"), length = gradArr.length, canvas = document.createElement("canvas"), ctx = canvas.getContext("2d"), grad;
- canvas.width = "256";
- canvas.height = "15";
- grad = ctx.createLinearGradient(0, 5, 256, 10);
- for (var i = 0; i < length; i++) {
- grad.addColorStop(1 / (length - 1) * i, gradArr[i].value);
- }
- ctx.fillStyle = grad;
- ctx.fillRect(0, 5, 256, 10);
- ctx.strokeStyle = "black";
- ctx.beginPath();
- for (var i = 0; i < length; i++) {
- ctx.moveTo((1 / (length - 1) * i * 256 >> 0) + 0.5, 0);
- ctx.lineTo((1 / (length - 1) * i * 256 >> 0) + 0.5, i == 0 ? 15 : 5);
- }
- ctx.moveTo(255.5, 0);
- ctx.lineTo(255.5, 15);
- ctx.moveTo(255.5, 4.5);
- ctx.lineTo(0, 4.5);
- ctx.stroke();
- me.set("ctx", ctx);
- return canvas.toDataURL();
- },
- getElement: function() {
- return this.get("element");
- },
- update: function(max) {
- var me = this, gradient = me.get("gradientArr"), ctx = me.get("ctx"), labels = me.get("labelsEl"), labelText, labelsHtml = "", offset;
- for (var i = 0; i < gradient.length; i++) {
- labelText = max * gradient[i].stop >> 0;
- offset = ctx.measureText(labelText).width / 2 >> 0;
- if (i == 0) {
- offset = 0;
- }
- if (i == gradient.length - 1) {
- offset *= 2;
- }
- labelsHtml += '<li style="position:absolute;left:' + (((1 / (gradient.length - 1) * i * 256 || 0) >> 0) - offset + 0.5) + 'px">' + labelText + "</li>";
- }
- labels.innerHTML = labelsHtml;
- }
- };
- var heatmap = function heatmap2(config2) {
- var _ = {
- radius: 40,
- element: {},
- canvas: {},
- acanvas: {},
- ctx: {},
- actx: {},
- legend: null,
- visible: true,
- width: 0,
- height: 0,
- max: false,
- gradient: false,
- opacity: 180,
- premultiplyAlpha: false,
- bounds: {
- l: 1e3,
- r: 0,
- t: 1e3,
- b: 0
- },
- debug: false
- };
- this.store = new store(this);
- this.get = function(key) {
- return _[key];
- };
- this.set = function(key, value) {
- _[key] = value;
- };
- this.configure(config2);
- this.init();
- };
- heatmap.prototype = {
- configure: function(config2) {
- var me = this;
- me.set("radius", config2["radius"] || 40);
- me.set("element", config2.element instanceof Object ? config2.element : document.getElementById(config2.element));
- me.set("visible", config2.visible != null ? config2.visible : true);
- me.set("max", config2.max || false);
- 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)" });
- me.set("opacity", parseInt(255 / (100 / config2.opacity), 10) || 180);
- me.set("width", config2.width || 0);
- me.set("height", config2.height || 0);
- me.set("debug", config2.debug);
- if (config2.legend) {
- var legendCfg = config2.legend;
- legendCfg.gradient = me.get("gradient");
- me.set("legend", new legend(legendCfg));
- }
- },
- resize: function() {
- var me = this, element = me.get("element"), canvas = me.get("canvas"), acanvas = me.get("acanvas");
- canvas.width = acanvas.width = me.get("width") || element.style.width.replace(/px/, "") || me.getWidth(element);
- this.set("width", canvas.width);
- canvas.height = acanvas.height = me.get("height") || element.style.height.replace(/px/, "") || me.getHeight(element);
- this.set("height", canvas.height);
- },
- init: function() {
- var me = this, canvas = document.createElement("canvas"), acanvas = document.createElement("canvas"), ctx = canvas.getContext("2d"), actx = acanvas.getContext("2d"), element = me.get("element");
- me.initColorPalette();
- me.set("canvas", canvas);
- me.set("ctx", ctx);
- me.set("acanvas", acanvas);
- me.set("actx", actx);
- me.resize();
- canvas.style.cssText = acanvas.style.cssText = "position:absolute;top:0;left:0;z-index:10000000;";
- if (!me.get("visible"))
- canvas.style.display = "none";
- element.appendChild(canvas);
- if (me.get("legend")) {
- element.appendChild(me.get("legend").getElement());
- }
- if (me.get("debug"))
- document.body.appendChild(acanvas);
- actx.shadowOffsetX = 15e3;
- actx.shadowOffsetY = 15e3;
- actx.shadowBlur = 15;
- },
- initColorPalette: function() {
- var me = this, canvas = document.createElement("canvas"), gradient = me.get("gradient"), ctx, grad, testData;
- canvas.width = "1";
- canvas.height = "256";
- ctx = canvas.getContext("2d");
- grad = ctx.createLinearGradient(0, 0, 1, 256);
- testData = ctx.getImageData(0, 0, 1, 1);
- testData.data[0] = testData.data[3] = 64;
- testData.data[1] = testData.data[2] = 0;
- ctx.putImageData(testData, 0, 0);
- testData = ctx.getImageData(0, 0, 1, 1);
- me.set("premultiplyAlpha", testData.data[0] < 60 || testData.data[0] > 70);
- for (var x in gradient) {
- grad.addColorStop(x, gradient[x]);
- }
- ctx.fillStyle = grad;
- ctx.fillRect(0, 0, 1, 256);
- me.set("gradient", ctx.getImageData(0, 0, 1, 256).data);
- },
- getWidth: function(element) {
- var width = element.offsetWidth;
- if (element.style.paddingLeft) {
- width += element.style.paddingLeft;
- }
- if (element.style.paddingRight) {
- width += element.style.paddingRight;
- }
- return width;
- },
- getHeight: function(element) {
- var height = element.offsetHeight;
- if (element.style.paddingTop) {
- height += element.style.paddingTop;
- }
- if (element.style.paddingBottom) {
- height += element.style.paddingBottom;
- }
- return height;
- },
- colorize: function(x, y) {
- 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;
- if (x != null && y != null) {
- if (x + x2 > width) {
- x = width - x2;
- }
- if (x < 0) {
- x = 0;
- }
- if (y < 0) {
- y = 0;
- }
- if (y + x2 > height) {
- y = height - x2;
- }
- left = x;
- top = y;
- right = x + x2;
- bottom = y + x2;
- } else {
- if (bounds["l"] < 0) {
- left = 0;
- } else {
- left = bounds["l"];
- }
- if (bounds["r"] > width) {
- right = width;
- } else {
- right = bounds["r"];
- }
- if (bounds["t"] < 0) {
- top = 0;
- } else {
- top = bounds["t"];
- }
- if (bounds["b"] > height) {
- bottom = height;
- } else {
- bottom = bounds["b"];
- }
- }
- image = actx.getImageData(left, top, right - left, bottom - top);
- length = image.data.length;
- for (var i = 3; i < length; i += 4) {
- alpha = image.data[i], offset = alpha * 4;
- if (!offset)
- continue;
- finalAlpha = alpha < opacity ? alpha : opacity;
- image.data[i - 3] = palette[offset];
- image.data[i - 2] = palette[offset + 1];
- image.data[i - 1] = palette[offset + 2];
- if (premultiplyAlpha) {
- image.data[i - 3] /= 255 / finalAlpha;
- image.data[i - 2] /= 255 / finalAlpha;
- image.data[i - 1] /= 255 / finalAlpha;
- }
- image.data[i] = finalAlpha;
- }
- ctx.putImageData(image, left, top);
- },
- drawAlpha: function(x, y, count, colorize) {
- var me = this, radius = me.get("radius"), ctx = me.get("actx");
- me.get("max");
- 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;
- ctx.shadowColor = "rgba(0,0,0," + (count ? count / me.store.max : "0.1") + ")";
- ctx.shadowOffsetX = 15e3;
- ctx.shadowOffsetY = 15e3;
- ctx.shadowBlur = 15;
- ctx.beginPath();
- ctx.arc(x - 15e3, y - 15e3, radius, 0, Math.PI * 2, true);
- ctx.closePath();
- ctx.fill();
- if (colorize) {
- me.colorize(xb, yb);
- } else {
- if (xb < bounds["l"]) {
- bounds["l"] = xb;
- }
- if (yb < bounds["t"]) {
- bounds["t"] = yb;
- }
- if (xc > bounds["r"]) {
- bounds["r"] = xc;
- }
- if (yc > bounds["b"]) {
- bounds["b"] = yc;
- }
- }
- },
- toggleDisplay: function() {
- var me = this, visible = me.get("visible"), canvas = me.get("canvas");
- if (!visible)
- canvas.style.display = "block";
- else
- canvas.style.display = "none";
- me.set("visible", !visible);
- },
- getImageData: function() {
- return this.get("canvas").toDataURL();
- },
- clear: function() {
- var me = this, w = me.get("width"), h = me.get("height");
- me.store.set("data", []);
- me.get("ctx").clearRect(0, 0, w, h);
- me.get("actx").clearRect(0, 0, w, h);
- },
- cleanup: function() {
- var me = this;
- me.get("element").removeChild(me.get("canvas"));
- }
- };
- return {
- create: function(config2) {
- return new heatmap(config2);
- },
- util: {
- mousePosition: function(ev) {
- var x, y;
- if (ev.layerX) {
- x = ev.layerX;
- y = ev.layerY;
- } else if (ev.offsetX) {
- x = ev.offsetX;
- y = ev.offsetY;
- }
- if (typeof x == "undefined")
- return;
- return [x, y];
- }
- }
- };
- }();
- var HeatmapOverlay = function(opts) {
- try {
- BMap;
- } catch (e) {
- throw Error("Baidu Map JS API is not ready yet!");
- }
- if (!HeatmapOverlay._isExtended) {
- HeatmapOverlay._isExtended = true;
- inherits(HeatmapOverlay, BMap.Overlay, "HeatmapOverlay");
- var newHeatmap = new HeatmapOverlay(opts);
- this.__proto__ = newHeatmap.__proto__;
- }
- this.conf = opts;
- this.heatmap = null;
- this.latlngs = [];
- this.bounds = null;
- this._moveendHandler = this._moveendHandler.bind(this);
- };
- HeatmapOverlay.prototype.initialize = function(map) {
- this._map = map;
- var el = document.createElement("div");
- el.style.position = "absolute";
- el.style.top = 0;
- el.style.left = 0;
- el.style.border = 0;
- el.style.width = this._map.getSize().width + "px";
- el.style.height = this._map.getSize().height + "px";
- this.conf.element = el;
- map.getPanes().mapPane.appendChild(el);
- this.heatmap = heatmapFactory.create(this.conf);
- this._div = el;
- return el;
- };
- HeatmapOverlay.prototype.draw = function() {
- var currentBounds = this._map.getBounds();
- if (currentBounds.equals(this.bounds)) {
- return;
- }
- this.bounds = currentBounds;
- var ne = this._map.pointToOverlayPixel(currentBounds.getNorthEast()), sw = this._map.pointToOverlayPixel(currentBounds.getSouthWest());
- if (!ne || !sw) {
- return;
- }
- var topY = ne.y, leftX = sw.x, h = sw.y - ne.y, w = ne.x - sw.x;
- this.conf.element.style.left = leftX + "px";
- this.conf.element.style.top = topY + "px";
- this.conf.element.style.width = w + "px";
- this.conf.element.style.height = h + "px";
- this.heatmap.store.get("heatmap").resize();
- if (this.latlngs.length > 0) {
- this.heatmap.clear();
- var len = this.latlngs.length;
- var d = {
- max: this.heatmap.store.max,
- data: []
- };
- while (len--) {
- var latlng = this.latlngs[len].latlng;
- if (!currentBounds.containsPoint(latlng)) {
- continue;
- }
- var divPixel = this._map.pointToOverlayPixel(latlng), screenPixel = new BMap.Pixel(divPixel.x - leftX, divPixel.y - topY);
- var roundedPoint = this.pixelTransform(screenPixel);
- d.data.push({
- x: roundedPoint.x,
- y: roundedPoint.y,
- count: this.latlngs[len].c
- });
- }
- this.heatmap.store.setDataSet(d);
- }
- };
- HeatmapOverlay.prototype.pixelTransform = function(p) {
- var w = this.heatmap.get("width"), h = this.heatmap.get("height");
- while (p.x < 0) {
- p.x += w;
- }
- while (p.x > w) {
- p.x -= w;
- }
- while (p.y < 0) {
- p.y += h;
- }
- while (p.y > h) {
- p.y -= h;
- }
- p.x = p.x >> 0;
- p.y = p.y >> 0;
- return p;
- };
- HeatmapOverlay.prototype._moveendHandler = function(e) {
- this.setDataSet(this._data);
- delete this._data;
- this._map.removeEventListener("moveend", this._moveendHandler);
- };
- HeatmapOverlay.prototype.setDataSet = function(data) {
- if (!this._map) {
- return;
- }
- var currentBounds = this._map.getBounds();
- var ne = this._map.pointToOverlayPixel(currentBounds.getNorthEast()), sw = this._map.pointToOverlayPixel(currentBounds.getSouthWest());
- if (!ne || !sw) {
- this._data = data;
- this._map.addEventListener("moveend", this._moveendHandler);
- }
- var mapdata = {
- max: data.max,
- data: []
- };
- var d = data.data, dlen = d.length;
- this.latlngs = [];
- while (dlen--) {
- var latlng = new BMap.Point(d[dlen].lng, d[dlen].lat);
- this.latlngs.push({
- latlng,
- c: d[dlen].count
- });
- if (!currentBounds.containsPoint(latlng)) {
- continue;
- }
- 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);
- var point = this.pixelTransform(screenPixel);
- mapdata.data.push({
- x: point.x,
- y: point.y,
- count: d[dlen].count
- });
- }
- this.heatmap.clear();
- this.heatmap.store.setDataSet(mapdata);
- };
- HeatmapOverlay.prototype.addDataPoint = function(lng, lat, count) {
- var latlng = new BMap.Point(lng, lat), point = this.pixelTransform(this._map.pointToOverlayPixel(latlng));
- this.heatmap.store.addDataPoint(point.x, point.y, count);
- this.latlngs.push({
- latlng,
- c: count
- });
- };
- HeatmapOverlay.prototype.toggle = function() {
- this.heatmap.toggleDisplay();
- };
- return HeatmapOverlay;
- });
- })(bmaplib_heatmap);
- var Heatmap = bmaplib_heatmap.exports;
- var _sfc_main$1 = {
- name: "bml-heatmap",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- data: {
- type: Array,
- default: Array
- },
- max: {
- type: Number
- },
- radius: {
- type: Number
- },
- gradient: {
- type: Object
- },
- opacity: {
- type: Number
- }
- },
- watch: {
- data: {
- handler() {
- this.reload();
- },
- deep: true
- },
- max() {
- this.reload();
- },
- radius(val) {
- const { originInstance, opacity, gradient } = this;
- originInstance.setOptions({
- radius: val,
- opacity,
- gradient
- });
- },
- gradient: {
- handler(val) {
- const { originInstance, radius, opacity } = this;
- originInstance.setOptions({
- radius,
- opacity,
- gradient: val
- });
- },
- deep: true
- },
- opacity(val) {
- const { originInstance, radius, gradient } = this;
- originInstance.setOptions({
- radius,
- opacity: val,
- gradient
- });
- }
- },
- methods: {
- load() {
- const { map, data, max, radius, opacity, gradient } = this;
- const overlay = this.originInstance = new Heatmap({
- radius,
- opacity,
- gradient
- });
- map.addOverlay(overlay);
- overlay.setDataSet({ data, max });
- }
- }
- };
- var bmaplib_curveline = { exports: {} };
- (function(module, exports) {
- (function(root, factory) {
- {
- module.exports = factory();
- }
- })(commonjsGlobal, function() {
- function CurveLine2(points, opts) {
- try {
- BMap;
- } catch (e) {
- throw Error("Baidu Map JS API is not ready yet!");
- }
- var curvePoints = getCurvePoints(points);
- var polyline = new BMap.Polyline(curvePoints, opts);
- polyline.addEventListener("lineupdate", function() {
- if (this.isEditing) {
- this.enableEditing();
- }
- });
- polyline.cornerPoints = points;
- polyline.editMarkers = [];
- polyline.enableEditing = function() {
- var self2 = this;
- if (self2.map) {
- self2.disableEditing();
- for (var i = 0; i < self2.cornerPoints.length; i++) {
- var marker = new BMap.Marker(self2.cornerPoints[i], {
- icon: new BMap.Icon("http://api.map.baidu.com/library/CurveLine/1.5/src/circle.png", new BMap.Size(16, 16)),
- enableDragging: true,
- raiseOnDrag: true
- });
- marker.addEventListener("dragend", function() {
- self2.cornerPoints.length = 0;
- for (var i2 = 0; i2 < self2.editMarkers.length; i2++) {
- self2.cornerPoints.push(self2.editMarkers[i2].getPosition());
- }
- var curvePoints2 = getCurvePoints(self2.cornerPoints);
- self2.setPath(curvePoints2);
- });
- marker.index = i;
- self2.editMarkers.push(marker);
- self2.map.addOverlay(marker);
- }
- }
- self2.isEditing = true;
- };
- polyline.disableEditing = function() {
- this.isEditing = false;
- for (var i = 0; i < this.editMarkers.length; i++) {
- this.map.removeOverlay(this.editMarkers[i]);
- this.editMarkers[i] = null;
- }
- this.editMarkers.length = 0;
- };
- polyline.getPath = function() {
- return curvePoints;
- };
- return polyline;
- }
- function getCurvePoints(points) {
- var curvePoints = [];
- for (var i = 0; i < points.length - 1; i++) {
- var p = getCurveByTwoPoints(points[i], points[i + 1]);
- if (p && p.length > 0) {
- curvePoints = curvePoints.concat(p);
- }
- }
- return curvePoints;
- }
- function getCurveByTwoPoints(obj1, obj2) {
- var curveCoordinates = [];
- if (!obj1 || !obj2 || !(obj1 instanceof BMap.Point) || !(obj2 instanceof BMap.Point)) {
- return null;
- }
- var B1 = function(x) {
- return 1 - 2 * x + x * x;
- };
- var B2 = function(x) {
- return 2 * x - 2 * x * x;
- };
- var B3 = function(x) {
- return x * x;
- };
- var count = 30;
- var t, h, h2, lat3, lng3, t2;
- var i = 0;
- var inc = 0;
- if (typeof obj2 == "undefined") {
- if (typeof curveCoordinates != "undefined") {
- curveCoordinates = [];
- }
- return;
- }
- var lat1 = parseFloat(obj1.lat);
- var lat2 = parseFloat(obj2.lat);
- var lng1 = parseFloat(obj1.lng);
- var lng2 = parseFloat(obj2.lng);
- if (lng2 > lng1) {
- if (parseFloat(lng2 - lng1) > 180) {
- if (lng1 < 0) {
- lng1 = parseFloat(180 + 180 + lng1);
- }
- }
- }
- if (lng1 > lng2) {
- if (parseFloat(lng1 - lng2) > 180) {
- if (lng2 < 0) {
- lng2 = parseFloat(180 + 180 + lng2);
- }
- }
- }
- t2 = 0;
- if (lat2 == lat1) {
- t = 0;
- h = lng1 - lng2;
- } else if (lng2 == lng1) {
- t = Math.PI / 2;
- h = lat1 - lat2;
- } else {
- t = Math.atan((lat2 - lat1) / (lng2 - lng1));
- h = (lat2 - lat1) / Math.sin(t);
- }
- if (t2 == 0) {
- t2 = t + Math.PI / 5;
- }
- h2 = h / 2;
- lng3 = h2 * Math.cos(t2) + lng1;
- lat3 = h2 * Math.sin(t2) + lat1;
- for (i = 0; i < count + 1; i++) {
- curveCoordinates.push(new BMap.Point(lng1 * B1(inc) + lng3 * B2(inc) + lng2 * B3(inc), lat1 * B1(inc) + lat3 * B2(inc) + lat2 * B3(inc)));
- inc = inc + 1 / count;
- }
- return curveCoordinates;
- }
- return CurveLine2;
- });
- })(bmaplib_curveline);
- var CurveLine = bmaplib_curveline.exports;
- var eventList = [
- "click",
- "dblclick",
- "mousedown",
- "mouseup",
- "mouseout",
- "mouseover",
- "remove",
- "lineupdate"
- ];
- var _sfc_main = {
- name: "bml-curve-line",
- render() {
- },
- mixins: [commonMixin("overlay")],
- props: {
- points: {
- type: Array,
- default: Array
- },
- strokeColor: {
- type: String
- },
- strokeWeight: {
- type: Number
- },
- strokeOpacity: {
- type: Number
- },
- strokeStyle: {
- type: String
- },
- massClear: {
- type: Boolean,
- default: true
- },
- clicking: {
- type: Boolean,
- default: true
- },
- editing: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- points: {
- handler(val, oldVal) {
- this.originInstance.disableEditing();
- this.reload();
- },
- deep: true
- },
- strokeColor(val) {
- this.originInstance.setStrokeColor(val);
- },
- strokeOpacity(val) {
- this.originInstance.setStrokeOpacity(val);
- },
- strokeWeight(val) {
- this.originInstance.setStrokeWeight(val);
- },
- strokeStyle(val) {
- this.originInstance.setStrokeStyle(val);
- },
- editing(val) {
- val ? this.originInstance.enableEditing() : this.originInstance.disableEditing();
- },
- massClear(val) {
- val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear();
- },
- clicking(val) {
- this.reload();
- }
- },
- methods: {
- load() {
- const { BMap: BMap2, map, points, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking } = this;
- const overlay = new CurveLine(points.map((item) => createPoint(BMap2, item)), {
- strokeColor,
- strokeWeight,
- strokeOpacity,
- strokeStyle,
- enableMassClear: massClear,
- enableClicking: clicking
- });
- editing ? overlay.enableEditing() : overlay.disableEditing();
- this.originInstance = overlay;
- map.addOverlay(overlay);
- bindEvents.call(this, overlay, eventList);
- }
- }
- };
- var useMap = () => {
- return new Promise((resolve) => {
- getBMap().then((BMap2) => {
- resolve(BMap2);
- });
- });
- };
- var geocoder;
- var useGeocoder = () => {
- return new Promise((resolve) => {
- if (geocoder) {
- resolve(geocoder);
- } else {
- useMap().then((BMap2) => {
- geocoder = new BMap2.Geocoder();
- resolve(geocoder);
- });
- }
- });
- };
- var usePoint = (lng, lat) => {
- return new Promise((resolve) => {
- useMap().then((BMap2) => {
- const point = new BMap2.Point(lng, lat);
- resolve(point);
- });
- });
- };
- var index = {
- install(Vue, options = {}) {
- setConfig(options);
- Vue.component("baidu-map", BaiduMap);
- Vue.component("bm-scale", _sfc_main$w);
- Vue.component("bm-navigation", _sfc_main$v);
- Vue.component("bm-map-type", _sfc_main$u);
- Vue.component("bm-overview-map", _sfc_main$t);
- Vue.component("bm-geolocation", _sfc_main$s);
- Vue.component("bm-copyright", _sfc_main$r);
- Vue.component("bm-city-list", _sfc_main$q);
- Vue.component("bm-panorama", _sfc_main$p);
- Vue.component("bm-control", BmControl);
- Vue.component("bm-marker", BmMarker);
- Vue.component("bm-point-collection", _sfc_main$m);
- Vue.component("bm-polyline", _sfc_main$l);
- Vue.component("bm-polygon", _sfc_main$k);
- Vue.component("bm-circle", _sfc_main$j);
- Vue.component("bm-ground", _sfc_main$i);
- Vue.component("bm-label", _sfc_main$h);
- Vue.component("bm-info-window", BmInfoWindow);
- Vue.component("bm-overlay", BmOverlay);
- Vue.component("bm-context-menu", BmContextMenu);
- Vue.component("bm-context-menu-item", BmContextMenuItem);
- Vue.component("bm-local-search", BmLocalSearch);
- Vue.component("bm-transit", BmTransit);
- Vue.component("bm-walking", BmWalking);
- Vue.component("bm-driving", BmDriving);
- Vue.component("bm-bus", BmBus);
- Vue.component("bm-tile", _sfc_main$7);
- Vue.component("bm-traffic", _sfc_main$6);
- Vue.component("bm-auto-complete", BmAutoComplete);
- Vue.component("bm-boundary", BmBoundary);
- }
- };
- export {
- BaiduMap,
- BmAutoComplete,
- BmBoundary,
- BmBus,
- _sfc_main$j as BmCircle,
- _sfc_main$q as BmCityList,
- BmContextMenu,
- BmContextMenuItem,
- BmControl,
- _sfc_main$r as BmCopyright,
- BmDriving,
- _sfc_main$s as BmGeolocation,
- _sfc_main$i as BmGround,
- BmInfoWindow,
- _sfc_main$h as BmLabel,
- BmLocalSearch,
- _sfc_main$u as BmMapType,
- BmMarker,
- _sfc_main$v as BmNavigation,
- BmOverlay,
- _sfc_main$t as BmOverviewMap,
- _sfc_main$p as BmPanorama,
- _sfc_main$m as BmPointCollection,
- _sfc_main$k as BmPolygon,
- _sfc_main$l as BmPolyline,
- _sfc_main$w as BmScale,
- _sfc_main$7 as BmTile,
- _sfc_main$6 as BmTraffic,
- BmTransit,
- BmWalking,
- _sfc_main as BmlCurveLine,
- _sfc_main$1 as BmlHeatmap,
- _sfc_main$2 as BmlLushu,
- MarkerClusterer as BmlMarkerClusterer,
- index as default,
- getAddressByPoints,
- getConfig,
- getPointByAddress,
- getPointsTransfer,
- useGeocoder,
- useMap,
- usePoint
- };
- //# sourceMappingURL=vue-baidu-map-3x.js.map
|