6adbde96a970e31ffa378fe2ae7fb0ae2c482032.svn-base 183 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970
  1. var pi = Math.PI / 180;
  2. function toRadian(d) {
  3. return d * pi;
  4. }
  5. function wrap(n, min, max) {
  6. if (n === max || n === min) {
  7. return n;
  8. }
  9. var d = max - min;
  10. var w = ((n - min) % d + d) % d + min;
  11. return w;
  12. }
  13. function isString(obj) {
  14. if (isNil(obj)) {
  15. return false;
  16. }
  17. return typeof obj === 'string' || obj.constructor !== null && obj.constructor === String;
  18. }
  19. function isInteger(n) {
  20. return (n | 0) === n;
  21. }
  22. var hasOwnProperty = Object.prototype.hasOwnProperty;
  23. function hasOwn(obj, key) {
  24. return hasOwnProperty.call(obj, key);
  25. }
  26. function extend(dest) {
  27. for (var i = 1; i < arguments.length; i++) {
  28. var src = arguments[i];
  29. for (var k in src) {
  30. dest[k] = src[k];
  31. }
  32. }
  33. return dest;
  34. }
  35. function parseJSON(str) {
  36. if (!str || !isString(str)) {
  37. return str;
  38. }
  39. return JSON.parse(str);
  40. }
  41. function pushIn(dest) {
  42. for (var i = 1; i < arguments.length; i++) {
  43. var src = arguments[i];
  44. if (src) {
  45. for (var ii = 0, ll = src.length; ii < ll; ii++) {
  46. dest.push(src[ii]);
  47. }
  48. }
  49. }
  50. return dest.length;
  51. }
  52. function isNil(obj) {
  53. return obj == null;
  54. }
  55. function isArrayHasData(obj) {
  56. return Array.isArray(obj) && obj.length > 0;
  57. }
  58. function _inheritsLoose(subClass, superClass) {
  59. subClass.prototype = superClass ? Object.create(superClass.prototype) : {};
  60. subClass.prototype.constructor = subClass;
  61. subClass.__proto__ = superClass;
  62. }
  63. function isNumber(val) {
  64. return typeof val === 'number' && !isNaN(val);
  65. }
  66. function isObject(obj) {
  67. return typeof obj === 'object' && !!obj;
  68. }
  69. function isFunction(obj) {
  70. if (isNil(obj)) {
  71. return false;
  72. }
  73. return typeof obj === 'function' || obj.constructor !== null && obj.constructor === Function;
  74. }
  75. var Common = {
  76. project: function project() { },
  77. unproject: function unproject() { },
  78. projectCoords: function projectCoords(coordinates) {
  79. var _this = this;
  80. if (!coordinates) {
  81. return [];
  82. }
  83. if (!Array.isArray(coordinates)) {
  84. return this.project(coordinates);
  85. }
  86. if (coordinates.length === 0) {
  87. return [];
  88. }
  89. if (!this.isSphere()) {
  90. return forEachCoord(coordinates, this.project, this);
  91. }
  92. if (Array.isArray(coordinates[0])) {
  93. return coordinates.map(function (coords) {
  94. return _this.projectCoords(coords);
  95. });
  96. } else {
  97. var circum = this.getCircum();
  98. var extent = this.getSphereExtent(),
  99. sx = extent.sx,
  100. sy = extent.sy;
  101. var wrapX, wrapY;
  102. var pre = coordinates[0],
  103. current,
  104. dx,
  105. dy,
  106. p;
  107. var prj = [this.project(pre)];
  108. for (var i = 1, l = coordinates.length; i < l; i++) {
  109. current = coordinates[i];
  110. dx = current.x - pre.x;
  111. dy = current.y - pre.y;
  112. p = this.project(current);
  113. if (Math.abs(dx) > 180) {
  114. if (wrapX === undefined) {
  115. wrapX = current.x < pre.x;
  116. }
  117. if (wrapX) {
  118. p._add(-circum.x * sign(dx) * sx, 0);
  119. current._add(-360 * sign(dx), 0);
  120. }
  121. }
  122. if (Math.abs(dy) > 90) {
  123. if (wrapY === undefined) {
  124. wrapY = current.y < pre.y;
  125. }
  126. if (wrapY) {
  127. p._add(0, -circum.y * sign(dy) * sy);
  128. current._add(0, -180 * sign(dy));
  129. }
  130. }
  131. pre = current;
  132. prj.push(p);
  133. }
  134. return prj;
  135. }
  136. },
  137. unprojectCoords: function unprojectCoords(projCoords) {
  138. if (!projCoords) {
  139. return [];
  140. }
  141. if (!Array.isArray(projCoords)) {
  142. return this.unproject(projCoords);
  143. }
  144. return forEachCoord(projCoords, this.unproject, this);
  145. },
  146. isSphere: function isSphere() {
  147. return !!this.sphere;
  148. },
  149. isOutSphere: function isOutSphere(pcoord) {
  150. if (!this.isSphere()) {
  151. return false;
  152. }
  153. var extent = this.getSphereExtent();
  154. return !extent.contains(pcoord);
  155. },
  156. wrapCoord: function wrapCoord(pcoord) {
  157. if (!this.isSphere()) {
  158. return pcoord;
  159. }
  160. var extent = this.getSphereExtent();
  161. var wrapped = new Coordinate(pcoord);
  162. if (!extent.contains(wrapped)) {
  163. wrapped.x = wrap(pcoord.x, extent.xmin, extent.xmax);
  164. wrapped.y = wrap(pcoord.y, extent.ymin, extent.ymax);
  165. }
  166. return wrapped;
  167. },
  168. getCircum: function getCircum() {
  169. if (!this.circum && this.isSphere()) {
  170. var extent = this.getSphereExtent();
  171. this.circum = {
  172. x: extent.getWidth(),
  173. y: extent.getHeight()
  174. };
  175. }
  176. return this.circum;
  177. },
  178. getSphereExtent: function getSphereExtent() {
  179. if (!this.extent && this.isSphere()) {
  180. var max = this.project(new Coordinate(180, 90)),
  181. min = this.project(new Coordinate(-180, -90));
  182. this.extent = new Extent(min, max, this);
  183. this.extent.sx = max.x > min.x ? 1 : -1;
  184. this.extent.sy = max.y > min.y ? 1 : -1;
  185. }
  186. return this.extent;
  187. }
  188. };
  189. var Common$1 = {
  190. measureLength: function measureLength(c1, c2) {
  191. if (!Array.isArray(c1)) {
  192. return this.measureLenBetween(c1, c2);
  193. }
  194. var len = 0;
  195. for (var i = 0, l = c1.length; i < l - 1; i++) {
  196. len += this.measureLenBetween(c1[i], c1[i + 1]);
  197. }
  198. return len;
  199. }
  200. };
  201. var types = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
  202. function createFilter(filter) {
  203. return new Function('f', "var p = (f && f.properties || {}); return " + compile(filter));
  204. }
  205. function compile(filter) {
  206. if (!filter) return 'true';
  207. var op = filter[0];
  208. if (filter.length <= 1) return op === 'any' ? 'false' : 'true';
  209. var str = op === '==' ? compileComparisonOp(filter[1], filter[2], '===', false) : op === '!=' ? compileComparisonOp(filter[1], filter[2], '!==', false) : op === '<' || op === '>' || op === '<=' || op === '>=' ? compileComparisonOp(filter[1], filter[2], op, true) : op === 'any' ? compileLogicalOp(filter.slice(1), '||') : op === 'all' ? compileLogicalOp(filter.slice(1), '&&') : op === 'none' ? compileNegation(compileLogicalOp(filter.slice(1), '||')) : op === 'in' ? compileInOp(filter[1], filter.slice(2)) : op === '!in' ? compileNegation(compileInOp(filter[1], filter.slice(2))) : op === 'has' ? compileHasOp(filter[1]) : op === '!has' ? compileNegation(compileHasOp(filter[1])) : 'true';
  210. return "(" + str + ")";
  211. }
  212. function compilePropertyReference(property) {
  213. return property[0] === '$' ? 'f.' + property.substring(1) : 'p[' + JSON.stringify(property) + ']';
  214. }
  215. function compileComparisonOp(property, value, op, checkType) {
  216. var left = compilePropertyReference(property);
  217. var right = property === '$type' ? types.indexOf(value) : JSON.stringify(value);
  218. return (checkType ? "typeof " + left + "=== typeof " + right + "&&" : '') + left + op + right;
  219. }
  220. function getFilterFeature(geometry) {
  221. var json = geometry._toJSON(),
  222. g = json['feature'];
  223. g['type'] = types.indexOf(g['geometry']['type']);
  224. g['subType'] = json['subType'];
  225. return g;
  226. }
  227. var Sphere = function () {
  228. function Sphere(radius) {
  229. this.radius = radius;
  230. }
  231. var _proto = Sphere.prototype;
  232. _proto.measureLenBetween = function measureLenBetween(c1, c2) {
  233. if (!c1 || !c2) {
  234. return 0;
  235. }
  236. var b = toRadian(c1.y);
  237. var d = toRadian(c2.y),
  238. e = b - d,
  239. f = toRadian(c1.x) - toRadian(c2.x);
  240. b = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(e / 2), 2) + Math.cos(b) * Math.cos(d) * Math.pow(Math.sin(f / 2), 2)));
  241. b *= this.radius;
  242. return Math.round(b * 1E5) / 1E5;
  243. };
  244. _proto.measureArea = function measureArea(coordinates) {
  245. var a = toRadian(this.radius);
  246. var b = 0,
  247. c = coordinates,
  248. d = c.length;
  249. if (d < 3) {
  250. return 0;
  251. }
  252. var i;
  253. for (i = 0; i < d - 1; i++) {
  254. var e = c[i],
  255. f = c[i + 1];
  256. b += e.x * a * Math.cos(toRadian(e.y)) * f.y * a - f.x * a * Math.cos(toRadian(f.y)) * e.y * a;
  257. }
  258. d = c[i];
  259. c = c[0];
  260. b += d.x * a * Math.cos(toRadian(d.y)) * c.y * a - c.x * a * Math.cos(toRadian(c.y)) * d.y * a;
  261. return 0.5 * Math.abs(b);
  262. };
  263. _proto.locate = function locate(c, xDist, yDist) {
  264. c = new Coordinate(c.x, c.y);
  265. return this._locate(c, xDist, yDist);
  266. };
  267. _proto._locate = function _locate(c, xDist, yDist) {
  268. if (!c) {
  269. return null;
  270. }
  271. if (!xDist) {
  272. xDist = 0;
  273. }
  274. if (!yDist) {
  275. yDist = 0;
  276. }
  277. if (!xDist && !yDist) {
  278. return c;
  279. }
  280. var x, y;
  281. var ry = toRadian(c.y);
  282. if (yDist !== 0) {
  283. var dy = Math.abs(yDist);
  284. var sy = Math.sin(dy / (2 * this.radius)) * 2;
  285. ry = ry + sy * (yDist > 0 ? 1 : -1);
  286. y = wrap(ry * 180 / Math.PI, -90, 90);
  287. } else {
  288. y = c.y;
  289. }
  290. if (xDist !== 0) {
  291. var dx = Math.abs(xDist);
  292. var rx = toRadian(c.x);
  293. var sx = 2 * Math.sqrt(Math.pow(Math.sin(dx / (2 * this.radius)), 2) / Math.pow(Math.cos(ry), 2));
  294. rx = rx + sx * (xDist > 0 ? 1 : -1);
  295. x = wrap(rx * 180 / Math.PI, -180, 180);
  296. } else {
  297. x = c.x;
  298. }
  299. c.x = x;
  300. c.y = y;
  301. return c;
  302. };
  303. _proto.rotate = function rotate(c, pivot, angle) {
  304. c = new Coordinate(c);
  305. return this._rotate(c, pivot, angle);
  306. };
  307. _proto._rotate = function _rotate(c, pivot, angle) {
  308. var initialAngle = rhumbBearing(pivot, c);
  309. var finalAngle = initialAngle - angle;
  310. var distance = this.measureLenBetween(pivot, c);
  311. c.x = pivot.x;
  312. c.y = pivot.y;
  313. return calculateRhumbDestination(c, distance, finalAngle, this.radius);
  314. };
  315. return Sphere;
  316. }();
  317. var WGS84Sphere = extend({
  318. 'measure': 'EPSG:4326',
  319. sphere: new Sphere(6378137),
  320. measureLenBetween: function measureLenBetween() {
  321. return this.sphere.measureLenBetween.apply(this.sphere, arguments);
  322. },
  323. measureArea: function measureArea() {
  324. return this.sphere.measureArea.apply(this.sphere, arguments);
  325. },
  326. _locate: function _locate() {
  327. return this.sphere._locate.apply(this.sphere, arguments);
  328. },
  329. locate: function locate() {
  330. return this.sphere.locate.apply(this.sphere, arguments);
  331. },
  332. _rotate: function _rotate() {
  333. return this.sphere._rotate.apply(this.sphere, arguments);
  334. },
  335. rotate: function rotate() {
  336. return this.sphere.rotate.apply(this.sphere, arguments);
  337. }
  338. }, Common$1);
  339. var BaiduSphere = extend({
  340. 'measure': 'BAIDU',
  341. sphere: new Sphere(6370996.81),
  342. measureLenBetween: function measureLenBetween() {
  343. return this.sphere.measureLenBetween.apply(this.sphere, arguments);
  344. },
  345. measureArea: function measureArea() {
  346. return this.sphere.measureArea.apply(this.sphere, arguments);
  347. },
  348. _locate: function _locate() {
  349. return this.sphere._locate.apply(this.sphere, arguments);
  350. },
  351. locate: function locate() {
  352. return this.sphere.locate.apply(this.sphere, arguments);
  353. },
  354. _rotate: function _rotate() {
  355. return this.sphere._rotate.apply(this.sphere, arguments);
  356. },
  357. rotate: function rotate() {
  358. return this.sphere.rotate.apply(this.sphere, arguments);
  359. }
  360. }, Common$1);
  361. var DEFAULT = WGS84Sphere;
  362. var EPSG3857 = extend({}, Common, {
  363. code: 'EPSG:3857',
  364. rad: Math.PI / 180,
  365. metersPerDegree: 6378137 * Math.PI / 180,
  366. maxLatitude: 85.0511287798,
  367. project: function project(lnglat) {
  368. var rad = this.rad,
  369. metersPerDegree = this.metersPerDegree,
  370. max = this.maxLatitude;
  371. var lng = lnglat.x,
  372. lat = Math.max(Math.min(max, lnglat.y), -max);
  373. var c;
  374. if (lat === 0) {
  375. c = 0;
  376. } else {
  377. c = Math.log(Math.tan((90 + lat) * rad / 2)) / rad;
  378. }
  379. return new Coordinate(lng * metersPerDegree, c * metersPerDegree);
  380. },
  381. unproject: function unproject(pLnglat) {
  382. var x = pLnglat.x,
  383. y = pLnglat.y;
  384. var rad = this.rad,
  385. metersPerDegree = this.metersPerDegree;
  386. var c;
  387. if (y === 0) {
  388. c = 0;
  389. } else {
  390. c = y / metersPerDegree;
  391. c = (2 * Math.atan(Math.exp(c * rad)) - Math.PI / 2) / rad;
  392. }
  393. return new Coordinate(wrap(x / metersPerDegree, -180, 180), wrap(c, -this.maxLatitude, this.maxLatitude));
  394. }
  395. }, WGS84Sphere);
  396. var PROJ4326 = extend({}, Common, {
  397. code: 'EPSG:4326',
  398. project: function project(p) {
  399. return new Coordinate(p);
  400. },
  401. unproject: function unproject(p) {
  402. return new Coordinate(p);
  403. }
  404. }, WGS84Sphere);
  405. var DEFAULT$1 = EPSG3857;
  406. var Projection_EPSG4490 = extend({}, PROJ4326, {
  407. code: 'EPSG:4490'
  408. });
  409. var Projection_Baidu = extend({}, Common, {
  410. code: 'BAIDU',
  411. project: function project(p) {
  412. return this.convertLL2MC(p);
  413. },
  414. unproject: function unproject(p) {
  415. return this.convertMC2LL(p);
  416. }
  417. }, BaiduSphere, {
  418. EARTHRADIUS: 6370996.81,
  419. MCBAND: [12890594.86, 8362377.87, 5591021, 3481989.83, 1678043.12, 0],
  420. LLBAND: [75, 60, 45, 30, 15, 0],
  421. MC2LL: [[1.410526172116255e-8, 0.00000898305509648872, -1.9939833816331, 200.9824383106796, -187.2403703815547, 91.6087516669843, -23.38765649603339, 2.57121317296198, -0.03801003308653, 17337981.2], [-7.435856389565537e-9, 0.000008983055097726239, -0.78625201886289, 96.32687599759846, -1.85204757529826, -59.36935905485877, 47.40033549296737, -16.50741931063887, 2.28786674699375, 10260144.86], [-3.030883460898826e-8, 0.00000898305509983578, 0.30071316287616, 59.74293618442277, 7.357984074871, -25.38371002664745, 13.45380521110908, -3.29883767235584, 0.32710905363475, 6856817.37], [-1.981981304930552e-8, 0.000008983055099779535, 0.03278182852591, 40.31678527705744, 0.65659298677277, -4.44255534477492, 0.85341911805263, 0.12923347998204, -0.04625736007561, 4482777.06], [3.09191371068437e-9, 0.000008983055096812155, 0.00006995724062, 23.10934304144901, -0.00023663490511, -0.6321817810242, -0.00663494467273, 0.03430082397953, -0.00466043876332, 2555164.4], [2.890871144776878e-9, 0.000008983055095805407, -3.068298e-8, 7.47137025468032, -0.00000353937994, -0.02145144861037, -0.00001234426596, 0.00010322952773, -0.00000323890364, 826088.5]],
  422. LL2MC: [[-0.0015702102444, 111320.7020616939, 1704480524535203, -10338987376042340, 26112667856603880, -35149669176653700, 26595700718403920, -10725012454188240, 1800819912950474, 82.5], [0.0008277824516172526, 111320.7020463578, 647795574.6671607, -4082003173.641316, 10774905663.51142, -15171875531.51559, 12053065338.62167, -5124939663.577472, 913311935.9512032, 67.5], [0.00337398766765, 111320.7020202162, 4481351.045890365, -23393751.19931662, 79682215.47186455, -115964993.2797253, 97236711.15602145, -43661946.33752821, 8477230.501135234, 52.5], [0.00220636496208, 111320.7020209128, 51751.86112841131, 3796837.749470245, 992013.7397791013, -1221952.21711287, 1340652.697009075, -620943.6990984312, 144416.9293806241, 37.5], [-0.0003441963504368392, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5], [-0.0003218135878613132, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292, 1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45]],
  423. convertMC2LL: function convertMC2LL(cB) {
  424. var cC = {
  425. x: Math.abs(cB.x),
  426. y: Math.abs(cB.y)
  427. };
  428. var cE;
  429. for (var cD = 0, len = this.MCBAND.length; cD < len; cD++) {
  430. if (cC.y >= this.MCBAND[cD]) {
  431. cE = this.MC2LL[cD];
  432. break;
  433. }
  434. }
  435. var T = this.convertor(cB, cE);
  436. var result = new Coordinate(T.x, T.y);
  437. return result;
  438. },
  439. convertLL2MC: function convertLL2MC(T) {
  440. var cD, cC, len;
  441. T.x = this.getLoop(T.x, -180, 180);
  442. T.y = this.getRange(T.y, -74, 74);
  443. var cB = new Coordinate(T.x, T.y);
  444. for (cC = 0, len = this.LLBAND.length; cC < len; cC++) {
  445. if (cB.y >= this.LLBAND[cC]) {
  446. cD = this.LL2MC[cC];
  447. break;
  448. }
  449. }
  450. if (!cD) {
  451. for (cC = this.LLBAND.length - 1; cC >= 0; cC--) {
  452. if (cB.y <= -this.LLBAND[cC]) {
  453. cD = this.LL2MC[cC];
  454. break;
  455. }
  456. }
  457. }
  458. var cE = this.convertor(T, cD);
  459. var result = new Coordinate(cE.x, cE.y);
  460. return result;
  461. },
  462. convertor: function convertor(cC, cD) {
  463. if (!cC || !cD) {
  464. return null;
  465. }
  466. var T = cD[0] + cD[1] * Math.abs(cC.x);
  467. var cB = Math.abs(cC.y) / cD[9];
  468. var cE = cD[2] + cD[3] * cB + cD[4] * cB * cB + cD[5] * cB * cB * cB + cD[6] * cB * cB * cB * cB + cD[7] * cB * cB * cB * cB * cB + cD[8] * cB * cB * cB * cB * cB * cB;
  469. T *= cC.x < 0 ? -1 : 1;
  470. cE *= cC.y < 0 ? -1 : 1;
  471. return new Coordinate(T, cE);
  472. },
  473. toRadians: function toRadians(T) {
  474. return Math.PI * T / 180;
  475. },
  476. toDegrees: function toDegrees(T) {
  477. return 180 * T / Math.PI;
  478. },
  479. getRange: function getRange(cC, cB, T) {
  480. if (cB != null) {
  481. cC = Math.max(cC, cB);
  482. }
  483. if (T != null) {
  484. cC = Math.min(cC, T);
  485. }
  486. return cC;
  487. },
  488. getLoop: function getLoop(cC, cB, T) {
  489. while (cC > T) {
  490. cC -= T - cB;
  491. }
  492. while (cC < cB) {
  493. cC += T - cB;
  494. }
  495. return cC;
  496. }
  497. });
  498. var Projection_IDENTITY = extend({}, Common, {
  499. code: 'IDENTITY',
  500. project: function project(p) {
  501. return p.copy();
  502. },
  503. unproject: function unproject(p) {
  504. return p.copy();
  505. }
  506. }, Identity);
  507. var projections = /*#__PURE__*/Object.freeze({
  508. EPSG3857: EPSG3857,
  509. DEFAULT: DEFAULT$1,
  510. EPSG4326: PROJ4326,
  511. EPSG4490: Projection_EPSG4490,
  512. BAIDU: Projection_Baidu,
  513. IDENTITY: Projection_IDENTITY,
  514. Common: Common
  515. });
  516. var SpatialReference = function () {
  517. function SpatialReference(options) {
  518. if (options === void 0) {
  519. options = {};
  520. }
  521. this.options = options;
  522. this._initSpatialRef();
  523. }
  524. SpatialReference.getProjectionInstance = function getProjectionInstance(prjName) {
  525. if (!prjName) {
  526. return null;
  527. }
  528. if (isObject(prjName)) {
  529. return prjName;
  530. }
  531. prjName = (prjName + '').toLowerCase();
  532. for (var p in projections) {
  533. if (hasOwn(projections, p)) {
  534. var code = projections[p]['code'];
  535. if (code && code.toLowerCase() === prjName) {
  536. return projections[p];
  537. }
  538. }
  539. }
  540. return null;
  541. };
  542. SpatialReference.equals = function equals(sp1, sp2) {
  543. if (!sp1 && !sp2) {
  544. return true;
  545. } else if (!sp1 || !sp2) {
  546. return false;
  547. }
  548. if (sp1.projection !== sp2.projection) {
  549. return false;
  550. }
  551. var f1 = sp1.fullExtent,
  552. f2 = sp2.fullExtent;
  553. if (f1 && f2) {
  554. if (f1.top !== f2.top || f1.bottom !== f2.bottom || f1.left !== f2.left || f1.right !== f2.right) {
  555. return false;
  556. }
  557. }
  558. var r1 = sp1.resolutions,
  559. r2 = sp2.resolutions;
  560. if (r1 && r2) {
  561. if (r1.length !== r2.length) {
  562. return false;
  563. }
  564. for (var i = 0; i < r1.length; i++) {
  565. if (r1[i] !== r2[i]) {
  566. return false;
  567. }
  568. }
  569. }
  570. return true;
  571. };
  572. var _proto = SpatialReference.prototype;
  573. _proto._initSpatialRef = function _initSpatialRef() {
  574. var projection = this.options['projection'];
  575. if (projection) {
  576. projection = SpatialReference.getProjectionInstance(projection);
  577. } else {
  578. projection = DEFAULT$1;
  579. }
  580. if (!projection) {
  581. throw new Error('must provide a valid projection in map\'s spatial reference.');
  582. }
  583. projection = extend({}, Common, projection);
  584. if (!projection.measureLength) {
  585. extend(projection, Measurer.DEFAULT);
  586. }
  587. this._projection = projection;
  588. var defaultSpatialRef,
  589. resolutions = this.options['resolutions'];
  590. if (!resolutions) {
  591. if (projection['code']) {
  592. defaultSpatialRef = DefaultSpatialRef[projection['code']];
  593. if (defaultSpatialRef) {
  594. resolutions = defaultSpatialRef['resolutions'];
  595. }
  596. }
  597. if (!resolutions) {
  598. throw new Error('must provide valid resolutions in map\'s spatial reference.');
  599. }
  600. }
  601. this._resolutions = resolutions;
  602. var fullExtent = this.options['fullExtent'];
  603. if (!fullExtent) {
  604. if (projection['code']) {
  605. defaultSpatialRef = DefaultSpatialRef[projection['code']];
  606. if (defaultSpatialRef) {
  607. fullExtent = defaultSpatialRef['fullExtent'];
  608. }
  609. }
  610. if (!fullExtent) {
  611. throw new Error('must provide a valid fullExtent in map\'s spatial reference.');
  612. }
  613. }
  614. if (!isNil(fullExtent['left'])) {
  615. this._fullExtent = new Extent(new Coordinate(fullExtent['left'], fullExtent['top']), new Coordinate(fullExtent['right'], fullExtent['bottom']));
  616. } else {
  617. this._fullExtent = new Extent(fullExtent);
  618. fullExtent['left'] = fullExtent['xmin'];
  619. fullExtent['right'] = fullExtent['xmax'];
  620. fullExtent['top'] = fullExtent['ymax'];
  621. fullExtent['bottom'] = fullExtent['ymin'];
  622. }
  623. if (isNil(fullExtent['top']) || isNil(fullExtent['bottom']) || isNil(fullExtent['left']) || isNil(fullExtent['right'])) {
  624. throw new Error('must provide valid top/bottom/left/right in fullExtent.');
  625. }
  626. extend(this._fullExtent, fullExtent);
  627. this._projection.fullExtent = fullExtent;
  628. var a = fullExtent['right'] >= fullExtent['left'] ? 1 : -1,
  629. b = fullExtent['top'] >= fullExtent['bottom'] ? -1 : 1;
  630. this._transformation = new Transformation([a, b, 0, 0]);
  631. };
  632. _proto.getResolutions = function getResolutions() {
  633. return this._resolutions || [];
  634. };
  635. _proto.getResolution = function getResolution(zoom) {
  636. var z = zoom | 0;
  637. if (z < 0) {
  638. z = 0;
  639. } else if (z > this._resolutions.length - 1) {
  640. z = this._resolutions.length - 1;
  641. }
  642. var res = this._resolutions[z];
  643. if (!isInteger(zoom) && z !== this._resolutions.length - 1) {
  644. var next = this._resolutions[z + 1];
  645. return res + (next - res) * (zoom - z);
  646. }
  647. return res;
  648. };
  649. _proto.getProjection = function getProjection() {
  650. return this._projection;
  651. };
  652. _proto.getFullExtent = function getFullExtent() {
  653. return this._fullExtent;
  654. };
  655. _proto.getTransformation = function getTransformation() {
  656. return this._transformation;
  657. };
  658. _proto.getMinZoom = function getMinZoom() {
  659. for (var i = 0; i < this._resolutions.length; i++) {
  660. if (!isNil(this._resolutions[i])) {
  661. return i;
  662. }
  663. }
  664. return 0;
  665. };
  666. _proto.getMaxZoom = function getMaxZoom() {
  667. for (var i = this._resolutions.length - 1; i >= 0; i--) {
  668. if (!isNil(this._resolutions[i])) {
  669. return i;
  670. }
  671. }
  672. return this._resolutions.length - 1;
  673. };
  674. _proto.getZoomDirection = function getZoomDirection() {
  675. return sign(this._resolutions[this.getMinZoom()] - this._resolutions[this.getMaxZoom()]);
  676. };
  677. _proto.toJSON = function toJSON() {
  678. if (!this.json) {
  679. this.json = {
  680. 'resolutions': this._resolutions,
  681. 'fullExtent': {
  682. 'top': this._fullExtent.top,
  683. 'left': this._fullExtent.left,
  684. 'bottom': this._fullExtent.bottom,
  685. 'right': this._fullExtent.right
  686. },
  687. 'projection': this._projection.code
  688. };
  689. }
  690. return this.json;
  691. };
  692. return SpatialReference;
  693. }();
  694. var Eventable = function Eventable(Base) {
  695. return function (_Base) {
  696. _inheritsLoose(_class, _Base);
  697. function _class() {
  698. return _Base.apply(this, arguments) || this;
  699. }
  700. var _proto = _class.prototype;
  701. _proto.on = function on$$1(eventsOn, handler, context) {
  702. if (!eventsOn) {
  703. return this;
  704. }
  705. if (!isString(eventsOn)) {
  706. return this._switch('on', eventsOn, handler);
  707. }
  708. if (!handler) {
  709. return this;
  710. }
  711. if (!this._eventMap) {
  712. this._eventMap = {};
  713. }
  714. var eventTypes = eventsOn.toLowerCase().split(' ');
  715. var evtType;
  716. if (!context) {
  717. context = this;
  718. }
  719. var handlerChain;
  720. for (var ii = 0, ll = eventTypes.length; ii < ll; ii++) {
  721. evtType = eventTypes[ii];
  722. handlerChain = this._eventMap[evtType];
  723. if (!handlerChain) {
  724. handlerChain = [];
  725. this._eventMap[evtType] = handlerChain;
  726. }
  727. var l = handlerChain.length;
  728. if (l > 0) {
  729. for (var i = 0; i < l; i++) {
  730. if (handler === handlerChain[i].handler && handlerChain[i].context === context) {
  731. return this;
  732. }
  733. }
  734. }
  735. handlerChain.push({
  736. handler: handler,
  737. context: context
  738. });
  739. }
  740. return this;
  741. };
  742. _proto.addEventListener = function addEventListener() {
  743. return this.on.apply(this, arguments);
  744. };
  745. _proto.once = function once(eventTypes, handler, context) {
  746. if (!isString(eventTypes)) {
  747. var once = {};
  748. for (var p in eventTypes) {
  749. if (eventTypes.hasOwnProperty(p)) {
  750. once[p] = this._wrapOnceHandler(p, eventTypes[p], context);
  751. }
  752. }
  753. return this._switch('on', once);
  754. }
  755. var evetTypes = eventTypes.split(' ');
  756. for (var i = 0, l = evetTypes.length; i < l; i++) {
  757. this.on(evetTypes[i], this._wrapOnceHandler(evetTypes[i], handler, context));
  758. }
  759. return this;
  760. };
  761. _proto.off = function off$$1(eventsOff, handler, context) {
  762. if (!this._eventMap || !eventsOff) {
  763. return this;
  764. }
  765. if (!isString(eventsOff)) {
  766. return this._switch('off', eventsOff, handler);
  767. }
  768. if (!handler) {
  769. return this;
  770. }
  771. var eventTypes = eventsOff.split(' ');
  772. var eventType, listeners, wrapKey;
  773. if (!context) {
  774. context = this;
  775. }
  776. for (var j = 0, jl = eventTypes.length; j < jl; j++) {
  777. eventType = eventTypes[j].toLowerCase();
  778. wrapKey = 'Z__' + eventType;
  779. listeners = this._eventMap[eventType];
  780. if (!listeners) {
  781. return this;
  782. }
  783. for (var i = listeners.length - 1; i >= 0; i--) {
  784. var listener = listeners[i];
  785. if ((handler === listener.handler || handler === listener.handler[wrapKey]) && listener.context === context) {
  786. delete listener.handler[wrapKey];
  787. listeners.splice(i, 1);
  788. }
  789. }
  790. }
  791. return this;
  792. };
  793. _proto.removeEventListener = function removeEventListener() {
  794. return this.off.apply(this, arguments);
  795. };
  796. _proto.listens = function listens(eventType, handler, context) {
  797. if (!this._eventMap || !isString(eventType)) {
  798. return 0;
  799. }
  800. var handlerChain = this._eventMap[eventType.toLowerCase()];
  801. if (!handlerChain || !handlerChain.length) {
  802. return 0;
  803. }
  804. var count = 0;
  805. for (var i = 0, len = handlerChain.length; i < len; i++) {
  806. if (handler) {
  807. if (handler === handlerChain[i].handler && (isNil(context) || handlerChain[i].context === context)) {
  808. return 1;
  809. }
  810. } else {
  811. count++;
  812. }
  813. }
  814. return count;
  815. };
  816. _proto.copyEventListeners = function copyEventListeners(target) {
  817. var eventMap = target._eventMap;
  818. if (!eventMap) {
  819. return this;
  820. }
  821. var handlerChain;
  822. for (var eventType in eventMap) {
  823. handlerChain = eventMap[eventType];
  824. for (var i = 0, len = handlerChain.length; i < len; i++) {
  825. this.on(eventType, handlerChain[i].handler, handlerChain[i].context);
  826. }
  827. }
  828. return this;
  829. };
  830. _proto.fire = function fire() {
  831. if (this._eventParent) {
  832. return this._eventParent.fire.apply(this._eventParent, arguments);
  833. }
  834. return this._fire.apply(this, arguments);
  835. };
  836. _proto._wrapOnceHandler = function _wrapOnceHandler(evtType, handler, context) {
  837. var me = this;
  838. var key = 'Z__' + evtType;
  839. var called = false;
  840. var fn = function onceHandler() {
  841. if (called) {
  842. return;
  843. }
  844. delete fn[key];
  845. called = true;
  846. if (context) {
  847. handler.apply(context, arguments);
  848. } else {
  849. handler.apply(this, arguments);
  850. }
  851. me.off(evtType, onceHandler, this);
  852. };
  853. fn[key] = handler;
  854. return fn;
  855. };
  856. _proto._switch = function _switch(to, eventKeys, context) {
  857. for (var p in eventKeys) {
  858. if (eventKeys.hasOwnProperty(p)) {
  859. this[to](p, eventKeys[p], context);
  860. }
  861. }
  862. return this;
  863. };
  864. _proto._clearListeners = function _clearListeners(eventType) {
  865. if (!this._eventMap || !isString(eventType)) {
  866. return;
  867. }
  868. var handlerChain = this._eventMap[eventType.toLowerCase()];
  869. if (!handlerChain) {
  870. return;
  871. }
  872. this._eventMap[eventType] = null;
  873. };
  874. _proto._clearAllListeners = function _clearAllListeners() {
  875. this._eventMap = null;
  876. };
  877. _proto._setEventParent = function _setEventParent(parent) {
  878. this._eventParent = parent;
  879. return this;
  880. };
  881. _proto._fire = function _fire(eventType, param) {
  882. if (!this._eventMap) {
  883. return this;
  884. }
  885. var handlerChain = this._eventMap[eventType.toLowerCase()];
  886. if (!handlerChain) {
  887. return this;
  888. }
  889. if (!param) {
  890. param = {};
  891. }
  892. param['type'] = eventType;
  893. param['target'] = this;
  894. var queue = handlerChain.slice(0);
  895. var context, bubble, passed;
  896. for (var i = 0, len = queue.length; i < len; i++) {
  897. if (!queue[i]) {
  898. continue;
  899. }
  900. context = queue[i].context;
  901. bubble = true;
  902. passed = extend({}, param);
  903. if (context) {
  904. bubble = queue[i].handler.call(context, passed);
  905. } else {
  906. bubble = queue[i].handler(passed);
  907. }
  908. if (bubble === false) {
  909. if (param['domEvent']) {
  910. stopPropagation(param['domEvent']);
  911. }
  912. }
  913. }
  914. return this;
  915. };
  916. return _class;
  917. }(Base);
  918. };
  919. var Handler = function () {
  920. function Handler(target) {
  921. this.target = target;
  922. }
  923. var _proto = Handler.prototype;
  924. _proto.enable = function enable() {
  925. if (this._enabled) {
  926. return this;
  927. }
  928. this._enabled = true;
  929. this.addHooks();
  930. return this;
  931. };
  932. _proto.disable = function disable() {
  933. if (!this._enabled) {
  934. return this;
  935. }
  936. this._enabled = false;
  937. this.removeHooks();
  938. return this;
  939. };
  940. _proto.enabled = function enabled() {
  941. return !!this._enabled;
  942. };
  943. _proto.remove = function remove() {
  944. this.disable();
  945. delete this.target;
  946. delete this.dom;
  947. };
  948. return Handler;
  949. }();
  950. var Handler$1 = Eventable(Handler);
  951. function Handlerable(Base) {
  952. return function (_Base) {
  953. _inheritsLoose(_class, _Base);
  954. function _class() {
  955. return _Base.apply(this, arguments) || this;
  956. }
  957. var _proto = _class.prototype;
  958. _proto.addHandler = function addHandler(name, handlerClass) {
  959. if (!handlerClass) {
  960. return this;
  961. }
  962. if (!this._handlers) {
  963. this._handlers = [];
  964. }
  965. if (this[name]) {
  966. this[name].enable();
  967. return this;
  968. }
  969. var handler = this[name] = new handlerClass(this);
  970. this._handlers.push(handler);
  971. if (this.options[name]) {
  972. handler.enable();
  973. }
  974. return this;
  975. };
  976. _proto.removeHandler = function removeHandler(name) {
  977. if (!name) {
  978. return this;
  979. }
  980. var handler = this[name];
  981. if (handler) {
  982. var hit = this._handlers.indexOf(handler);
  983. if (hit >= 0) {
  984. this._handlers.splice(hit, 1);
  985. }
  986. this[name].remove();
  987. delete this[name];
  988. }
  989. return this;
  990. };
  991. _proto._clearHandlers = function _clearHandlers() {
  992. for (var i = 0, len = this._handlers.length; i < len; i++) {
  993. this._handlers[i].remove();
  994. }
  995. this._handlers = [];
  996. };
  997. return _class;
  998. }(Base);
  999. }
  1000. var registeredTypes = {};
  1001. var JSONAble = (function (Base) {
  1002. return function (_Base) {
  1003. _inheritsLoose(_class, _Base);
  1004. function _class() {
  1005. return _Base.apply(this, arguments) || this;
  1006. }
  1007. _class.registerJSONType = function registerJSONType(type) {
  1008. if (!type) {
  1009. return this;
  1010. }
  1011. registeredTypes[type] = this;
  1012. return this;
  1013. };
  1014. _class.getJSONClass = function getJSONClass(type) {
  1015. if (!type) {
  1016. return null;
  1017. }
  1018. return registeredTypes[type];
  1019. };
  1020. var _proto = _class.prototype;
  1021. _proto.getJSONType = function getJSONType() {
  1022. if (this._jsonType === undefined) {
  1023. var clazz = Object.getPrototypeOf(this).constructor;
  1024. for (var p in registeredTypes) {
  1025. if (registeredTypes[p] === clazz) {
  1026. this._jsonType = p;
  1027. break;
  1028. }
  1029. }
  1030. }
  1031. if (!this._jsonType) {
  1032. throw new Error('Found an unregistered geometry class!');
  1033. }
  1034. return this._jsonType;
  1035. };
  1036. return _class;
  1037. }(Base);
  1038. });
  1039. var Class = function () {
  1040. function Class(options) {
  1041. if (!this || !this.setOptions) {
  1042. throw new Error('Class instance is being created without "new" operator.');
  1043. }
  1044. this.setOptions(options);
  1045. this.callInitHooks();
  1046. }
  1047. var _proto = Class.prototype;
  1048. _proto.callInitHooks = function callInitHooks() {
  1049. var proto = Object.getPrototypeOf(this);
  1050. this._visitInitHooks(proto);
  1051. return this;
  1052. };
  1053. _proto.setOptions = function setOptions(options) {
  1054. if (!this.hasOwnProperty('options')) {
  1055. this.options = this.options ? Object.create(this.options) : {};
  1056. }
  1057. if (!options) {
  1058. return this;
  1059. }
  1060. for (var i in options) {
  1061. this.options[i] = options[i];
  1062. }
  1063. return this;
  1064. };
  1065. _proto.config = function config(conf) {
  1066. if (!conf) {
  1067. var config = {};
  1068. for (var p in this.options) {
  1069. if (this.options.hasOwnProperty(p)) {
  1070. config[p] = this.options[p];
  1071. }
  1072. }
  1073. return config;
  1074. } else {
  1075. if (arguments.length === 2) {
  1076. var t = {};
  1077. t[conf] = arguments[1];
  1078. conf = t;
  1079. }
  1080. for (var i in conf) {
  1081. this.options[i] = conf[i];
  1082. if (this[i] && this[i] instanceof Handler$1) {
  1083. if (conf[i]) {
  1084. this[i].enable();
  1085. } else {
  1086. this[i].disable();
  1087. }
  1088. }
  1089. }
  1090. this.onConfig(conf);
  1091. }
  1092. return this;
  1093. };
  1094. _proto.onConfig = function onConfig() { };
  1095. _proto._visitInitHooks = function _visitInitHooks(proto) {
  1096. if (this._initHooksCalled) {
  1097. return;
  1098. }
  1099. var parentProto = Object.getPrototypeOf(proto);
  1100. if (parentProto._visitInitHooks) {
  1101. parentProto._visitInitHooks.call(this, parentProto);
  1102. }
  1103. this._initHooksCalled = true;
  1104. var hooks = proto._initHooks;
  1105. if (hooks && hooks !== parentProto._initHooks) {
  1106. for (var i = 0; i < hooks.length; i++) {
  1107. hooks[i].call(this);
  1108. }
  1109. }
  1110. };
  1111. Class.addInitHook = function addInitHook(fn) {
  1112. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1113. args[_key - 1] = arguments[_key];
  1114. }
  1115. var init = typeof fn === 'function' ? fn : function () {
  1116. this[fn].apply(this, args);
  1117. };
  1118. var proto = this.prototype;
  1119. var parentProto = Object.getPrototypeOf(proto);
  1120. if (!proto._initHooks || proto._initHooks === parentProto._initHooks) {
  1121. proto._initHooks = [];
  1122. }
  1123. proto._initHooks.push(init);
  1124. return this;
  1125. };
  1126. Class.include = function include() {
  1127. for (var i = 0; i < arguments.length; i++) {
  1128. extend(this.prototype, i < 0 || arguments.length <= i ? undefined : arguments[i]);
  1129. }
  1130. return this;
  1131. };
  1132. Class.mergeOptions = function mergeOptions(options) {
  1133. var proto = this.prototype;
  1134. var parentProto = Object.getPrototypeOf(proto);
  1135. if (!proto.options || proto.options === parentProto.options) {
  1136. proto.options = proto.options ? Object.create(proto.options) : {};
  1137. }
  1138. extend(proto.options, options);
  1139. return this;
  1140. };
  1141. return Class;
  1142. }();
  1143. var options$2 = {
  1144. 'id': null,
  1145. 'visible': true,
  1146. 'editable': true,
  1147. 'cursor': null,
  1148. 'defaultProjection': 'EPSG:4326'
  1149. };
  1150. var Geometry = function (_JSONAble) {
  1151. _inheritsLoose(Geometry, _JSONAble);
  1152. function Geometry(options) {
  1153. var _this;
  1154. var opts = extend({}, options);
  1155. var symbol = opts['symbol'];
  1156. var properties = opts['properties'];
  1157. var id = opts['id'];
  1158. delete opts['symbol'];
  1159. delete opts['id'];
  1160. delete opts['properties'];
  1161. _this = _JSONAble.call(this, opts) || this;
  1162. if (symbol) {
  1163. _this.setSymbol(symbol);
  1164. }
  1165. if (properties) {
  1166. _this.setProperties(properties);
  1167. }
  1168. if (!isNil(id)) {
  1169. _this.setId(id);
  1170. }
  1171. return _this;
  1172. }
  1173. var _proto = Geometry.prototype;
  1174. _proto.getFirstCoordinate = function getFirstCoordinate() {
  1175. if (this.type === 'GeometryCollection') {
  1176. var geometries = this.getGeometries();
  1177. if (!geometries.length) {
  1178. return null;
  1179. }
  1180. return geometries[0].getFirstCoordinate();
  1181. }
  1182. var coordinates = this.getCoordinates();
  1183. if (!Array.isArray(coordinates)) {
  1184. return coordinates;
  1185. }
  1186. do {
  1187. coordinates = coordinates[0];
  1188. } while (Array.isArray(coordinates) && coordinates.length > 0);
  1189. return coordinates;
  1190. };
  1191. _proto.getLastCoordinate = function getLastCoordinate() {
  1192. if (this.type === 'GeometryCollection') {
  1193. var geometries = this.getGeometries();
  1194. if (!geometries.length) {
  1195. return null;
  1196. }
  1197. return geometries[geometries.length - 1].getLastCoordinate();
  1198. }
  1199. var coordinates = this.getCoordinates();
  1200. if (!Array.isArray(coordinates)) {
  1201. return coordinates;
  1202. }
  1203. do {
  1204. coordinates = coordinates[coordinates.length - 1];
  1205. } while (Array.isArray(coordinates) && coordinates.length > 0);
  1206. return coordinates;
  1207. };
  1208. _proto.addTo = function addTo(layer, fitview) {
  1209. layer.addGeometry(this, fitview);
  1210. return this;
  1211. };
  1212. _proto.getLayer = function getLayer() {
  1213. if (!this._layer) {
  1214. return null;
  1215. }
  1216. return this._layer;
  1217. };
  1218. _proto.getMap = function getMap() {
  1219. if (!this._layer) {
  1220. return null;
  1221. }
  1222. return this._layer.getMap();
  1223. };
  1224. _proto.getId = function getId() {
  1225. return this._id;
  1226. };
  1227. _proto.setId = function setId(id) {
  1228. var oldId = this.getId();
  1229. this._id = id;
  1230. this._fireEvent('idchange', {
  1231. 'old': oldId,
  1232. 'new': id
  1233. });
  1234. return this;
  1235. };
  1236. _proto.getProperties = function getProperties() {
  1237. if (!this.properties) {
  1238. if (this._getParent()) {
  1239. return this._getParent().getProperties();
  1240. }
  1241. return null;
  1242. }
  1243. return this.properties;
  1244. };
  1245. _proto.setProperties = function setProperties(properties) {
  1246. var old = this.properties;
  1247. this.properties = isObject(properties) ? extend({}, properties) : properties;
  1248. this._repaint();
  1249. this._fireEvent('propertieschange', {
  1250. 'old': old,
  1251. 'new': properties
  1252. });
  1253. return this;
  1254. };
  1255. _proto.getType = function getType() {
  1256. return this.type;
  1257. };
  1258. _proto.getSymbol = function getSymbol() {
  1259. var s = this._symbol;
  1260. if (s) {
  1261. if (!Array.isArray(s)) {
  1262. return extend({}, s);
  1263. } else {
  1264. return extendSymbol(s);
  1265. }
  1266. }
  1267. return null;
  1268. };
  1269. _proto.setSymbol = function setSymbol(symbol) {
  1270. this._symbol = this._prepareSymbol(symbol);
  1271. this.onSymbolChanged();
  1272. return this;
  1273. };
  1274. _proto.updateSymbol = function updateSymbol(props) {
  1275. if (!props) {
  1276. return this;
  1277. }
  1278. var s = this._getSymbol();
  1279. if (s) {
  1280. s = extendSymbol(s, props);
  1281. } else {
  1282. s = extendSymbol(this._getInternalSymbol(), props);
  1283. }
  1284. return this.setSymbol(s);
  1285. };
  1286. _proto.getCenter = function getCenter() {
  1287. return this._computeCenter(this._getMeasurer());
  1288. };
  1289. _proto.getExtent = function getExtent() {
  1290. var prjExt = this._getPrjExtent();
  1291. if (prjExt) {
  1292. var p = this._getProjection();
  1293. var min = p.unproject(new Coordinate(prjExt['xmin'], prjExt['ymin'])),
  1294. max = p.unproject(new Coordinate(prjExt['xmax'], prjExt['ymax']));
  1295. return new Extent(min, max, this._getProjection());
  1296. } else {
  1297. return this._computeExtent(this._getMeasurer());
  1298. }
  1299. };
  1300. _proto.getContainerExtent = function getContainerExtent() {
  1301. var painter = this._getPainter();
  1302. return painter ? painter.getContainerExtent() : null;
  1303. };
  1304. _proto.getSize = function getSize() {
  1305. var extent = this.getContainerExtent();
  1306. return extent ? extent.getSize() : null;
  1307. };
  1308. _proto.containsPoint = function containsPoint(containerPoint, t) {
  1309. if (!this.getMap()) {
  1310. throw new Error('The geometry is required to be added on a map to perform "containsPoint".');
  1311. }
  1312. if (containerPoint instanceof Coordinate) {
  1313. containerPoint = this.getMap().coordToContainerPoint(containerPoint);
  1314. }
  1315. return this._containsPoint(containerPoint, t);
  1316. };
  1317. _proto._containsPoint = function _containsPoint(containerPoint, t) {
  1318. var painter = this._getPainter();
  1319. if (!painter) {
  1320. return false;
  1321. }
  1322. if (isNil(t) && this._hitTestTolerance) {
  1323. t = this._hitTestTolerance();
  1324. }
  1325. return painter.hitTest(containerPoint, t);
  1326. };
  1327. _proto.show = function show() {
  1328. this.options['visible'] = true;
  1329. if (this.getMap()) {
  1330. var painter = this._getPainter();
  1331. if (painter) {
  1332. painter.show();
  1333. }
  1334. this._fireEvent('show');
  1335. }
  1336. return this;
  1337. };
  1338. _proto.hide = function hide() {
  1339. this.options['visible'] = false;
  1340. if (this.getMap()) {
  1341. this.onHide();
  1342. var painter = this._getPainter();
  1343. if (painter) {
  1344. painter.hide();
  1345. }
  1346. this._fireEvent('hide');
  1347. }
  1348. return this;
  1349. };
  1350. _proto.isVisible = function isVisible() {
  1351. if (!this.options['visible']) {
  1352. return false;
  1353. }
  1354. var symbol = this._getInternalSymbol();
  1355. if (!symbol) {
  1356. return true;
  1357. }
  1358. if (Array.isArray(symbol)) {
  1359. if (!symbol.length) {
  1360. return true;
  1361. }
  1362. for (var i = 0, l = symbol.length; i < l; i++) {
  1363. if (isNil(symbol[i]['opacity']) || symbol[i]['opacity'] > 0) {
  1364. return true;
  1365. }
  1366. }
  1367. return false;
  1368. } else {
  1369. return isNil(symbol['opacity']) || isNumber(symbol['opacity']) && symbol['opacity'] > 0;
  1370. }
  1371. };
  1372. _proto.getZIndex = function getZIndex() {
  1373. return this.options['zIndex'] || 0;
  1374. };
  1375. _proto.setZIndex = function setZIndex(zIndex) {
  1376. var old = this.options['zIndex'];
  1377. this.options['zIndex'] = zIndex;
  1378. this._fireEvent('zindexchange', {
  1379. 'old': old,
  1380. 'new': zIndex
  1381. });
  1382. return this;
  1383. };
  1384. _proto.setZIndexSilently = function setZIndexSilently(zIndex) {
  1385. this.options['zIndex'] = zIndex;
  1386. return this;
  1387. };
  1388. _proto.bringToFront = function bringToFront() {
  1389. var layer = this.getLayer();
  1390. if (!layer || !layer.getGeoMaxZIndex) {
  1391. return this;
  1392. }
  1393. var topZ = layer.getGeoMaxZIndex();
  1394. this.setZIndex(topZ + 1);
  1395. return this;
  1396. };
  1397. _proto.bringToBack = function bringToBack() {
  1398. var layer = this.getLayer();
  1399. if (!layer || !layer.getGeoMinZIndex) {
  1400. return this;
  1401. }
  1402. var bottomZ = layer.getGeoMinZIndex();
  1403. this.setZIndex(bottomZ - 1);
  1404. return this;
  1405. };
  1406. _proto.translate = function translate(x, y) {
  1407. if (isNil(x)) {
  1408. return this;
  1409. }
  1410. var offset = new Coordinate(x, y);
  1411. if (offset.x === 0 && offset.y === 0) {
  1412. return this;
  1413. }
  1414. var coordinates = this.getCoordinates();
  1415. if (coordinates) {
  1416. if (Array.isArray(coordinates)) {
  1417. var translated = forEachCoord(coordinates, function (coord) {
  1418. return coord.add(offset);
  1419. });
  1420. this.setCoordinates(translated);
  1421. } else {
  1422. this.setCoordinates(coordinates.add(offset));
  1423. }
  1424. }
  1425. return this;
  1426. };
  1427. _proto.flash = function flash$$1(interval, count, cb, context) {
  1428. return flash.call(this, interval, count, cb, context);
  1429. };
  1430. _proto.copy = function copy() {
  1431. var json = this.toJSON();
  1432. var ret = Geometry.fromJSON(json);
  1433. ret.options['visible'] = true;
  1434. return ret;
  1435. };
  1436. _proto.remove = function remove() {
  1437. var layer = this.getLayer();
  1438. if (!layer) {
  1439. return this;
  1440. }
  1441. this._fireEvent('removestart');
  1442. this._unbind();
  1443. this._fireEvent('removeend');
  1444. this._fireEvent('remove');
  1445. return this;
  1446. };
  1447. _proto.toGeoJSONGeometry = function toGeoJSONGeometry() {
  1448. var gJson = this._exportGeoJSONGeometry();
  1449. return gJson;
  1450. };
  1451. _proto.toGeoJSON = function toGeoJSON(opts) {
  1452. if (!opts) {
  1453. opts = {};
  1454. }
  1455. var feature = {
  1456. 'type': 'Feature',
  1457. 'geometry': null
  1458. };
  1459. if (isNil(opts['geometry']) || opts['geometry']) {
  1460. var geoJSON = this._exportGeoJSONGeometry();
  1461. feature['geometry'] = geoJSON;
  1462. }
  1463. var id = this.getId();
  1464. if (!isNil(id)) {
  1465. feature['id'] = id;
  1466. }
  1467. var properties;
  1468. if (isNil(opts['properties']) || opts['properties']) {
  1469. properties = this._exportProperties();
  1470. }
  1471. feature['properties'] = properties;
  1472. return feature;
  1473. };
  1474. _proto.toJSON = function toJSON(options) {
  1475. if (!options) {
  1476. options = {};
  1477. }
  1478. var json = this._toJSON(options);
  1479. var other = this._exportGraphicOptions(options);
  1480. extend(json, other);
  1481. return json;
  1482. };
  1483. _proto.getLength = function getLength() {
  1484. return this._computeGeodesicLength(this._getMeasurer());
  1485. };
  1486. _proto.getArea = function getArea() {
  1487. return this._computeGeodesicArea(this._getMeasurer());
  1488. };
  1489. _proto.rotate = function rotate(angle, pivot) {
  1490. if (this.type === 'GeometryCollection') {
  1491. var geometries = this.getGeometries();
  1492. geometries.forEach(function (g) {
  1493. return g.rotate(angle, pivot);
  1494. });
  1495. return this;
  1496. }
  1497. if (!pivot) {
  1498. pivot = this.getCenter();
  1499. } else {
  1500. pivot = new Coordinate(pivot);
  1501. }
  1502. var measurer = this._getMeasurer();
  1503. var coordinates = this.getCoordinates();
  1504. if (!Array.isArray(coordinates)) {
  1505. if (pivot.x !== coordinates.x || pivot.y !== coordinates.y) {
  1506. var c = measurer._rotate(coordinates, pivot, angle);
  1507. this.setCoordinates(c);
  1508. }
  1509. return this;
  1510. }
  1511. forEachCoord(coordinates, function (c) {
  1512. return measurer._rotate(c, pivot, angle);
  1513. });
  1514. this.setCoordinates(coordinates);
  1515. return this;
  1516. };
  1517. _proto._getConnectPoints = function _getConnectPoints() {
  1518. return [this.getCenter()];
  1519. };
  1520. _proto._initOptions = function _initOptions(options) {
  1521. var opts = extend({}, options);
  1522. var symbol = opts['symbol'];
  1523. var properties = opts['properties'];
  1524. var id = opts['id'];
  1525. delete opts['symbol'];
  1526. delete opts['id'];
  1527. delete opts['properties'];
  1528. this.setOptions(opts);
  1529. if (symbol) {
  1530. this.setSymbol(symbol);
  1531. }
  1532. if (properties) {
  1533. this.setProperties(properties);
  1534. }
  1535. if (!isNil(id)) {
  1536. this.setId(id);
  1537. }
  1538. };
  1539. _proto._bindLayer = function _bindLayer(layer) {
  1540. if (this.getLayer()) {
  1541. throw new Error('Geometry cannot be added to two or more layers at the same time.');
  1542. }
  1543. this._layer = layer;
  1544. this._clearCache();
  1545. this._clearProjection();
  1546. };
  1547. _proto._prepareSymbol = function _prepareSymbol(symbol) {
  1548. if (Array.isArray(symbol)) {
  1549. var cookedSymbols = [];
  1550. for (var i = 0; i < symbol.length; i++) {
  1551. cookedSymbols.push(convertResourceUrl(this._checkAndCopySymbol(symbol[i])));
  1552. }
  1553. return cookedSymbols;
  1554. } else if (symbol) {
  1555. symbol = this._checkAndCopySymbol(symbol);
  1556. return convertResourceUrl(symbol);
  1557. }
  1558. return null;
  1559. };
  1560. _proto._checkAndCopySymbol = function _checkAndCopySymbol(symbol) {
  1561. var s = {};
  1562. for (var i in symbol) {
  1563. if (NUMERICAL_PROPERTIES[i] && isString(symbol[i])) {
  1564. s[i] = +symbol[i];
  1565. } else {
  1566. s[i] = symbol[i];
  1567. }
  1568. }
  1569. return s;
  1570. };
  1571. _proto._getSymbol = function _getSymbol() {
  1572. return this._symbol;
  1573. };
  1574. _proto._setExternSymbol = function _setExternSymbol(symbol) {
  1575. this._externSymbol = this._prepareSymbol(symbol);
  1576. this.onSymbolChanged();
  1577. return this;
  1578. };
  1579. _proto._getInternalSymbol = function _getInternalSymbol() {
  1580. if (this._symbol) {
  1581. return this._symbol;
  1582. } else if (this._externSymbol) {
  1583. return this._externSymbol;
  1584. } else if (this.options['symbol']) {
  1585. return this.options['symbol'];
  1586. }
  1587. return null;
  1588. };
  1589. _proto._getPrjExtent = function _getPrjExtent() {
  1590. var p = this._getProjection();
  1591. this._verifyProjection();
  1592. if (!this._extent && p) {
  1593. this._extent = this._computePrjExtent(p);
  1594. }
  1595. return this._extent;
  1596. };
  1597. _proto._unbind = function _unbind() {
  1598. var layer = this.getLayer();
  1599. if (!layer) {
  1600. return;
  1601. }
  1602. if (this._animPlayer) {
  1603. this._animPlayer.finish();
  1604. }
  1605. this._clearHandlers();
  1606. this._unbindMenu();
  1607. this._unbindInfoWindow();
  1608. if (this.isEditing()) {
  1609. this.endEdit();
  1610. }
  1611. this._removePainter();
  1612. if (this.onRemove) {
  1613. this.onRemove();
  1614. }
  1615. if (layer.onRemoveGeometry) {
  1616. layer.onRemoveGeometry(this);
  1617. }
  1618. delete this._layer;
  1619. delete this._internalId;
  1620. delete this._extent;
  1621. };
  1622. _proto._getInternalId = function _getInternalId() {
  1623. return this._internalId;
  1624. };
  1625. _proto._setInternalId = function _setInternalId(id) {
  1626. this._internalId = id;
  1627. };
  1628. _proto._getMeasurer = function _getMeasurer() {
  1629. if (this._getProjection()) {
  1630. return this._getProjection();
  1631. }
  1632. return SpatialReference.getProjectionInstance(this.options['defaultProjection']);
  1633. };
  1634. _proto._getProjection = function _getProjection() {
  1635. var map = this.getMap();
  1636. if (map) {
  1637. return map.getProjection();
  1638. }
  1639. return null;
  1640. };
  1641. _proto._verifyProjection = function _verifyProjection() {
  1642. var projection = this._getProjection();
  1643. if (this._projCode && (!projection || this._projCode !== projection.code)) {
  1644. this._clearProjection();
  1645. }
  1646. this._projCode = projection ? projection.code : null;
  1647. };
  1648. _proto._getExternalResources = function _getExternalResources() {
  1649. var symbol = this._getInternalSymbol();
  1650. return getExternalResources(symbol);
  1651. };
  1652. _proto._getPainter = function _getPainter() {
  1653. if (!this._painter && this.getMap()) {
  1654. if (GEOMETRY_COLLECTION_TYPES.indexOf(this.type) !== -1) {
  1655. this._painter = new CollectionPainter(this);
  1656. } else {
  1657. this._painter = new Painter(this);
  1658. }
  1659. }
  1660. return this._painter;
  1661. };
  1662. _proto._removePainter = function _removePainter() {
  1663. if (this._painter) {
  1664. this._painter.remove();
  1665. }
  1666. delete this._painter;
  1667. };
  1668. _proto._paint = function _paint(extent) {
  1669. if (this._painter) {
  1670. this._painter.paint(extent);
  1671. }
  1672. };
  1673. _proto._clearCache = function _clearCache() {
  1674. delete this._extent;
  1675. };
  1676. _proto._clearProjection = function _clearProjection() {
  1677. delete this._extent;
  1678. };
  1679. _proto._repaint = function _repaint() {
  1680. if (this._painter) {
  1681. this._painter.repaint();
  1682. }
  1683. };
  1684. _proto.onHide = function onHide() {
  1685. this.closeMenu();
  1686. this.closeInfoWindow();
  1687. };
  1688. _proto.onShapeChanged = function onShapeChanged() {
  1689. this._clearCache();
  1690. this._repaint();
  1691. this._fireEvent('shapechange');
  1692. };
  1693. _proto.onPositionChanged = function onPositionChanged() {
  1694. this._clearCache();
  1695. this._repaint();
  1696. this._fireEvent('positionchange');
  1697. };
  1698. _proto.onSymbolChanged = function onSymbolChanged() {
  1699. if (this._painter) {
  1700. this._painter.refreshSymbol();
  1701. }
  1702. this._fireEvent('symbolchange');
  1703. };
  1704. _proto.onConfig = function onConfig(conf) {
  1705. var properties;
  1706. if (conf['properties']) {
  1707. properties = conf['properties'];
  1708. delete conf['properties'];
  1709. }
  1710. var needRepaint = false;
  1711. for (var p in conf) {
  1712. if (conf.hasOwnProperty(p)) {
  1713. var prefix = p.slice(0, 5);
  1714. if (prefix === 'arrow' || prefix === 'smoot') {
  1715. needRepaint = true;
  1716. break;
  1717. }
  1718. }
  1719. }
  1720. if (properties) {
  1721. this.setProperties(properties);
  1722. this._repaint();
  1723. } else if (needRepaint) {
  1724. this._repaint();
  1725. }
  1726. };
  1727. _proto._setParent = function _setParent(geometry) {
  1728. if (geometry) {
  1729. this._parent = geometry;
  1730. }
  1731. };
  1732. _proto._getParent = function _getParent() {
  1733. return this._parent;
  1734. };
  1735. _proto._fireEvent = function _fireEvent(eventName, param) {
  1736. if (this.getLayer() && this.getLayer()._onGeometryEvent) {
  1737. if (!param) {
  1738. param = {};
  1739. }
  1740. param['type'] = eventName;
  1741. param['target'] = this;
  1742. this.getLayer()._onGeometryEvent(param);
  1743. }
  1744. this.fire(eventName, param);
  1745. };
  1746. _proto._toJSON = function _toJSON(options) {
  1747. return {
  1748. 'feature': this.toGeoJSON(options)
  1749. };
  1750. };
  1751. _proto._exportGraphicOptions = function _exportGraphicOptions(options) {
  1752. var json = {};
  1753. if (isNil(options['options']) || options['options']) {
  1754. json['options'] = this.config();
  1755. }
  1756. if (isNil(options['symbol']) || options['symbol']) {
  1757. json['symbol'] = this.getSymbol();
  1758. }
  1759. if (isNil(options['infoWindow']) || options['infoWindow']) {
  1760. if (this._infoWinOptions) {
  1761. json['infoWindow'] = this._infoWinOptions;
  1762. }
  1763. }
  1764. return json;
  1765. };
  1766. _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
  1767. var points = this.getCoordinates();
  1768. var coordinates = Coordinate.toNumberArrays(points);
  1769. return {
  1770. 'type': this.getType(),
  1771. 'coordinates': coordinates
  1772. };
  1773. };
  1774. _proto._exportProperties = function _exportProperties() {
  1775. var properties = null;
  1776. var geoProperties = this.getProperties();
  1777. if (!isNil(geoProperties)) {
  1778. if (isObject(geoProperties)) {
  1779. properties = extend({}, geoProperties);
  1780. } else {
  1781. properties = geoProperties;
  1782. }
  1783. }
  1784. return properties;
  1785. };
  1786. return Geometry;
  1787. }(JSONAble(Eventable(Handlerable(Class))));
  1788. Geometry.mergeOptions(options$2);
  1789. var Marker = function (_CenterMixin) {
  1790. _inheritsLoose(Marker, _CenterMixin);
  1791. function Marker(coordinates, opts) {
  1792. var _this;
  1793. _this = _CenterMixin.call(this, opts) || this;
  1794. _this.type = 'Point';
  1795. if (coordinates) {
  1796. _this.setCoordinates(coordinates);
  1797. }
  1798. return _this;
  1799. }
  1800. var _proto = Marker.prototype;
  1801. _proto.getOutline = function getOutline() {
  1802. var painter = this._getPainter();
  1803. if (!painter) {
  1804. return null;
  1805. }
  1806. var coord = this.getCoordinates();
  1807. var extent = painter.getContainerExtent();
  1808. var anchor = this.getMap().coordToContainerPoint(coord);
  1809. return new Marker(coord, {
  1810. 'symbol': {
  1811. 'markerType': 'square',
  1812. 'markerWidth': extent.getWidth(),
  1813. 'markerHeight': extent.getHeight(),
  1814. 'markerLineWidth': 1,
  1815. 'markerLineColor': '6b707b',
  1816. 'markerFill': 'rgba(0, 0, 0, 0)',
  1817. 'markerDx': extent.xmin - (anchor.x - extent.getWidth() / 2),
  1818. 'markerDy': extent.ymin - (anchor.y - extent.getHeight() / 2)
  1819. }
  1820. });
  1821. };
  1822. _proto._isVectorMarker = function _isVectorMarker() {
  1823. var symbol = this._getInternalSymbol();
  1824. if (Array.isArray(symbol)) {
  1825. return false;
  1826. }
  1827. return VectorMarkerSymbolizer.test(symbol);
  1828. };
  1829. _proto._canEdit = function _canEdit() {
  1830. var symbol = this._getInternalSymbol();
  1831. if (Array.isArray(symbol)) {
  1832. return false;
  1833. }
  1834. return VectorMarkerSymbolizer.test(symbol) || VectorPathMarkerSymbolizer.test(symbol) || ImageMarkerSymbolizer.test(symbol);
  1835. };
  1836. _proto._containsPoint = function _containsPoint(point, t) {
  1837. var extent = this.getContainerExtent();
  1838. if (t) {
  1839. extent = extent.expand(t);
  1840. }
  1841. if (extent.contains(point)) {
  1842. if (this.options['hitTestForEvent']) {
  1843. return _CenterMixin.prototype._containsPoint.call(this, point, t);
  1844. } else {
  1845. return true;
  1846. }
  1847. } else {
  1848. return false;
  1849. }
  1850. };
  1851. _proto._computeExtent = function _computeExtent() {
  1852. return computeExtent.call(this, 'getCenter');
  1853. };
  1854. _proto._computePrjExtent = function _computePrjExtent() {
  1855. return computeExtent.call(this, '_getPrjCoordinates');
  1856. };
  1857. _proto._computeGeodesicLength = function _computeGeodesicLength() {
  1858. return 0;
  1859. };
  1860. _proto._computeGeodesicArea = function _computeGeodesicArea() {
  1861. return 0;
  1862. };
  1863. _proto._getSprite = function _getSprite(resources, canvasClass) {
  1864. if (this._getPainter()) {
  1865. return this._getPainter().getSprite(resources, canvasClass);
  1866. }
  1867. return new Painter(this).getSprite(resources, canvasClass);
  1868. };
  1869. return Marker;
  1870. }(CenterMixin(Geometry));
  1871. var options$3 = {
  1872. 'smoothness': 0,
  1873. 'enableClip': true,
  1874. 'enableSimplify': true,
  1875. 'simplifyTolerance': 2,
  1876. 'symbol': {
  1877. 'lineColor': '#000',
  1878. 'lineWidth': 2,
  1879. 'lineOpacity': 1,
  1880. 'polygonFill': '#fff',
  1881. 'polygonOpacity': 1,
  1882. 'opacity': 1
  1883. }
  1884. };
  1885. var Path = function (_Geometry) {
  1886. _inheritsLoose(Path, _Geometry);
  1887. function Path() {
  1888. return _Geometry.apply(this, arguments) || this;
  1889. }
  1890. var _proto = Path.prototype;
  1891. _proto.getOutline = function getOutline() {
  1892. var painter = this._getPainter();
  1893. if (!painter) {
  1894. return null;
  1895. }
  1896. var map = this.getMap();
  1897. var extent = painter.getContainerExtent().convertTo(function (c) {
  1898. return map.containerPointToCoord(c);
  1899. });
  1900. return new Polygon(extent.toArray(), {
  1901. symbol: {
  1902. 'lineWidth': 1,
  1903. 'lineColor': '6b707b'
  1904. }
  1905. });
  1906. };
  1907. _proto.animateShow = function animateShow(options, cb) {
  1908. var _this = this;
  1909. if (options === void 0) {
  1910. options = {};
  1911. }
  1912. if (this._showPlayer) {
  1913. this._showPlayer.finish();
  1914. }
  1915. if (isFunction(options)) {
  1916. options = {};
  1917. cb = options;
  1918. }
  1919. var coordinates = this.getCoordinates();
  1920. if (coordinates.length === 0) {
  1921. return this;
  1922. }
  1923. this._animIdx = 0;
  1924. this._animLenSoFar = 0;
  1925. this.show();
  1926. var isPolygon = !!this.getShell;
  1927. var animCoords = isPolygon ? this.getShell().concat(this.getShell()[0]) : this.getCoordinates();
  1928. var projection = this._getProjection();
  1929. this._aniShowCenter = projection.unproject(this._getPrjExtent().getCenter());
  1930. var duration = options['duration'] || 1000,
  1931. length = this.getLength(),
  1932. easing = options['easing'] || 'out';
  1933. this.setCoordinates([]);
  1934. var player = this._showPlayer = Animation.animate({
  1935. 't': duration
  1936. }, {
  1937. 'duration': duration,
  1938. 'easing': easing
  1939. }, function (frame) {
  1940. if (!_this.getMap()) {
  1941. if (player.playState !== 'finished') {
  1942. player.finish();
  1943. if (cb) {
  1944. var _coordinates = _this.getCoordinates();
  1945. cb(frame, _coordinates[_coordinates.length - 1]);
  1946. }
  1947. }
  1948. return;
  1949. }
  1950. var currentCoord = _this._drawAnimShowFrame(frame.styles.t, duration, length, animCoords);
  1951. if (frame.state.playState === 'finished') {
  1952. delete _this._showPlayer;
  1953. delete _this._aniShowCenter;
  1954. delete _this._animIdx;
  1955. delete _this._animLenSoFar;
  1956. delete _this._animTailRatio;
  1957. _this.setCoordinates(coordinates);
  1958. }
  1959. if (cb) {
  1960. cb(frame, currentCoord);
  1961. }
  1962. });
  1963. player.play();
  1964. return player;
  1965. };
  1966. _proto._drawAnimShowFrame = function _drawAnimShowFrame(t, duration, length, coordinates) {
  1967. if (t === 0) {
  1968. return coordinates[0];
  1969. }
  1970. var map = this.getMap();
  1971. var targetLength = t / duration * length;
  1972. var segLen = 0;
  1973. var i, l;
  1974. for (i = this._animIdx, l = coordinates.length; i < l - 1; i++) {
  1975. segLen = map.computeLength(coordinates[i], coordinates[i + 1]);
  1976. if (this._animLenSoFar + segLen > targetLength) {
  1977. break;
  1978. }
  1979. this._animLenSoFar += segLen;
  1980. }
  1981. this._animIdx = i;
  1982. if (this._animIdx >= l - 1) {
  1983. this.setCoordinates(coordinates);
  1984. return coordinates[coordinates.length - 1];
  1985. }
  1986. var idx = this._animIdx;
  1987. var p1 = coordinates[idx],
  1988. p2 = coordinates[idx + 1],
  1989. span = targetLength - this._animLenSoFar,
  1990. r = span / segLen;
  1991. this._animTailRatio = r;
  1992. var x = p1.x + (p2.x - p1.x) * r,
  1993. y = p1.y + (p2.y - p1.y) * r,
  1994. targetCoord = new Coordinate(x, y);
  1995. var isPolygon = !!this.getShell;
  1996. if (!isPolygon && this.options['smoothness'] > 0) {
  1997. var animCoords = coordinates.slice(0, this._animIdx + 3);
  1998. this.setCoordinates(animCoords);
  1999. } else {
  2000. var _animCoords = coordinates.slice(0, this._animIdx + 1);
  2001. _animCoords.push(targetCoord);
  2002. if (isPolygon) {
  2003. this.setCoordinates([this._aniShowCenter].concat(_animCoords));
  2004. } else {
  2005. this.setCoordinates(_animCoords);
  2006. }
  2007. }
  2008. return targetCoord;
  2009. };
  2010. _proto._getCenterInExtent = function _getCenterInExtent(extent, coordinates, clipFn) {
  2011. var meExtent = this.getExtent();
  2012. if (!extent.intersects(meExtent)) {
  2013. return null;
  2014. }
  2015. var clipped = clipFn(coordinates, extent);
  2016. if (clipped.length === 0) {
  2017. return null;
  2018. }
  2019. var sumx = 0,
  2020. sumy = 0,
  2021. counter = 0;
  2022. clipped.forEach(function (part) {
  2023. if (Array.isArray(part)) {
  2024. part.forEach(function (c) {
  2025. if (c.point) {
  2026. c = c.point;
  2027. }
  2028. sumx += c.x;
  2029. sumy += c.y;
  2030. counter++;
  2031. });
  2032. } else {
  2033. if (part.point) {
  2034. part = part.point;
  2035. }
  2036. sumx += part.x;
  2037. sumy += part.y;
  2038. counter++;
  2039. }
  2040. });
  2041. var c = new Coordinate(sumx, sumy)._multi(1 / counter);
  2042. c.count = counter;
  2043. return c;
  2044. };
  2045. _proto._getPath2DPoints = function _getPath2DPoints(prjCoords, disableSimplify, zoom) {
  2046. if (!isArrayHasData(prjCoords)) {
  2047. return [];
  2048. }
  2049. var map = this.getMap(),
  2050. isSimplify = !disableSimplify && this._shouldSimplify(),
  2051. tolerance = this.options['simplifyTolerance'] * map._getResolution(),
  2052. isMulti = Array.isArray(prjCoords[0]);
  2053. delete this._simplified;
  2054. if (isSimplify && !isMulti) {
  2055. var count = prjCoords.length;
  2056. prjCoords = simplify(prjCoords, tolerance, false);
  2057. this._simplified = prjCoords.length < count;
  2058. }
  2059. if (isNil(zoom)) {
  2060. zoom = map.getZoom();
  2061. }
  2062. return forEachCoord(prjCoords, function (c) {
  2063. return map._prjToPoint(c, zoom);
  2064. });
  2065. };
  2066. _proto._shouldSimplify = function _shouldSimplify() {
  2067. var layer = this.getLayer(),
  2068. properties = this.getProperties();
  2069. var hasAltitude = properties && layer.options['enableAltitude'] && !isNil(properties[layer.options['altitudeProperty']]);
  2070. return layer && layer.options['enableSimplify'] && !hasAltitude && this.options['enableSimplify'] && !this._showPlayer;
  2071. };
  2072. _proto._setPrjCoordinates = function _setPrjCoordinates(prjPoints) {
  2073. this._prjCoords = prjPoints;
  2074. this.onShapeChanged();
  2075. };
  2076. _proto._getPrjCoordinates = function _getPrjCoordinates() {
  2077. var projection = this._getProjection();
  2078. if (!projection) {
  2079. return null;
  2080. }
  2081. this._verifyProjection();
  2082. if (!this._prjCoords) {
  2083. this._prjCoords = this._projectCoords(this._coordinates);
  2084. }
  2085. return this._prjCoords;
  2086. };
  2087. _proto._updateCache = function _updateCache() {
  2088. this._clearCache();
  2089. var projection = this._getProjection();
  2090. if (!projection) {
  2091. return;
  2092. }
  2093. if (this._prjCoords) {
  2094. this._coordinates = this._unprojectCoords(this._getPrjCoordinates());
  2095. }
  2096. };
  2097. _proto._clearProjection = function _clearProjection() {
  2098. this._prjCoords = null;
  2099. _Geometry.prototype._clearProjection.call(this);
  2100. };
  2101. _proto._projectCoords = function _projectCoords(points) {
  2102. var projection = this._getProjection();
  2103. if (projection) {
  2104. return projection.projectCoords(points);
  2105. }
  2106. return [];
  2107. };
  2108. _proto._unprojectCoords = function _unprojectCoords(prjPoints) {
  2109. var projection = this._getProjection();
  2110. if (projection) {
  2111. return projection.unprojectCoords(prjPoints);
  2112. }
  2113. return [];
  2114. };
  2115. _proto._computeCenter = function _computeCenter() {
  2116. var ring = this._coordinates;
  2117. if (!isArrayHasData(ring)) {
  2118. return null;
  2119. }
  2120. var sumx = 0,
  2121. sumy = 0,
  2122. counter = 0;
  2123. var size = ring.length;
  2124. for (var i = 0; i < size; i++) {
  2125. if (ring[i]) {
  2126. if (isNumber(ring[i].x) && isNumber(ring[i].y)) {
  2127. sumx += ring[i].x;
  2128. sumy += ring[i].y;
  2129. counter++;
  2130. }
  2131. }
  2132. }
  2133. return new Coordinate(sumx / counter, sumy / counter);
  2134. };
  2135. _proto._computeExtent = function _computeExtent() {
  2136. var shell = this._coordinates;
  2137. if (!isArrayHasData(shell)) {
  2138. return null;
  2139. }
  2140. var rings = [shell];
  2141. if (this.hasHoles && this.hasHoles()) {
  2142. rings.push.apply(rings, this.getHoles());
  2143. }
  2144. return this._coords2Extent(rings, this._getProjection());
  2145. };
  2146. _proto._computePrjExtent = function _computePrjExtent() {
  2147. var coords = [this._getPrjCoordinates()];
  2148. if (this.hasHoles && this.hasHoles()) {
  2149. coords.push.apply(coords, this._getPrjHoles());
  2150. }
  2151. return this._coords2Extent(coords);
  2152. };
  2153. _proto._get2DLength = function _get2DLength() {
  2154. var vertexes = this._getPath2DPoints(this._getPrjCoordinates(), true);
  2155. var len = 0;
  2156. for (var i = 1, l = vertexes.length; i < l; i++) {
  2157. len += vertexes[i].distanceTo(vertexes[i - 1]);
  2158. }
  2159. return len;
  2160. };
  2161. _proto._hitTestTolerance = function _hitTestTolerance() {
  2162. var symbol = this._getInternalSymbol();
  2163. var w;
  2164. if (Array.isArray(symbol)) {
  2165. w = 0;
  2166. for (var i = 0; i < symbol.length; i++) {
  2167. if (isNumber(symbol[i]['lineWidth'])) {
  2168. if (symbol[i]['lineWidth'] > w) {
  2169. w = symbol[i]['lineWidth'];
  2170. }
  2171. }
  2172. }
  2173. } else {
  2174. w = symbol['lineWidth'];
  2175. }
  2176. return isNumber(w) ? w / 2 : 1.5;
  2177. };
  2178. _proto._coords2Extent = function _coords2Extent(coords, proj) {
  2179. var result = new Extent(proj);
  2180. for (var i = 0, l = coords.length; i < l; i++) {
  2181. for (var j = 0, ll = coords[i].length; j < ll; j++) {
  2182. result._combine(coords[i][j]);
  2183. }
  2184. }
  2185. return result;
  2186. };
  2187. return Path;
  2188. }(Geometry);
  2189. Path.mergeOptions(options$3);
  2190. var Position = function () {
  2191. function Position(x, y) {
  2192. if (!isNil(x) && !isNil(y)) {
  2193. this.x = +x;
  2194. this.y = +y;
  2195. } else if (!isNil(x.x) && !isNil(x.y)) {
  2196. this.x = +x.x;
  2197. this.y = +x.y;
  2198. } else if (Array.isArray(x)) {
  2199. this.x = +x[0];
  2200. this.y = +x[1];
  2201. }
  2202. if (this._isNaN()) {
  2203. throw new Error('Position is NaN');
  2204. }
  2205. }
  2206. var _proto = Position.prototype;
  2207. _proto.abs = function abs() {
  2208. return new this.constructor(Math.abs(this.x), Math.abs(this.y));
  2209. };
  2210. _proto._abs = function _abs() {
  2211. this.x = Math.abs(this.x);
  2212. this.y = Math.abs(this.y);
  2213. return this;
  2214. };
  2215. _proto._round = function _round() {
  2216. this.x = Math.round(this.x);
  2217. this.y = Math.round(this.y);
  2218. return this;
  2219. };
  2220. _proto.round = function round() {
  2221. return new this.constructor(Math.round(this.x), Math.round(this.y));
  2222. };
  2223. _proto._ceil = function _ceil() {
  2224. this.x = Math.ceil(this.x);
  2225. this.y = Math.ceil(this.y);
  2226. return this;
  2227. };
  2228. _proto.ceil = function ceil() {
  2229. return new this.constructor(Math.ceil(this.x), Math.ceil(this.y));
  2230. };
  2231. _proto._floor = function _floor() {
  2232. this.x = Math.floor(this.x);
  2233. this.y = Math.floor(this.y);
  2234. return this;
  2235. };
  2236. _proto.floor = function floor() {
  2237. return new this.constructor(Math.floor(this.x), Math.floor(this.y));
  2238. };
  2239. _proto.copy = function copy() {
  2240. return new this.constructor(this.x, this.y);
  2241. };
  2242. _proto._add = function _add(x, y) {
  2243. if (!isNil(x.x)) {
  2244. this.x += x.x;
  2245. this.y += x.y;
  2246. } else if (!isNil(x[0])) {
  2247. this.x += x[0];
  2248. this.y += x[1];
  2249. } else {
  2250. this.x += x;
  2251. this.y += y;
  2252. }
  2253. return this;
  2254. };
  2255. _proto.add = function add(x, y) {
  2256. var nx, ny;
  2257. if (!isNil(x.x)) {
  2258. nx = this.x + x.x;
  2259. ny = this.y + x.y;
  2260. } else if (!isNil(x[0])) {
  2261. nx = this.x + x[0];
  2262. ny = this.y + x[1];
  2263. } else {
  2264. nx = this.x + x;
  2265. ny = this.y + y;
  2266. }
  2267. return new this.constructor(nx, ny);
  2268. };
  2269. _proto._sub = function _sub(x, y) {
  2270. if (!isNil(x.x)) {
  2271. this.x -= x.x;
  2272. this.y -= x.y;
  2273. } else if (!isNil(x[0])) {
  2274. this.x -= x[0];
  2275. this.y -= x[1];
  2276. } else {
  2277. this.x -= x;
  2278. this.y -= y;
  2279. }
  2280. return this;
  2281. };
  2282. _proto._substract = function _substract() {
  2283. return this._sub.apply(this, arguments);
  2284. };
  2285. _proto.sub = function sub(x, y) {
  2286. var nx, ny;
  2287. if (!isNil(x.x)) {
  2288. nx = this.x - x.x;
  2289. ny = this.y - x.y;
  2290. } else if (!isNil(x[0])) {
  2291. nx = this.x - x[0];
  2292. ny = this.y - x[1];
  2293. } else {
  2294. nx = this.x - x;
  2295. ny = this.y - y;
  2296. }
  2297. return new this.constructor(nx, ny);
  2298. };
  2299. _proto.substract = function substract() {
  2300. return this.sub.apply(this, arguments);
  2301. };
  2302. _proto.multi = function multi(ratio) {
  2303. return new this.constructor(this.x * ratio, this.y * ratio);
  2304. };
  2305. _proto._multi = function _multi(ratio) {
  2306. this.x *= ratio;
  2307. this.y *= ratio;
  2308. return this;
  2309. };
  2310. _proto.div = function div(n) {
  2311. return this.multi(1 / n);
  2312. };
  2313. _proto._div = function _div(n) {
  2314. return this._multi(1 / n);
  2315. };
  2316. _proto.equals = function equals(c) {
  2317. if (!(c instanceof this.constructor)) {
  2318. return false;
  2319. }
  2320. return this.x === c.x && this.y === c.y;
  2321. };
  2322. _proto._isNaN = function _isNaN() {
  2323. return isNaN(this.x) || isNaN(this.y);
  2324. };
  2325. _proto.isZero = function isZero() {
  2326. return this.x === 0 && this.y === 0;
  2327. };
  2328. _proto.toArray = function toArray() {
  2329. return [this.x, this.y];
  2330. };
  2331. _proto.toFixed = function toFixed(n) {
  2332. return new this.constructor(this.x.toFixed(n), this.y.toFixed(n));
  2333. };
  2334. _proto.toJSON = function toJSON() {
  2335. return {
  2336. x: this.x,
  2337. y: this.y
  2338. };
  2339. };
  2340. return Position;
  2341. }();
  2342. var Point = function (_Position) {
  2343. _inheritsLoose(Point, _Position);
  2344. function Point() {
  2345. return _Position.apply(this, arguments) || this;
  2346. }
  2347. var _proto = Point.prototype;
  2348. _proto.closeTo = function closeTo(p, delta) {
  2349. if (!delta) {
  2350. delta = 0;
  2351. }
  2352. return this.x >= p.x - delta && this.x <= p.x + delta && this.y >= p.y - delta && this.y <= p.y + delta;
  2353. };
  2354. _proto.distanceTo = function distanceTo(point) {
  2355. var x = point.x - this.x,
  2356. y = point.y - this.y;
  2357. return Math.sqrt(x * x + y * y);
  2358. };
  2359. _proto.mag = function mag() {
  2360. return Math.sqrt(this.x * this.x + this.y * this.y);
  2361. };
  2362. _proto.unit = function unit() {
  2363. return this.copy()._unit();
  2364. };
  2365. _proto._unit = function _unit() {
  2366. this._div(this.mag());
  2367. return this;
  2368. };
  2369. _proto.perp = function perp() {
  2370. return this.copy()._perp();
  2371. };
  2372. _proto._perp = function _perp() {
  2373. var y = this.y;
  2374. this.y = this.x;
  2375. this.x = -y;
  2376. return this;
  2377. };
  2378. _proto.angleWith = function angleWith(b) {
  2379. return this.angleWithSep(b.x, b.y);
  2380. };
  2381. _proto.angleWithSep = function angleWithSep(x, y) {
  2382. return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
  2383. };
  2384. _proto._rotate = function _rotate(angle) {
  2385. var cos = Math.cos(angle),
  2386. sin = Math.sin(angle),
  2387. x = cos * this.x - sin * this.y,
  2388. y = sin * this.x + cos * this.y;
  2389. this.x = x;
  2390. this.y = y;
  2391. return this;
  2392. };
  2393. _proto.rotate = function rotate(a) {
  2394. return this.copy()._rotate(a);
  2395. };
  2396. return Point;
  2397. }(Position);
  2398. var Identity = extend({
  2399. 'measure': 'IDENTITY',
  2400. measureLenBetween: function measureLenBetween(c1, c2) {
  2401. if (!c1 || !c2) {
  2402. return 0;
  2403. }
  2404. try {
  2405. return Math.sqrt(Math.pow(c1.x - c2.x, 2) + Math.pow(c1.y - c2.y, 2));
  2406. } catch (err) {
  2407. return 0;
  2408. }
  2409. },
  2410. measureArea: function measureArea(coordinates) {
  2411. if (!Array.isArray(coordinates)) {
  2412. return 0;
  2413. }
  2414. var area = 0;
  2415. for (var i = 0, len = coordinates.length; i < len; i++) {
  2416. var c1 = coordinates[i];
  2417. var c2 = null;
  2418. if (i === len - 1) {
  2419. c2 = coordinates[0];
  2420. } else {
  2421. c2 = coordinates[i + 1];
  2422. }
  2423. area += c1.x * c2.y - c1.y * c2.x;
  2424. }
  2425. return Math.abs(area / 2);
  2426. },
  2427. locate: function locate(c, xDist, yDist) {
  2428. c = new Coordinate(c.x, c.y);
  2429. return this._locate(c, xDist, yDist);
  2430. },
  2431. _locate: function _locate(c, xDist, yDist) {
  2432. if (!c) {
  2433. return null;
  2434. }
  2435. if (!xDist) {
  2436. xDist = 0;
  2437. }
  2438. if (!yDist) {
  2439. yDist = 0;
  2440. }
  2441. if (!xDist && !yDist) {
  2442. return c;
  2443. }
  2444. c.x = c.x + xDist;
  2445. c.y = c.y + yDist;
  2446. return c;
  2447. },
  2448. rotate: function rotate(c, pivot, angle) {
  2449. c = new Coordinate(c.x, c.y);
  2450. return this._rotate(c, pivot, angle);
  2451. },
  2452. _rotate: function () {
  2453. var tmp = new Point(0, 0);
  2454. return function (c, pivot, angle) {
  2455. tmp.x = c.x - pivot.x;
  2456. tmp.y = c.y - pivot.y;
  2457. tmp._rotate(angle * Math.PI / 180);
  2458. c.x = pivot.x + tmp.x;
  2459. c.y = pivot.y + tmp.y;
  2460. return c;
  2461. };
  2462. }()
  2463. }, Common$1);
  2464. function _assertThisInitialized(self) {
  2465. if (self === void 0) {
  2466. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  2467. }
  2468. return self;
  2469. }
  2470. var uid = 0;
  2471. function UID() {
  2472. return uid++;
  2473. }
  2474. var DefaultSpatialRef = {
  2475. 'EPSG:3857': {
  2476. 'resolutions': function () {
  2477. var resolutions = [];
  2478. var d = 2 * 6378137 * Math.PI;
  2479. for (var i = 0; i < 21; i++) {
  2480. resolutions[i] = d / (256 * Math.pow(2, i));
  2481. }
  2482. return resolutions;
  2483. }(),
  2484. 'fullExtent': {
  2485. 'top': 6378137 * Math.PI,
  2486. 'left': -6378137 * Math.PI,
  2487. 'bottom': -6378137 * Math.PI,
  2488. 'right': 6378137 * Math.PI
  2489. }
  2490. },
  2491. 'EPSG:4326': {
  2492. 'fullExtent': {
  2493. 'top': 90,
  2494. 'left': -180,
  2495. 'bottom': -90,
  2496. 'right': 180
  2497. },
  2498. 'resolutions': function () {
  2499. var resolutions = [];
  2500. for (var i = 0; i < 20; i++) {
  2501. resolutions[i] = 180 / (Math.pow(2, i) * 128);
  2502. }
  2503. return resolutions;
  2504. }()
  2505. },
  2506. 'BAIDU': {
  2507. 'resolutions': function () {
  2508. var res = Math.pow(2, 18);
  2509. var resolutions = [];
  2510. for (var i = 0; i < 20; i++) {
  2511. resolutions[i] = res;
  2512. res *= 0.5;
  2513. }
  2514. resolutions[0] = null;
  2515. resolutions[1] = null;
  2516. resolutions[2] = null;
  2517. return resolutions;
  2518. }(),
  2519. 'fullExtent': {
  2520. 'top': 33554432,
  2521. 'left': -33554432,
  2522. 'bottom': -33554432,
  2523. 'right': 33554432
  2524. }
  2525. },
  2526. 'IDENTITY': {
  2527. 'resolutions': function () {
  2528. var res = Math.pow(2, 8);
  2529. var resolutions = [];
  2530. for (var i = 0; i < 18; i++) {
  2531. resolutions[i] = res;
  2532. res *= 0.5;
  2533. }
  2534. return resolutions;
  2535. }(),
  2536. 'fullExtent': {
  2537. 'top': 200000,
  2538. 'left': -200000,
  2539. 'bottom': -200000,
  2540. 'right': 200000
  2541. }
  2542. }
  2543. };
  2544. DefaultSpatialRef['EPSG:4490'] = DefaultSpatialRef['EPSG:4326'];
  2545. var Coordinate = function (_Position) {
  2546. _inheritsLoose(Coordinate, _Position);
  2547. function Coordinate() {
  2548. return _Position.apply(this, arguments) || this;
  2549. }
  2550. Coordinate.toNumberArrays = function toNumberArrays(coordinates) {
  2551. if (!Array.isArray(coordinates)) {
  2552. return [coordinates.x, coordinates.y];
  2553. }
  2554. return forEachCoord(coordinates, function (coord) {
  2555. return [coord.x, coord.y];
  2556. });
  2557. };
  2558. Coordinate.toCoordinates = function toCoordinates(coordinates) {
  2559. if (isNumber(coordinates[0]) && isNumber(coordinates[1])) {
  2560. return new Coordinate(coordinates);
  2561. }
  2562. var result = [];
  2563. for (var i = 0, len = coordinates.length; i < len; i++) {
  2564. var child = coordinates[i];
  2565. if (Array.isArray(child)) {
  2566. if (isNumber(child[0])) {
  2567. result.push(new Coordinate(child));
  2568. } else {
  2569. result.push(Coordinate.toCoordinates(child));
  2570. }
  2571. } else {
  2572. result.push(new Coordinate(child));
  2573. }
  2574. }
  2575. return result;
  2576. };
  2577. return Coordinate;
  2578. }(Position);
  2579. var JSON_TYPE = 'Polygon';
  2580. var Polygon = function (_Path) {
  2581. _inheritsLoose(Polygon, _Path);
  2582. function Polygon(coordinates, opts) {
  2583. var _this;
  2584. _this = _Path.call(this, opts) || this;
  2585. _this.type = 'Polygon';
  2586. if (coordinates) {
  2587. _this.setCoordinates(coordinates);
  2588. }
  2589. return _this;
  2590. }
  2591. var _proto = Polygon.prototype;
  2592. _proto.setCoordinates = function setCoordinates(coordinates) {
  2593. if (!coordinates) {
  2594. this._coordinates = null;
  2595. this._holes = null;
  2596. this._projectRings();
  2597. return this;
  2598. }
  2599. var rings = Coordinate.toCoordinates(coordinates);
  2600. var len = rings.length;
  2601. if (!Array.isArray(rings[0])) {
  2602. this._coordinates = this._trimRing(rings);
  2603. } else {
  2604. this._coordinates = this._trimRing(rings[0]);
  2605. if (len > 1) {
  2606. var holes = [];
  2607. for (var i = 1; i < len; i++) {
  2608. if (!rings[i]) {
  2609. continue;
  2610. }
  2611. holes.push(this._trimRing(rings[i]));
  2612. }
  2613. this._holes = holes;
  2614. }
  2615. }
  2616. this._projectRings();
  2617. return this;
  2618. };
  2619. _proto.getCoordinates = function getCoordinates() {
  2620. if (!this._coordinates) {
  2621. return [];
  2622. }
  2623. var holes = this.getHoles();
  2624. var rings = [this._copyAndCloseRing(this._coordinates)];
  2625. for (var i = 0, l = holes.length; i < l; i++) {
  2626. rings.push(this._copyAndCloseRing(holes[i]));
  2627. }
  2628. return rings;
  2629. };
  2630. _proto.getCenterInExtent = function getCenterInExtent(extent) {
  2631. return this._getCenterInExtent(extent, this.getShell(), clipPolygon);
  2632. };
  2633. _proto.getShell = function getShell() {
  2634. return this._coordinates || [];
  2635. };
  2636. _proto.getHoles = function getHoles() {
  2637. return this._holes || [];
  2638. };
  2639. _proto.hasHoles = function hasHoles() {
  2640. return this.getHoles().length > 0;
  2641. };
  2642. _proto._projectRings = function _projectRings() {
  2643. if (!this.getMap()) {
  2644. this.onShapeChanged();
  2645. return;
  2646. }
  2647. this._prjCoords = this._projectCoords(this._coordinates);
  2648. this._prjHoles = this._projectCoords(this._holes);
  2649. this.onShapeChanged();
  2650. };
  2651. _proto._cleanRing = function _cleanRing(ring) {
  2652. for (var i = ring.length - 1; i >= 0; i--) {
  2653. if (!ring[i]) {
  2654. ring.splice(i, 1);
  2655. }
  2656. }
  2657. };
  2658. _proto._checkRing = function _checkRing(ring) {
  2659. this._cleanRing(ring);
  2660. if (!ring || !isArrayHasData(ring)) {
  2661. return false;
  2662. }
  2663. var lastPoint = ring[ring.length - 1];
  2664. var isClose = true;
  2665. if (ring[0].x !== lastPoint.x || ring[0].y !== lastPoint.y) {
  2666. isClose = false;
  2667. }
  2668. return isClose;
  2669. };
  2670. _proto._trimRing = function _trimRing(ring) {
  2671. var isClose = this._checkRing(ring);
  2672. if (isArrayHasData(ring) && isClose) {
  2673. ring.splice(ring.length - 1, 1);
  2674. }
  2675. return ring;
  2676. };
  2677. _proto._copyAndCloseRing = function _copyAndCloseRing(ring) {
  2678. ring = ring.slice(0);
  2679. var isClose = this._checkRing(ring);
  2680. if (isArrayHasData(ring) && !isClose) {
  2681. ring.push(ring[0].copy());
  2682. return ring;
  2683. } else {
  2684. return ring;
  2685. }
  2686. };
  2687. _proto._getPrjShell = function _getPrjShell() {
  2688. if (this.getJSONType() === JSON_TYPE) {
  2689. return this._getPrjCoordinates();
  2690. }
  2691. var projection = this._getProjection();
  2692. if (!projection) {
  2693. return null;
  2694. }
  2695. this._verifyProjection();
  2696. if (!this._prjShell) {
  2697. this._prjShell = this._projectCoords(this.getShell());
  2698. }
  2699. return this._prjShell;
  2700. };
  2701. _proto._getPrjHoles = function _getPrjHoles() {
  2702. var projection = this._getProjection();
  2703. if (!projection) {
  2704. return null;
  2705. }
  2706. this._verifyProjection();
  2707. if (!this._prjHoles) {
  2708. this._prjHoles = this._projectCoords(this.getHoles());
  2709. }
  2710. return this._prjHoles;
  2711. };
  2712. _proto._computeGeodesicLength = function _computeGeodesicLength(measurer) {
  2713. var rings = this.getCoordinates();
  2714. if (!isArrayHasData(rings)) {
  2715. return 0;
  2716. }
  2717. var result = 0;
  2718. for (var i = 0, len = rings.length; i < len; i++) {
  2719. result += measurer.measureLength(rings[i]);
  2720. }
  2721. return result;
  2722. };
  2723. _proto._computeGeodesicArea = function _computeGeodesicArea(measurer) {
  2724. var rings = this.getCoordinates();
  2725. if (!isArrayHasData(rings)) {
  2726. return 0;
  2727. }
  2728. var result = measurer.measureArea(rings[0]);
  2729. for (var i = 1, len = rings.length; i < len; i++) {
  2730. result -= measurer.measureArea(rings[i]);
  2731. }
  2732. return result;
  2733. };
  2734. _proto._updateCache = function _updateCache() {
  2735. _Path.prototype._updateCache.call(this);
  2736. if (this._prjHoles) {
  2737. this._holes = this._unprojectCoords(this._getPrjHoles());
  2738. }
  2739. };
  2740. _proto._clearCache = function _clearCache() {
  2741. delete this._prjShell;
  2742. return _Path.prototype._clearCache.call(this);
  2743. };
  2744. _proto._clearProjection = function _clearProjection() {
  2745. if (this._prjHoles) {
  2746. this._prjHoles = null;
  2747. }
  2748. if (this._prjShell) {
  2749. this._prjShell = null;
  2750. }
  2751. _Path.prototype._clearProjection.call(this);
  2752. };
  2753. return Polygon;
  2754. }(Path);
  2755. Polygon.registerJSONType(JSON_TYPE);
  2756. var options$5 = {
  2757. 'arrowStyle': null,
  2758. 'arrowPlacement': 'vertex-last'
  2759. };
  2760. var LineString = function (_Path) {
  2761. _inheritsLoose(LineString, _Path);
  2762. function LineString(coordinates, options) {
  2763. var _this;
  2764. _this = _Path.call(this, options) || this;
  2765. _this.type = 'LineString';
  2766. if (coordinates) {
  2767. _this.setCoordinates(coordinates);
  2768. }
  2769. return _this;
  2770. }
  2771. var _proto = LineString.prototype;
  2772. _proto.setCoordinates = function setCoordinates(coordinates) {
  2773. if (!coordinates) {
  2774. this._coordinates = null;
  2775. this._setPrjCoordinates(null);
  2776. return this;
  2777. }
  2778. this._coordinates = Coordinate.toCoordinates(coordinates);
  2779. if (this.getMap()) {
  2780. this._setPrjCoordinates(this._projectCoords(this._coordinates));
  2781. } else {
  2782. this.onShapeChanged();
  2783. }
  2784. return this;
  2785. };
  2786. _proto.getCoordinates = function getCoordinates() {
  2787. return this._coordinates || [];
  2788. };
  2789. _proto.getCenterInExtent = function getCenterInExtent(extent) {
  2790. return this._getCenterInExtent(extent, this.getCoordinates(), clipLine);
  2791. };
  2792. _proto._computeGeodesicLength = function _computeGeodesicLength(measurer) {
  2793. return measurer.measureLength(this.getCoordinates());
  2794. };
  2795. _proto._computeGeodesicArea = function _computeGeodesicArea() {
  2796. return 0;
  2797. };
  2798. return LineString;
  2799. }(Path);
  2800. LineString.mergeOptions(options$5);
  2801. LineString.registerJSONType('LineString');
  2802. var GeometryCollection = function (_Geometry) {
  2803. _inheritsLoose(GeometryCollection, _Geometry);
  2804. function GeometryCollection(geometries, opts) {
  2805. var _this;
  2806. _this = _Geometry.call(this, opts) || this;
  2807. _this.type = 'GeometryCollection';
  2808. _this.setGeometries(geometries);
  2809. return _this;
  2810. }
  2811. var _proto = GeometryCollection.prototype;
  2812. _proto.setGeometries = function setGeometries(_geometries) {
  2813. var geometries = this._checkGeometries(_geometries || []);
  2814. var symbol = this._getSymbol();
  2815. var options = this.config();
  2816. for (var i = geometries.length - 1; i >= 0; i--) {
  2817. geometries[i]._initOptions(options);
  2818. geometries[i]._setParent(this);
  2819. geometries[i]._setEventParent(this);
  2820. if (symbol) {
  2821. geometries[i].setSymbol(symbol);
  2822. }
  2823. }
  2824. this._geometries = geometries;
  2825. if (this.getLayer()) {
  2826. this._bindGeometriesToLayer();
  2827. this.onShapeChanged();
  2828. }
  2829. return this;
  2830. };
  2831. _proto.getGeometries = function getGeometries() {
  2832. return this._geometries || [];
  2833. };
  2834. _proto.forEach = function forEach(fn, context) {
  2835. var geometries = this.getGeometries();
  2836. for (var i = 0, l = geometries.length; i < l; i++) {
  2837. if (!geometries[i]) {
  2838. continue;
  2839. }
  2840. if (!context) {
  2841. fn(geometries[i], i);
  2842. } else {
  2843. fn.call(context, geometries[i], i);
  2844. }
  2845. }
  2846. return this;
  2847. };
  2848. _proto.filter = function filter(fn, context) {
  2849. if (!fn) {
  2850. return new GeometryCollection();
  2851. }
  2852. var selected = [];
  2853. var isFn = isFunction(fn);
  2854. var filter = isFn ? fn : createFilter(fn);
  2855. this.forEach(function (geometry) {
  2856. var g = isFn ? geometry : getFilterFeature(geometry);
  2857. if (context ? filter.call(context, g) : filter(g)) {
  2858. selected.push(geometry);
  2859. }
  2860. }, this);
  2861. return new GeometryCollection(selected);
  2862. };
  2863. _proto.translate = function translate(offset) {
  2864. if (!offset) {
  2865. return this;
  2866. }
  2867. if (this.isEmpty()) {
  2868. return this;
  2869. }
  2870. var args = arguments;
  2871. this.forEach(function (geometry) {
  2872. if (geometry && geometry.translate) {
  2873. geometry.translate.apply(geometry, args);
  2874. }
  2875. });
  2876. return this;
  2877. };
  2878. _proto.isEmpty = function isEmpty() {
  2879. return !isArrayHasData(this.getGeometries());
  2880. };
  2881. _proto.remove = function remove() {
  2882. this.forEach(function (geometry) {
  2883. geometry._unbind();
  2884. });
  2885. return Geometry.prototype.remove.apply(this, arguments);
  2886. };
  2887. _proto.show = function show() {
  2888. this.options['visible'] = true;
  2889. this.forEach(function (geometry) {
  2890. geometry.show();
  2891. });
  2892. return this;
  2893. };
  2894. _proto.hide = function hide() {
  2895. this.options['visible'] = false;
  2896. this.forEach(function (geometry) {
  2897. geometry.hide();
  2898. });
  2899. return this;
  2900. };
  2901. _proto.onConfig = function onConfig(config) {
  2902. this.forEach(function (geometry) {
  2903. geometry.config(config);
  2904. });
  2905. };
  2906. _proto.getSymbol = function getSymbol() {
  2907. var s = _Geometry.prototype.getSymbol.call(this);
  2908. if (!s) {
  2909. var symbols = [];
  2910. var is = false;
  2911. this.forEach(function (g) {
  2912. var symbol = g.getSymbol();
  2913. if (symbol && !is) {
  2914. is = true;
  2915. }
  2916. symbols.push(g.getSymbol());
  2917. });
  2918. if (is) {
  2919. s = {
  2920. 'children': symbols
  2921. };
  2922. }
  2923. }
  2924. return s;
  2925. };
  2926. _proto.setSymbol = function setSymbol(s) {
  2927. if (s && s['children']) {
  2928. this._symbol = null;
  2929. this.forEach(function (g, i) {
  2930. g.setSymbol(s['children'][i]);
  2931. });
  2932. } else {
  2933. var symbol = this._prepareSymbol(s);
  2934. this._symbol = symbol;
  2935. this.forEach(function (g) {
  2936. g.setSymbol(symbol);
  2937. });
  2938. }
  2939. this.onSymbolChanged();
  2940. return this;
  2941. };
  2942. _proto._setExternSymbol = function _setExternSymbol(symbol) {
  2943. symbol = this._prepareSymbol(symbol);
  2944. this._externSymbol = symbol;
  2945. this.forEach(function (geometry) {
  2946. geometry._setExternSymbol(symbol);
  2947. });
  2948. this.onSymbolChanged();
  2949. return this;
  2950. };
  2951. _proto._bindLayer = function _bindLayer() {
  2952. _Geometry.prototype._bindLayer.apply(this, arguments);
  2953. this._bindGeometriesToLayer();
  2954. };
  2955. _proto._bindGeometriesToLayer = function _bindGeometriesToLayer() {
  2956. var layer = this.getLayer();
  2957. this.forEach(function (geometry) {
  2958. geometry._bindLayer(layer);
  2959. });
  2960. };
  2961. _proto._checkGeometries = function _checkGeometries(geometries) {
  2962. var invalidGeoError = 'The geometry added to collection is invalid.';
  2963. if (geometries && !Array.isArray(geometries)) {
  2964. if (geometries instanceof Geometry) {
  2965. return [geometries];
  2966. } else {
  2967. throw new Error(invalidGeoError);
  2968. }
  2969. } else {
  2970. for (var i = 0, l = geometries.length; i < l; i++) {
  2971. if (!this._checkGeo(geometries[i])) {
  2972. throw new Error(invalidGeoError + ' Index: ' + i);
  2973. }
  2974. }
  2975. return geometries;
  2976. }
  2977. };
  2978. _proto._checkGeo = function _checkGeo(geo) {
  2979. return geo instanceof Geometry;
  2980. };
  2981. _proto._updateCache = function _updateCache() {
  2982. this._clearCache();
  2983. if (this.isEmpty()) {
  2984. return;
  2985. }
  2986. this.forEach(function (geometry) {
  2987. if (geometry && geometry._updateCache) {
  2988. geometry._updateCache();
  2989. }
  2990. });
  2991. };
  2992. _proto._removePainter = function _removePainter() {
  2993. if (this._painter) {
  2994. this._painter.remove();
  2995. }
  2996. delete this._painter;
  2997. this.forEach(function (geometry) {
  2998. geometry._removePainter();
  2999. });
  3000. };
  3001. _proto._computeCenter = function _computeCenter(projection) {
  3002. if (!projection || this.isEmpty()) {
  3003. return null;
  3004. }
  3005. var sumX = 0,
  3006. sumY = 0,
  3007. counter = 0;
  3008. var geometries = this.getGeometries();
  3009. for (var i = 0, l = geometries.length; i < l; i++) {
  3010. if (!geometries[i]) {
  3011. continue;
  3012. }
  3013. var center = geometries[i]._computeCenter(projection);
  3014. if (center) {
  3015. sumX += center.x;
  3016. sumY += center.y;
  3017. counter++;
  3018. }
  3019. }
  3020. if (counter === 0) {
  3021. return null;
  3022. }
  3023. return new Coordinate(sumX / counter, sumY / counter);
  3024. };
  3025. _proto._containsPoint = function _containsPoint(point, t) {
  3026. if (this.isEmpty()) {
  3027. return false;
  3028. }
  3029. var geometries = this.getGeometries();
  3030. for (var i = 0, l = geometries.length; i < l; i++) {
  3031. if (geometries[i]._containsPoint(point, t)) {
  3032. return true;
  3033. }
  3034. }
  3035. return false;
  3036. };
  3037. _proto._computeExtent = function _computeExtent(projection) {
  3038. return computeExtent$1.call(this, projection, '_computeExtent');
  3039. };
  3040. _proto._computePrjExtent = function _computePrjExtent(projection) {
  3041. return computeExtent$1.call(this, projection, '_computePrjExtent');
  3042. };
  3043. _proto._computeGeodesicLength = function _computeGeodesicLength(projection) {
  3044. if (!projection || this.isEmpty()) {
  3045. return 0;
  3046. }
  3047. var geometries = this.getGeometries();
  3048. var result = 0;
  3049. for (var i = 0, l = geometries.length; i < l; i++) {
  3050. if (!geometries[i]) {
  3051. continue;
  3052. }
  3053. result += geometries[i]._computeGeodesicLength(projection);
  3054. }
  3055. return result;
  3056. };
  3057. _proto._computeGeodesicArea = function _computeGeodesicArea(projection) {
  3058. if (!projection || this.isEmpty()) {
  3059. return 0;
  3060. }
  3061. var geometries = this.getGeometries();
  3062. var result = 0;
  3063. for (var i = 0, l = geometries.length; i < l; i++) {
  3064. if (!geometries[i]) {
  3065. continue;
  3066. }
  3067. result += geometries[i]._computeGeodesicArea(projection);
  3068. }
  3069. return result;
  3070. };
  3071. _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
  3072. var children = [];
  3073. if (!this.isEmpty()) {
  3074. var geometries = this.getGeometries();
  3075. for (var i = 0, l = geometries.length; i < l; i++) {
  3076. if (!geometries[i]) {
  3077. continue;
  3078. }
  3079. children.push(geometries[i]._exportGeoJSONGeometry());
  3080. }
  3081. }
  3082. return {
  3083. 'type': 'GeometryCollection',
  3084. 'geometries': children
  3085. };
  3086. };
  3087. _proto._clearProjection = function _clearProjection() {
  3088. if (this.isEmpty()) {
  3089. return;
  3090. }
  3091. var geometries = this.getGeometries();
  3092. for (var i = 0, l = geometries.length; i < l; i++) {
  3093. if (!geometries[i]) {
  3094. continue;
  3095. }
  3096. geometries[i]._clearProjection();
  3097. }
  3098. };
  3099. _proto._getConnectPoints = function _getConnectPoints() {
  3100. var extent = this.getExtent();
  3101. var anchors = [new Coordinate(extent.xmin, extent.ymax), new Coordinate(extent.xmax, extent.ymin), new Coordinate(extent.xmin, extent.ymin), new Coordinate(extent.xmax, extent.ymax)];
  3102. return anchors;
  3103. };
  3104. _proto._getExternalResources = function _getExternalResources() {
  3105. if (this.isEmpty()) {
  3106. return [];
  3107. }
  3108. var geometries = this.getGeometries(),
  3109. resources = [];
  3110. var cache = {};
  3111. var symbol, res, key;
  3112. for (var i = 0, l = geometries.length; i < l; i++) {
  3113. if (!geometries[i]) {
  3114. continue;
  3115. }
  3116. symbol = geometries[i]._getInternalSymbol();
  3117. res = getExternalResources(symbol);
  3118. for (var ii = 0, ll = res.length; ii < ll; ii++) {
  3119. key = res[ii].join();
  3120. if (!cache[key]) {
  3121. resources.push(res[ii]);
  3122. cache[key] = 1;
  3123. }
  3124. }
  3125. }
  3126. return resources;
  3127. };
  3128. _proto.startEdit = function startEdit(opts) {
  3129. var _this2 = this;
  3130. if (this.isEmpty()) {
  3131. return this;
  3132. }
  3133. if (!opts) {
  3134. opts = {};
  3135. }
  3136. if (opts['symbol']) {
  3137. this._originalSymbol = this.getSymbol();
  3138. this.setSymbol(opts['symbol']);
  3139. }
  3140. this._draggbleBeforeEdit = this.options['draggable'];
  3141. this.config('draggable', false);
  3142. var geometries = this.getGeometries();
  3143. for (var i = 0, l = geometries.length; i < l; i++) {
  3144. geometries[i].startEdit(opts);
  3145. }
  3146. this._editing = true;
  3147. this.hide();
  3148. setTimeout(function () {
  3149. _this2.fire('editstart');
  3150. }, 1);
  3151. return this;
  3152. };
  3153. _proto.endEdit = function endEdit() {
  3154. if (this.isEmpty()) {
  3155. return this;
  3156. }
  3157. var geometries = this.getGeometries();
  3158. for (var i = 0, l = geometries.length; i < l; i++) {
  3159. geometries[i].endEdit();
  3160. }
  3161. if (this._originalSymbol) {
  3162. this.setSymbol(this._originalSymbol);
  3163. delete this._originalSymbol;
  3164. }
  3165. this._editing = false;
  3166. this.show();
  3167. this.config('draggable', this._draggbleBeforeEdit);
  3168. this.fire('editend');
  3169. return this;
  3170. };
  3171. _proto.isEditing = function isEditing() {
  3172. if (!this._editing) {
  3173. return false;
  3174. }
  3175. return true;
  3176. };
  3177. return GeometryCollection;
  3178. }(Geometry);
  3179. GeometryCollection.registerJSONType('GeometryCollection');
  3180. function toGeometry(geoJSON) {
  3181. if (isString(geoJSON)) {
  3182. geoJSON = parseJSON(geoJSON);
  3183. }
  3184. if (Array.isArray(geoJSON)) {
  3185. var resultGeos = [];
  3186. for (var i = 0, len = geoJSON.length; i < len; i++) {
  3187. var geo = _convert(geoJSON[i]);
  3188. if (Array.isArray(geo)) {
  3189. pushIn(resultGeos, geo);
  3190. } else {
  3191. resultGeos.push(geo);
  3192. }
  3193. }
  3194. return resultGeos;
  3195. } else {
  3196. var resultGeo = GeoJSON._convert(geoJSON);
  3197. return resultGeo;
  3198. }
  3199. }
  3200. var MultiGeometry = function (_GeometryCollection) {
  3201. _inheritsLoose(MultiGeometry, _GeometryCollection);
  3202. function MultiGeometry(geoType, type, data, options) {
  3203. var _this;
  3204. _this = _GeometryCollection.call(this, null, options) || this;
  3205. _this.GeometryType = geoType;
  3206. _this.type = type;
  3207. _this._initData(data);
  3208. return _this;
  3209. }
  3210. var _proto = MultiGeometry.prototype;
  3211. _proto.getCoordinates = function getCoordinates() {
  3212. var coordinates = [];
  3213. var geometries = this.getGeometries();
  3214. for (var i = 0, l = geometries.length; i < l; i++) {
  3215. var child = geometries[i];
  3216. coordinates.push(child.getShell && child.getJSONType() !== 'Polygon' ? [child.getShell()] : child.getCoordinates());
  3217. }
  3218. return coordinates;
  3219. };
  3220. _proto.setCoordinates = function setCoordinates(coordinates) {
  3221. coordinates = coordinates || [];
  3222. var geometries = [];
  3223. for (var i = 0, l = coordinates.length; i < l; i++) {
  3224. var g = new this.GeometryType(coordinates[i], this.config());
  3225. geometries.push(g);
  3226. }
  3227. this.setGeometries(geometries);
  3228. return this;
  3229. };
  3230. _proto._initData = function _initData(data) {
  3231. data = data || [];
  3232. if (data.length) {
  3233. if (data[0] instanceof this.GeometryType) {
  3234. this.setGeometries(data);
  3235. } else {
  3236. this.setCoordinates(data);
  3237. }
  3238. }
  3239. };
  3240. _proto._checkGeo = function _checkGeo(geo) {
  3241. return geo instanceof this.GeometryType;
  3242. };
  3243. _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
  3244. var points = this.getCoordinates();
  3245. var coordinates = Coordinate.toNumberArrays(points);
  3246. return {
  3247. 'type': this.getType(),
  3248. 'coordinates': coordinates
  3249. };
  3250. };
  3251. return MultiGeometry;
  3252. }(GeometryCollection);
  3253. var MultiPoint = function (_MultiGeometry) {
  3254. _inheritsLoose(MultiPoint, _MultiGeometry);
  3255. function MultiPoint(data, opts) {
  3256. return _MultiGeometry.call(this, Marker, 'MultiPoint', data, opts) || this;
  3257. }
  3258. var _proto = MultiPoint.prototype;
  3259. _proto.findClosest = function findClosest(coordinate) {
  3260. if (!coordinate) {
  3261. return null;
  3262. }
  3263. var coords = this.getCoordinates();
  3264. var hit = null;
  3265. var max = Infinity;
  3266. coords.forEach(function (c) {
  3267. var dist = distanceTo(c, coordinate);
  3268. if (dist < max) {
  3269. hit = c;
  3270. max = dist;
  3271. }
  3272. });
  3273. return hit;
  3274. };
  3275. return MultiPoint;
  3276. }(MultiGeometry);
  3277. MultiPoint.registerJSONType('MultiPoint');
  3278. function distanceTo(p0, p1) {
  3279. var x = p1.x - p0.x,
  3280. y = p1.y - p0.y;
  3281. return Math.sqrt(x * x + y * y);
  3282. }
  3283. var MultiPath = function (_MultiGeometry) {
  3284. _inheritsLoose(MultiPath, _MultiGeometry);
  3285. function MultiPath() {
  3286. return _MultiGeometry.apply(this, arguments) || this;
  3287. }
  3288. var _proto = MultiPath.prototype;
  3289. _proto.getCenterInExtent = function getCenterInExtent(extent) {
  3290. var children = this.getGeometries();
  3291. var sumx = 0,
  3292. sumy = 0,
  3293. counter = 0;
  3294. children.forEach(function (l) {
  3295. var c = l.getCenterInExtent(extent);
  3296. if (c) {
  3297. sumx += c.x * c.count;
  3298. sumy += c.y * c.count;
  3299. counter += c.count;
  3300. }
  3301. });
  3302. if (counter === 0) {
  3303. return null;
  3304. }
  3305. return new Coordinate(sumx, sumy)._multi(1 / counter);
  3306. };
  3307. return MultiPath;
  3308. }(MultiGeometry);
  3309. var MultiLineString = function (_MultiPath) {
  3310. _inheritsLoose(MultiLineString, _MultiPath);
  3311. function MultiLineString(data, options) {
  3312. return _MultiPath.call(this, LineString, 'MultiLineString', data, options) || this;
  3313. }
  3314. return MultiLineString;
  3315. }(MultiPath);
  3316. MultiLineString.registerJSONType('MultiLineString');
  3317. var MultiPolygon = function (_MultiPath) {
  3318. _inheritsLoose(MultiPolygon, _MultiPath);
  3319. function MultiPolygon(data, opts) {
  3320. return _MultiPath.call(this, Polygon, 'MultiPolygon', data, opts) || this;
  3321. }
  3322. return MultiPolygon;
  3323. }(MultiPath);
  3324. function CenterMixin(Base) {
  3325. return function (_Base) {
  3326. _inheritsLoose(_class, _Base);
  3327. function _class() {
  3328. return _Base.apply(this, arguments) || this;
  3329. }
  3330. var _proto = _class.prototype;
  3331. _proto.getCoordinates = function getCoordinates() {
  3332. return this._coordinates;
  3333. };
  3334. _proto.setCoordinates = function setCoordinates(coordinates) {
  3335. var center = coordinates instanceof Coordinate ? coordinates : new Coordinate(coordinates);
  3336. if (center.equals(this._coordinates)) {
  3337. return this;
  3338. }
  3339. this._coordinates = center;
  3340. if (!this.getMap()) {
  3341. this.onPositionChanged();
  3342. return this;
  3343. }
  3344. var projection = this._getProjection();
  3345. this._setPrjCoordinates(projection.project(this._coordinates));
  3346. return this;
  3347. };
  3348. _proto._getCenter2DPoint = function _getCenter2DPoint(zoom) {
  3349. var map = this.getMap();
  3350. if (!map) {
  3351. return null;
  3352. }
  3353. var z = isNil(zoom) ? map.getZoom() : map.getGLZoom();
  3354. var pcenter = this._getPrjCoordinates();
  3355. if (!pcenter) {
  3356. return null;
  3357. }
  3358. return map._prjToPoint(pcenter, z);
  3359. };
  3360. _proto._getPrjCoordinates = function _getPrjCoordinates() {
  3361. var projection = this._getProjection();
  3362. if (!projection) {
  3363. return null;
  3364. }
  3365. this._verifyProjection();
  3366. if (!this._pcenter) {
  3367. if (this._coordinates) {
  3368. this._pcenter = projection.project(this._coordinates);
  3369. }
  3370. }
  3371. return this._pcenter;
  3372. };
  3373. _proto._setPrjCoordinates = function _setPrjCoordinates(pcenter) {
  3374. this._pcenter = pcenter;
  3375. this.onPositionChanged();
  3376. };
  3377. _proto._updateCache = function _updateCache() {
  3378. this._clearCache();
  3379. var projection = this._getProjection();
  3380. if (this._pcenter && projection) {
  3381. this._coordinates = projection.unproject(this._pcenter);
  3382. }
  3383. };
  3384. _proto._clearProjection = function _clearProjection() {
  3385. this._pcenter = null;
  3386. _Base.prototype._clearProjection.call(this);
  3387. };
  3388. _proto._computeCenter = function _computeCenter() {
  3389. return this._coordinates ? this._coordinates.copy() : null;
  3390. };
  3391. return _class;
  3392. }(Base);
  3393. }
  3394. MultiPolygon.registerJSONType('MultiPolygon');
  3395. var types$1 = {
  3396. 'Marker': Marker,
  3397. 'LineString': LineString,
  3398. 'Polygon': Polygon,
  3399. 'MultiPoint': MultiPoint,
  3400. 'MultiLineString': MultiLineString,
  3401. 'MultiPolygon': MultiPolygon
  3402. };
  3403. function _convert(json) {
  3404. if (!json || isNil(json['type'])) {
  3405. return null;
  3406. }
  3407. var type = json['type'];
  3408. if (type === 'Feature') {
  3409. var g = json['geometry'];
  3410. var geometry = _convert(g);
  3411. if (!geometry) {
  3412. return null;
  3413. }
  3414. geometry.setId(json['id']);
  3415. geometry.setProperties(json['properties']);
  3416. return geometry;
  3417. } else if (type === 'FeatureCollection') {
  3418. var features = json['features'];
  3419. if (!features) {
  3420. return null;
  3421. }
  3422. var result = toGeometry(features);
  3423. return result;
  3424. } else if (['Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon'].indexOf(type) >= 0) {
  3425. var clazz = type === 'Point' ? 'Marker' : type;
  3426. return new types$1[clazz](json['coordinates']);
  3427. } else if (type === 'GeometryCollection') {
  3428. var geometries = json['geometries'];
  3429. if (!isArrayHasData(geometries)) {
  3430. return new GeometryCollection();
  3431. }
  3432. var mGeos = [];
  3433. var size = geometries.length;
  3434. for (var i = 0; i < size; i++) {
  3435. mGeos.push(_convert(geometries[i]));
  3436. }
  3437. return new GeometryCollection(mGeos);
  3438. }
  3439. return null;
  3440. }
  3441. var Renderable = (function (Base) {
  3442. return function (_Base) {
  3443. _inheritsLoose(_class, _Base);
  3444. function _class() {
  3445. return _Base.apply(this, arguments) || this;
  3446. }
  3447. _class.registerRenderer = function registerRenderer(name, clazz) {
  3448. var proto = this.prototype;
  3449. var parentProto = Object.getPrototypeOf(proto);
  3450. if (!proto._rendererClasses || proto._rendererClasses === parentProto._rendererClasses) {
  3451. proto._rendererClasses = proto._rendererClasses ? Object.create(proto._rendererClasses) : {};
  3452. }
  3453. proto._rendererClasses[name.toLowerCase()] = clazz;
  3454. return this;
  3455. };
  3456. _class.getRendererClass = function getRendererClass(name) {
  3457. var proto = this.prototype;
  3458. if (!proto._rendererClasses) {
  3459. return null;
  3460. }
  3461. return proto._rendererClasses[name.toLowerCase()];
  3462. };
  3463. return _class;
  3464. }(Base);
  3465. });
  3466. var IS_NODE = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]' && !process.versions['electron'] && !process.versions['nw'] && !process.versions['node-webkit'];
  3467. var Browser = {};
  3468. // if (!IS_NODE) {
  3469. // var ua = navigator.userAgent.toLowerCase(),
  3470. // doc = document.documentElement,
  3471. // ie = 'ActiveXObject' in window,
  3472. // webkit = ua.indexOf('webkit') !== -1,
  3473. // phantomjs = ua.indexOf('phantom') !== -1,
  3474. // android23 = ua.search('android [23]') !== -1,
  3475. // chrome = ua.indexOf('chrome') !== -1,
  3476. // gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,
  3477. // mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,
  3478. // msPointer = !window.PointerEvent && window.MSPointerEvent,
  3479. // pointer = window.PointerEvent && navigator.pointerEnabled || msPointer,
  3480. // ie3d = ie && 'transition' in doc.style,
  3481. // webkit3d = 'WebKitCSSMatrix' in window && 'm11' in new window.WebKitCSSMatrix() && !android23,
  3482. // gecko3d = 'MozPerspective' in doc.style,
  3483. // opera12 = 'OTransition' in doc.style,
  3484. // any3d = (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs;
  3485. // var chromeVersion = 0;
  3486. // if (chrome) {
  3487. // chromeVersion = ua.match(/chrome\/([\d.]+)/)[1];
  3488. // }
  3489. // var touch = !phantomjs && (pointer || 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
  3490. // var webgl;
  3491. // try {
  3492. // var canvas = document.createElement('canvas');
  3493. // var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
  3494. // webgl = gl && gl instanceof WebGLRenderingContext;
  3495. // } catch (err) {
  3496. // webgl = false;
  3497. // }
  3498. // Browser = {
  3499. // ie: ie,
  3500. // ielt9: ie && !document.addEventListener,
  3501. // edge: 'msLaunchUri' in navigator && !('documentMode' in document),
  3502. // webkit: webkit,
  3503. // gecko: gecko,
  3504. // android: ua.indexOf('android') !== -1,
  3505. // android23: android23,
  3506. // chrome: chrome,
  3507. // chromeVersion: chromeVersion,
  3508. // safari: !chrome && ua.indexOf('safari') !== -1,
  3509. // phantomjs: phantomjs,
  3510. // ie3d: ie3d,
  3511. // webkit3d: webkit3d,
  3512. // gecko3d: gecko3d,
  3513. // opera12: opera12,
  3514. // any3d: any3d,
  3515. // mobile: mobile,
  3516. // mobileWebkit: mobile && webkit,
  3517. // mobileWebkit3d: mobile && webkit3d,
  3518. // mobileOpera: mobile && window.opera,
  3519. // mobileGecko: mobile && gecko,
  3520. // touch: !!touch,
  3521. // msPointer: !!msPointer,
  3522. // pointer: !!pointer,
  3523. // retina: (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1,
  3524. // language: navigator.browserLanguage ? navigator.browserLanguage : navigator.language,
  3525. // ie9: ie && document.documentMode === 9,
  3526. // ie10: ie && document.documentMode === 10,
  3527. // webgl: webgl
  3528. // };
  3529. // }
  3530. var Extent = function () {
  3531. function Extent(p1, p2, p3, p4) {
  3532. this._clazz = Coordinate;
  3533. var l = arguments.length;
  3534. var proj = l > 0 ? arguments[l - 1] : null;
  3535. if (proj && proj.unproject) {
  3536. this.projection = arguments[l - 1];
  3537. }
  3538. this._dirty = true;
  3539. this._initialize(p1, p2, p3, p4);
  3540. }
  3541. var _proto = Extent.prototype;
  3542. _proto._initialize = function _initialize(p1, p2, p3, p4) {
  3543. this.xmin = null;
  3544. this.xmax = null;
  3545. this.ymin = null;
  3546. this.ymax = null;
  3547. if (isNil(p1)) {
  3548. return;
  3549. }
  3550. var projection = this.projection;
  3551. if (isNumber(p1) && isNumber(p2) && isNumber(p3) && isNumber(p4)) {
  3552. if (projection) {
  3553. this['xmin'] = p1;
  3554. this['ymin'] = p2;
  3555. this['xmax'] = p3;
  3556. this['ymax'] = p4;
  3557. } else {
  3558. this['xmin'] = Math.min(p1, p3);
  3559. this['ymin'] = Math.min(p2, p4);
  3560. this['xmax'] = Math.max(p1, p3);
  3561. this['ymax'] = Math.max(p2, p4);
  3562. }
  3563. return;
  3564. } else if (Array.isArray(p1)) {
  3565. if (projection) {
  3566. this['xmin'] = p1[0];
  3567. this['ymin'] = p1[1];
  3568. this['xmax'] = p1[2];
  3569. this['ymax'] = p1[3];
  3570. } else {
  3571. this['xmin'] = Math.min(p1[0], p1[2]);
  3572. this['ymin'] = Math.min(p1[1], p1[3]);
  3573. this['xmax'] = Math.max(p1[0], p1[2]);
  3574. this['ymax'] = Math.max(p1[1], p1[3]);
  3575. }
  3576. } else if (isNumber(p1.x) && isNumber(p2.x) && isNumber(p1.y) && isNumber(p2.y)) {
  3577. if (projection) {
  3578. this['xmin'] = p1.x;
  3579. this['ymin'] = p1.y;
  3580. this['xmax'] = p2.x;
  3581. this['ymax'] = p2.y;
  3582. } else {
  3583. if (p1.x > p2.x) {
  3584. this['xmin'] = p2.x;
  3585. this['xmax'] = p1.x;
  3586. } else {
  3587. this['xmin'] = p1.x;
  3588. this['xmax'] = p2.x;
  3589. }
  3590. if (p1.y > p2.y) {
  3591. this['ymin'] = p2.y;
  3592. this['ymax'] = p1.y;
  3593. } else {
  3594. this['ymin'] = p1.y;
  3595. this['ymax'] = p2.y;
  3596. }
  3597. }
  3598. } else if (isNumber(p1['xmin']) && isNumber(p1['xmax']) && isNumber(p1['ymin']) && isNumber(p1['ymax'])) {
  3599. this['xmin'] = p1['xmin'];
  3600. this['ymin'] = p1['ymin'];
  3601. this['xmax'] = p1['xmax'];
  3602. this['ymax'] = p1['ymax'];
  3603. }
  3604. };
  3605. _proto._add = function _add(p) {
  3606. this._dirty = true;
  3607. if (!isNil(p.x)) {
  3608. this['xmin'] += p.x;
  3609. this['ymin'] += p.y;
  3610. this['xmax'] += p.x;
  3611. this['ymax'] += p.y;
  3612. } else if (!isNil(p.xmin)) {
  3613. this['xmin'] += p.xmin;
  3614. this['ymin'] += p.ymin;
  3615. this['xmax'] += p.xmax;
  3616. this['ymax'] += p.ymax;
  3617. } else if (!isNil(p[0])) {
  3618. this['xmin'] += p[0];
  3619. this['ymin'] += p[1];
  3620. this['xmax'] += p[0];
  3621. this['ymax'] += p[1];
  3622. }
  3623. return this;
  3624. };
  3625. _proto.add = function add() {
  3626. var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
  3627. return e._add.apply(e, arguments);
  3628. };
  3629. _proto._sub = function _sub(p) {
  3630. this._dirty = true;
  3631. if (!isNil(p.x)) {
  3632. this['xmin'] -= p.x;
  3633. this['ymin'] -= p.y;
  3634. this['xmax'] -= p.x;
  3635. this['ymax'] -= p.y;
  3636. } else if (!isNil(p.xmin)) {
  3637. this['xmin'] -= p.xmin;
  3638. this['ymin'] -= p.ymin;
  3639. this['xmax'] -= p.xmax;
  3640. this['ymax'] -= p.ymax;
  3641. } else if (!isNil(p[0])) {
  3642. this['xmin'] -= p[0];
  3643. this['ymin'] -= p[1];
  3644. this['xmax'] -= p[0];
  3645. this['ymax'] -= p[1];
  3646. }
  3647. return this;
  3648. };
  3649. _proto._substract = function _substract() {
  3650. return this._sub.apply(this, arguments);
  3651. };
  3652. _proto.sub = function sub() {
  3653. var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
  3654. return e._sub.apply(e, arguments);
  3655. };
  3656. _proto.substract = function substract() {
  3657. return this.sub.apply(this, arguments);
  3658. };
  3659. _proto.round = function round() {
  3660. return new this.constructor(Math.round(this['xmin']), Math.round(this['ymin']), Math.round(this['xmax']), Math.round(this['ymax']), this.projection);
  3661. };
  3662. _proto._round = function _round() {
  3663. this._dirty = true;
  3664. this['xmin'] = Math.round(this['xmin']);
  3665. this['ymin'] = Math.round(this['ymin']);
  3666. this['xmax'] = Math.round(this['xmax']);
  3667. this['ymax'] = Math.round(this['ymax']);
  3668. return this;
  3669. };
  3670. _proto.getMin = function getMin() {
  3671. return new this._clazz(this['xmin'], this['ymin']);
  3672. };
  3673. _proto.getMax = function getMax() {
  3674. return new this._clazz(this['xmax'], this['ymax']);
  3675. };
  3676. _proto.getCenter = function getCenter() {
  3677. return new this._clazz((this['xmin'] + this['xmax']) / 2, (this['ymin'] + this['ymax']) / 2);
  3678. };
  3679. _proto.isValid = function isValid() {
  3680. return isNumber(this['xmin']) && isNumber(this['ymin']) && isNumber(this['xmax']) && isNumber(this['ymax']);
  3681. };
  3682. _proto.equals = function equals(ext2) {
  3683. return this['xmin'] === ext2['xmin'] && this['xmax'] === ext2['xmax'] && this['ymin'] === ext2['ymin'] && this['ymax'] === ext2['ymax'];
  3684. };
  3685. _proto.intersects = function intersects(ext2) {
  3686. this._project(this);
  3687. this._project(ext2);
  3688. var rxmin = Math.max(this['pxmin'], ext2['pxmin']);
  3689. var rymin = Math.max(this['pymin'], ext2['pymin']);
  3690. var rxmax = Math.min(this['pxmax'], ext2['pxmax']);
  3691. var rymax = Math.min(this['pymax'], ext2['pymax']);
  3692. var intersects = !(rxmin > rxmax || rymin > rymax);
  3693. return intersects;
  3694. };
  3695. _proto.within = function within(extent) {
  3696. this._project(this);
  3697. this._project(extent);
  3698. return this.pxmin >= extent.pxmin && this.pxmax <= extent.pxmax && this.pymin >= extent.pymin && this.pymax <= extent.pymax;
  3699. };
  3700. _proto.contains = function contains(c) {
  3701. if (!c) {
  3702. return false;
  3703. }
  3704. this._project(this);
  3705. var proj = this.projection;
  3706. if (Array.isArray(c)) {
  3707. c = new this._clazz(c);
  3708. }
  3709. if (proj) {
  3710. c = proj.project(c);
  3711. }
  3712. return c.x >= this.pxmin && c.x <= this.pxmax && c.y >= this.pymin && c.y <= this.pymax;
  3713. };
  3714. _proto.getWidth = function getWidth() {
  3715. return Math.abs(this['xmax'] - this['xmin']);
  3716. };
  3717. _proto.getHeight = function getHeight() {
  3718. return Math.abs(this['ymax'] - this['ymin']);
  3719. };
  3720. _proto.getSize = function getSize() {
  3721. return new Size(this.getWidth(), this.getHeight());
  3722. };
  3723. _proto.__combine = function __combine(extent) {
  3724. if (!(extent instanceof this.constructor)) {
  3725. extent = new this.constructor(extent, extent);
  3726. }
  3727. this._project(extent);
  3728. this._project(this);
  3729. var xmin = this['pxmin'];
  3730. if (!isNumber(xmin)) {
  3731. xmin = extent['pxmin'];
  3732. } else if (isNumber(extent['pxmin'])) {
  3733. if (xmin > extent['pxmin']) {
  3734. xmin = extent['pxmin'];
  3735. }
  3736. }
  3737. var xmax = this['pxmax'];
  3738. if (!isNumber(xmax)) {
  3739. xmax = extent['pxmax'];
  3740. } else if (isNumber(extent['pxmax'])) {
  3741. if (xmax < extent['pxmax']) {
  3742. xmax = extent['pxmax'];
  3743. }
  3744. }
  3745. var ymin = this['pymin'];
  3746. if (!isNumber(ymin)) {
  3747. ymin = extent['pymin'];
  3748. } else if (isNumber(extent['pymin'])) {
  3749. if (ymin > extent['pymin']) {
  3750. ymin = extent['pymin'];
  3751. }
  3752. }
  3753. var ymax = this['pymax'];
  3754. if (!isNumber(ymax)) {
  3755. ymax = extent['pymax'];
  3756. } else if (isNumber(extent['pymax'])) {
  3757. if (ymax < extent['pymax']) {
  3758. ymax = extent['pymax'];
  3759. }
  3760. }
  3761. var proj = this.projection;
  3762. if (proj) {
  3763. var min = proj.unproject(new this._clazz(xmin, ymin)),
  3764. max = proj.unproject(new this._clazz(xmax, ymax));
  3765. xmin = min.x;
  3766. ymin = min.y;
  3767. xmax = max.x;
  3768. ymax = max.y;
  3769. }
  3770. return [xmin, ymin, xmax, ymax];
  3771. };
  3772. _proto._combine = function _combine(extent) {
  3773. if (!extent) {
  3774. return this;
  3775. }
  3776. var ext = this.__combine(extent);
  3777. this['xmin'] = ext[0];
  3778. this['ymin'] = ext[1];
  3779. this['xmax'] = ext[2];
  3780. this['ymax'] = ext[3];
  3781. this._dirty = true;
  3782. return this;
  3783. };
  3784. _proto.combine = function combine(extent) {
  3785. if (!extent) {
  3786. return this;
  3787. }
  3788. var ext = this.__combine(extent);
  3789. return new this.constructor(ext[0], ext[1], ext[2], ext[3], this.projection);
  3790. };
  3791. _proto.intersection = function intersection(extent) {
  3792. if (!this.intersects(extent)) {
  3793. return null;
  3794. }
  3795. var min = new this._clazz(Math.max(this['pxmin'], extent['pxmin']), Math.max(this['pymin'], extent['pymin'])),
  3796. max = new this._clazz(Math.min(this['pxmax'], extent['pxmax']), Math.min(this['pymax'], extent['pymax']));
  3797. var proj = this.projection;
  3798. if (proj) {
  3799. min = proj.unproject(min);
  3800. max = proj.unproject(max);
  3801. }
  3802. return new this.constructor(min, max, proj);
  3803. };
  3804. _proto.expand = function expand(distance) {
  3805. var w, h;
  3806. if (!isNumber(distance)) {
  3807. w = distance['width'] || distance['x'] || distance[0] || 0;
  3808. h = distance['height'] || distance['y'] || distance[1] || 0;
  3809. } else {
  3810. w = h = distance;
  3811. }
  3812. return new this.constructor(this['xmin'] - w, this['ymin'] - h, this['xmax'] + w, this['ymax'] + h, this.projection);
  3813. };
  3814. _proto._expand = function _expand(distance) {
  3815. var w, h;
  3816. if (!isNumber(distance)) {
  3817. w = distance['width'] || distance['x'] || distance[0] || 0;
  3818. h = distance['height'] || distance['y'] || distance[1] || 0;
  3819. } else {
  3820. w = h = distance;
  3821. }
  3822. this['xmin'] -= w;
  3823. this['ymin'] -= h;
  3824. this['xmax'] += w;
  3825. this['ymax'] += h;
  3826. this._dirty = true;
  3827. return this;
  3828. };
  3829. _proto.toJSON = function toJSON() {
  3830. return {
  3831. 'xmin': this['xmin'],
  3832. 'ymin': this['ymin'],
  3833. 'xmax': this['xmax'],
  3834. 'ymax': this['ymax']
  3835. };
  3836. };
  3837. _proto.toArray = function toArray() {
  3838. var xmin = this['xmin'],
  3839. ymin = this['ymin'],
  3840. xmax = this['xmax'],
  3841. ymax = this['ymax'];
  3842. return [new this._clazz([xmin, ymax]), new this._clazz([xmax, ymax]), new this._clazz([xmax, ymin]), new this._clazz([xmin, ymin]), new this._clazz([xmin, ymax])];
  3843. };
  3844. _proto.toString = function toString() {
  3845. return this.xmin + "," + this.ymin + "," + this.xmax + "," + this.ymax;
  3846. };
  3847. _proto.copy = function copy() {
  3848. return new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
  3849. };
  3850. _proto.convertTo = function convertTo(fn) {
  3851. if (!this.isValid()) {
  3852. return null;
  3853. }
  3854. var e = new this.constructor();
  3855. var coord = new this._clazz(this.xmin, this.ymax);
  3856. e._combine(fn(coord));
  3857. coord.x = this.xmax;
  3858. e._combine(fn(coord));
  3859. coord.y = this.ymin;
  3860. e._combine(fn(coord));
  3861. coord.x = this.xmin;
  3862. e._combine(fn(coord));
  3863. return e;
  3864. };
  3865. _proto._project = function _project(ext) {
  3866. if (!ext || !ext.isValid()) {
  3867. return;
  3868. }
  3869. var proj = this.projection;
  3870. if (proj) {
  3871. if (ext._dirty) {
  3872. var minmax = [ext.getMin(), ext.getMax()];
  3873. minmax = proj.projectCoords(minmax);
  3874. var min = minmax[0],
  3875. max = minmax[1];
  3876. ext.pxmin = Math.min(min.x, max.x);
  3877. ext.pymin = Math.min(min.y, max.y);
  3878. ext.pxmax = Math.max(min.x, max.x);
  3879. ext.pymax = Math.max(min.y, max.y);
  3880. }
  3881. delete ext._dirty;
  3882. } else {
  3883. ext.pxmin = ext.xmin;
  3884. ext.pxmax = ext.xmax;
  3885. ext.pymin = ext.ymin;
  3886. ext.pymax = ext.ymax;
  3887. }
  3888. };
  3889. return Extent;
  3890. }();
  3891. var Transformation = function () {
  3892. function Transformation(matrix) {
  3893. this.matrix = matrix;
  3894. }
  3895. var _proto = Transformation.prototype;
  3896. _proto.transform = function transform(coordinates, scale) {
  3897. return new Point(this.matrix[0] * (coordinates.x - this.matrix[2]) / scale, this.matrix[1] * (coordinates.y - this.matrix[3]) / scale);
  3898. };
  3899. _proto.untransform = function untransform(point, scale) {
  3900. return new Coordinate(point.x * scale / this.matrix[0] + this.matrix[2], point.y * scale / this.matrix[1] + this.matrix[3]);
  3901. };
  3902. return Transformation;
  3903. }();
  3904. var Browser$1 = Browser;
  3905. var options$1 = {
  3906. 'maxVisualPitch': 60,
  3907. 'maxPitch': 80,
  3908. 'centerCross': false,
  3909. 'zoomInCenter': false,
  3910. 'zoomAnimation': function () {
  3911. return !IS_NODE;
  3912. }(),
  3913. 'zoomAnimationDuration': 330,
  3914. 'panAnimation': function () {
  3915. return !IS_NODE;
  3916. }(),
  3917. 'panAnimationDuration': 600,
  3918. 'zoomable': true,
  3919. 'enableInfoWindow': true,
  3920. 'hitDetect': function () {
  3921. return false;
  3922. }(),
  3923. 'hitDetectLimit': 5,
  3924. 'fpsOnInteracting': 25,
  3925. 'layerCanvasLimitOnInteracting': -1,
  3926. 'maxZoom': null,
  3927. 'minZoom': null,
  3928. 'maxExtent': null,
  3929. 'checkSize': true,
  3930. 'renderer': 'canvas'
  3931. };
  3932. var Map$1 = function (_Handlerable) {
  3933. _inheritsLoose(Map, _Handlerable);
  3934. function Map(container, options) {
  3935. var _this;
  3936. if (!options) {
  3937. throw new Error('Invalid options when creating map.');
  3938. }
  3939. if (!options['center']) {
  3940. throw new Error('Invalid center when creating map.');
  3941. }
  3942. var opts = extend({}, options);
  3943. var zoom = opts['zoom'];
  3944. delete opts['zoom'];
  3945. var center = new Coordinate(opts['center']);
  3946. delete opts['center'];
  3947. var baseLayer = opts['baseLayer'];
  3948. delete opts['baseLayer'];
  3949. var layers = opts['layers'];
  3950. delete opts['layers'];
  3951. _this = _Handlerable.call(this, opts) || this;
  3952. Object.defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), 'id', {
  3953. value: UID(),
  3954. writable: false
  3955. });
  3956. _this._loaded = false;
  3957. // _this._initContainer(container);
  3958. _this._panels = {};
  3959. _this._baseLayer = null;
  3960. _this._layers = [];
  3961. _this._zoomLevel = zoom;
  3962. _this._center = center;
  3963. _this.setSpatialReference(opts['spatialReference'] || opts['view']);
  3964. _this._mapViewPoint = new Point(0, 0);
  3965. // _this._initRenderer();
  3966. // _this._updateMapSize(_this._getContainerDomSize());
  3967. // if (baseLayer) {
  3968. // _this.setBaseLayer(baseLayer);
  3969. // }
  3970. // if (layers) {
  3971. // _this.addLayer(layers);
  3972. // }
  3973. // _this._Load();
  3974. return _this;
  3975. }
  3976. Map.addOnLoadHook = function addOnLoadHook(fn) {
  3977. var args = Array.prototype.slice.call(arguments, 1);
  3978. var onload = typeof fn === 'function' ? fn : function () {
  3979. this[fn].apply(this, args);
  3980. };
  3981. this.prototype._onLoadHooks = this.prototype._onLoadHooks || [];
  3982. this.prototype._onLoadHooks.push(onload);
  3983. return this;
  3984. };
  3985. var _proto = Map.prototype;
  3986. _proto.isLoaded = function isLoaded() {
  3987. return !!this._loaded;
  3988. };
  3989. _proto.getContainer = function getContainer() {
  3990. return this._containerDOM;
  3991. };
  3992. _proto.getSpatialReference = function getSpatialReference() {
  3993. return this._spatialReference;
  3994. };
  3995. _proto.setSpatialReference = function setSpatialReference(ref) {
  3996. var oldRef = this.options['spatialReference'];
  3997. if (this._loaded && SpatialReference.equals(oldRef, ref)) {
  3998. return this;
  3999. }
  4000. ref = extend({}, ref);
  4001. this._center = this.getCenter();
  4002. this.options['spatialReference'] = ref;
  4003. this._spatialReference = new SpatialReference(ref);
  4004. if (this.options['spatialReference'] && isFunction(this.options['spatialReference']['projection'])) {
  4005. var projection = this._spatialReference.getProjection();
  4006. this.options['spatialReference']['projection'] = projection['code'];
  4007. }
  4008. this._resetMapStatus();
  4009. this._fireEvent('spatialreferencechange', {
  4010. 'old': oldRef,
  4011. 'new': extend({}, this.options['spatialReference'])
  4012. });
  4013. return this;
  4014. };
  4015. _proto.onConfig = function onConfig(conf) {
  4016. var ref = conf['spatialReference'] || conf['view'];
  4017. if (!isNil(ref)) {
  4018. this.setSpatialReference(ref);
  4019. }
  4020. return this;
  4021. };
  4022. _proto.getProjection = function getProjection() {
  4023. if (!this._spatialReference) {
  4024. return null;
  4025. }
  4026. return this._spatialReference.getProjection();
  4027. };
  4028. _proto.getFullExtent = function getFullExtent() {
  4029. if (!this._spatialReference) {
  4030. return null;
  4031. }
  4032. return this._spatialReference.getFullExtent();
  4033. };
  4034. _proto.setCursor = function setCursor(cursor) {
  4035. delete this._cursor;
  4036. this._trySetCursor(cursor);
  4037. this._cursor = cursor;
  4038. return this;
  4039. };
  4040. _proto.resetCursor = function resetCursor() {
  4041. return this.setCursor(null);
  4042. };
  4043. _proto.getCenter = function getCenter() {
  4044. if (!this._loaded || !this._prjCenter) {
  4045. return this._center;
  4046. }
  4047. var projection = this.getProjection();
  4048. return projection.unproject(this._prjCenter);
  4049. };
  4050. _proto.setCenter = function setCenter(center) {
  4051. if (!center) {
  4052. return this;
  4053. }
  4054. center = new Coordinate(center);
  4055. if (!this._verifyExtent(center)) {
  4056. return this;
  4057. }
  4058. if (!this._loaded) {
  4059. this._center = center;
  4060. return this;
  4061. }
  4062. this.onMoveStart();
  4063. var projection = this.getProjection();
  4064. var _pcenter = projection.project(center);
  4065. this._setPrjCenter(_pcenter);
  4066. this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
  4067. return this;
  4068. };
  4069. _proto.getSize = function getSize() {
  4070. if (isNil(this.width) || isNil(this.height)) {
  4071. return this._getContainerDomSize();
  4072. }
  4073. return new Size(this.width, this.height);
  4074. };
  4075. _proto.getContainerExtent = function getContainerExtent() {
  4076. var visualHeight = this.height;
  4077. var pitch = this.getPitch(),
  4078. maxVisualPitch = this.options['maxVisualPitch'];
  4079. if (maxVisualPitch && pitch > maxVisualPitch) {
  4080. visualHeight = this._getVisualHeight(maxVisualPitch);
  4081. }
  4082. return new PointExtent(0, this.height - visualHeight, this.width, this.height);
  4083. };
  4084. _proto._getVisualHeight = function _getVisualHeight(maxVisualPitch) {
  4085. var pitch = this.getPitch();
  4086. var visualDistance = this.height / 2 * Math.tan(maxVisualPitch * Math.PI / 180);
  4087. return this.height / 2 + visualDistance * Math.tan((90 - pitch) * Math.PI / 180);
  4088. };
  4089. _proto.getExtent = function getExtent() {
  4090. return this._pointToExtent(this._get2DExtent());
  4091. };
  4092. _proto.getProjExtent = function getProjExtent() {
  4093. var extent2D = this._get2DExtent();
  4094. return new Extent(this._pointToPrj(extent2D.getMin()), this._pointToPrj(extent2D.getMax()));
  4095. };
  4096. _proto.getPrjExtent = function getPrjExtent() {
  4097. return this.getProjExtent();
  4098. };
  4099. _proto.getMaxExtent = function getMaxExtent() {
  4100. if (!this.options['maxExtent']) {
  4101. return null;
  4102. }
  4103. return new Extent(this.options['maxExtent'], this.getProjection());
  4104. };
  4105. _proto.setMaxExtent = function setMaxExtent(extent) {
  4106. if (extent) {
  4107. var maxExt = new Extent(extent, this.getProjection());
  4108. this.options['maxExtent'] = maxExt;
  4109. var center = this.getCenter();
  4110. if (!this._verifyExtent(center)) {
  4111. this.panTo(maxExt.getCenter());
  4112. }
  4113. } else {
  4114. delete this.options['maxExtent'];
  4115. }
  4116. return this;
  4117. };
  4118. _proto.getZoom = function getZoom() {
  4119. return this._zoomLevel;
  4120. };
  4121. _proto.getZoomForScale = function getZoomForScale(scale, fromZoom, isFraction) {
  4122. var zoom = this.getZoom();
  4123. if (isNil(fromZoom)) {
  4124. fromZoom = zoom;
  4125. }
  4126. if (scale === 1 && fromZoom === zoom) {
  4127. return zoom;
  4128. }
  4129. var res = this._getResolution(fromZoom),
  4130. targetRes = res / scale;
  4131. var scaleZoom = this.getZoomFromRes(targetRes);
  4132. if (isFraction) {
  4133. return scaleZoom;
  4134. } else {
  4135. var delta = 1E-6;
  4136. return this.getSpatialReference().getZoomDirection() < 0 ? Math.ceil(scaleZoom - delta) : Math.floor(scaleZoom + delta);
  4137. }
  4138. };
  4139. _proto.getZoomFromRes = function getZoomFromRes(res) {
  4140. var resolutions = this._getResolutions(),
  4141. minRes = this._getResolution(this.getMinZoom()),
  4142. maxRes = this._getResolution(this.getMaxZoom());
  4143. if (minRes <= maxRes) {
  4144. if (res <= minRes) {
  4145. return this.getMinZoom();
  4146. } else if (res >= maxRes) {
  4147. return this.getMaxZoom();
  4148. }
  4149. } else if (res >= minRes) {
  4150. return this.getMinZoom();
  4151. } else if (res <= maxRes) {
  4152. return this.getMaxZoom();
  4153. }
  4154. var l = resolutions.length;
  4155. for (var i = 0; i < l - 1; i++) {
  4156. if (!resolutions[i]) {
  4157. continue;
  4158. }
  4159. var gap = resolutions[i + 1] - resolutions[i];
  4160. var test = res - resolutions[i];
  4161. if (sign(gap) === sign(test) && Math.abs(gap) >= Math.abs(test)) {
  4162. return i + test / gap;
  4163. }
  4164. }
  4165. return l - 1;
  4166. };
  4167. _proto.setZoom = function setZoom(zoom, options) {
  4168. if (options === void 0) {
  4169. options = {
  4170. 'animation': true
  4171. };
  4172. }
  4173. if (isNaN(zoom) || isNil(zoom)) {
  4174. return this;
  4175. }
  4176. if (this._loaded && this.options['zoomAnimation'] && options['animation']) {
  4177. this._zoomAnimation(zoom);
  4178. } else {
  4179. this._zoom(zoom);
  4180. }
  4181. return this;
  4182. };
  4183. _proto.getMaxZoom = function getMaxZoom() {
  4184. if (!isNil(this.options['maxZoom'])) {
  4185. return this.options['maxZoom'];
  4186. }
  4187. return this.getMaxNativeZoom();
  4188. };
  4189. _proto.setMaxZoom = function setMaxZoom(maxZoom) {
  4190. var viewMaxZoom = this.getMaxNativeZoom();
  4191. if (maxZoom > viewMaxZoom) {
  4192. maxZoom = viewMaxZoom;
  4193. }
  4194. if (maxZoom !== null && maxZoom < this._zoomLevel) {
  4195. this.setZoom(maxZoom);
  4196. }
  4197. this.options['maxZoom'] = maxZoom;
  4198. return this;
  4199. };
  4200. _proto.getMinZoom = function getMinZoom() {
  4201. if (!isNil(this.options['minZoom'])) {
  4202. return this.options['minZoom'];
  4203. }
  4204. return this._spatialReference.getMinZoom();
  4205. };
  4206. _proto.setMinZoom = function setMinZoom(minZoom) {
  4207. if (minZoom !== null) {
  4208. var viewMinZoom = this._spatialReference.getMinZoom();
  4209. if (minZoom < viewMinZoom) {
  4210. minZoom = viewMinZoom;
  4211. }
  4212. if (minZoom > this._zoomLevel) {
  4213. this.setZoom(minZoom);
  4214. }
  4215. }
  4216. this.options['minZoom'] = minZoom;
  4217. return this;
  4218. };
  4219. _proto.getMaxNativeZoom = function getMaxNativeZoom() {
  4220. var ref = this.getSpatialReference();
  4221. if (!ref) {
  4222. return null;
  4223. }
  4224. return ref.getMaxZoom();
  4225. };
  4226. _proto.getGLZoom = function getGLZoom() {
  4227. return this.getMaxNativeZoom() / 2;
  4228. };
  4229. _proto.getGLScale = function getGLScale(zoom) {
  4230. if (isNil(zoom)) {
  4231. zoom = this.getZoom();
  4232. }
  4233. return this.getScale(zoom) / this.getScale(this.getGLZoom());
  4234. };
  4235. _proto.zoomIn = function zoomIn() {
  4236. return this.setZoom(this.getZoom() + 1);
  4237. };
  4238. _proto.zoomOut = function zoomOut() {
  4239. return this.setZoom(this.getZoom() - 1);
  4240. };
  4241. _proto.isZooming = function isZooming() {
  4242. return !!this._zooming;
  4243. };
  4244. _proto.isInteracting = function isInteracting() {
  4245. return this.isZooming() || this.isMoving() || this.isRotating();
  4246. };
  4247. _proto.setCenterAndZoom = function setCenterAndZoom(center, zoom) {
  4248. if (!isNil(zoom) && this._zoomLevel !== zoom) {
  4249. this.setCenter(center);
  4250. this.setZoom(zoom, {
  4251. animation: false
  4252. });
  4253. } else {
  4254. this.setCenter(center);
  4255. }
  4256. return this;
  4257. };
  4258. _proto.getFitZoom = function getFitZoom(extent) {
  4259. var _this2 = this;
  4260. if (!extent || !(extent instanceof Extent)) {
  4261. return this._zoomLevel;
  4262. }
  4263. if (extent['xmin'] === extent['xmax'] && extent['ymin'] === extent['ymax']) {
  4264. return this.getMaxZoom();
  4265. }
  4266. var size = this.getSize();
  4267. var containerExtent = extent.convertTo(function (p) {
  4268. return _this2.coordToContainerPoint(p);
  4269. });
  4270. var w = containerExtent.getWidth(),
  4271. h = containerExtent.getHeight();
  4272. var scaleX = size['width'] / w,
  4273. scaleY = size['height'] / h;
  4274. var scale = this.getSpatialReference().getZoomDirection() < 0 ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);
  4275. var zoom = this.getZoomForScale(scale);
  4276. return zoom;
  4277. };
  4278. _proto.getView = function getView() {
  4279. return {
  4280. 'center': this.getCenter().toArray(),
  4281. 'zoom': this.getZoom(),
  4282. 'pitch': this.getPitch(),
  4283. 'bearing': this.getBearing()
  4284. };
  4285. };
  4286. _proto.setView = function setView(view) {
  4287. if (!view) {
  4288. return this;
  4289. }
  4290. if (view['center']) {
  4291. this.setCenter(view['center']);
  4292. }
  4293. if (view['zoom']) {
  4294. this.setZoom(view['zoom'], {
  4295. 'animation': false
  4296. });
  4297. }
  4298. if (view['pitch']) {
  4299. this.setPitch(view['pitch']);
  4300. }
  4301. if (view['bearing']) {
  4302. this.setBearing(view['bearing']);
  4303. }
  4304. return this;
  4305. };
  4306. _proto.getResolution = function getResolution(zoom) {
  4307. return this._getResolution(zoom);
  4308. };
  4309. _proto.getScale = function getScale(zoom) {
  4310. var z = isNil(zoom) ? this.getZoom() : zoom;
  4311. var max = this._getResolution(this.getMaxNativeZoom()),
  4312. res = this._getResolution(z);
  4313. return res / max;
  4314. };
  4315. _proto.fitExtent = function fitExtent(extent, zoomOffset, options, step) {
  4316. if (options === void 0) {
  4317. options = {};
  4318. }
  4319. if (!extent) {
  4320. return this;
  4321. }
  4322. extent = new Extent(extent, this.getProjection());
  4323. var zoom = this.getFitZoom(extent) + (zoomOffset || 0);
  4324. var center = extent.getCenter();
  4325. if (typeof options['animation'] === 'undefined' || options['animation']) return this.animateTo({
  4326. center: center,
  4327. zoom: zoom
  4328. }, {
  4329. 'duration': options['duration'] || this.options['zoomAnimationDuration'],
  4330. 'easing': options['easing'] || 'out'
  4331. }, step); else return this.setCenterAndZoom(center, zoom);
  4332. };
  4333. _proto.getBaseLayer = function getBaseLayer() {
  4334. return this._baseLayer;
  4335. };
  4336. _proto.setBaseLayer = function setBaseLayer(baseLayer) {
  4337. var isChange = false;
  4338. if (this._baseLayer) {
  4339. isChange = true;
  4340. this._fireEvent('baselayerchangestart');
  4341. this._baseLayer.remove();
  4342. }
  4343. if (!baseLayer) {
  4344. delete this._baseLayer;
  4345. this._fireEvent('baselayerchangeend');
  4346. this._fireEvent('setbaselayer');
  4347. return this;
  4348. }
  4349. this._baseLayer = baseLayer;
  4350. baseLayer._bindMap(this, -1);
  4351. function onbaseLayerload() {
  4352. this._fireEvent('baselayerload');
  4353. if (isChange) {
  4354. isChange = false;
  4355. this._fireEvent('baselayerchangeend');
  4356. }
  4357. }
  4358. this._baseLayer.on('layerload', onbaseLayerload, this);
  4359. if (this._loaded) {
  4360. this._baseLayer.load();
  4361. }
  4362. this._fireEvent('setbaselayer');
  4363. return this;
  4364. };
  4365. _proto.removeBaseLayer = function removeBaseLayer() {
  4366. if (this._baseLayer) {
  4367. this._baseLayer.remove();
  4368. delete this._baseLayer;
  4369. this._fireEvent('baselayerremove');
  4370. }
  4371. return this;
  4372. };
  4373. _proto.getLayers = function getLayers(filter) {
  4374. return this._getLayers(function (layer) {
  4375. if (layer === this._baseLayer || layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
  4376. return false;
  4377. }
  4378. if (filter) {
  4379. return filter(layer);
  4380. }
  4381. return true;
  4382. });
  4383. };
  4384. _proto.getLayer = function getLayer(id) {
  4385. if (!id) {
  4386. return null;
  4387. }
  4388. var layer = this._layerCache ? this._layerCache[id] : null;
  4389. if (layer) {
  4390. return layer;
  4391. }
  4392. var baseLayer = this.getBaseLayer();
  4393. if (baseLayer && baseLayer.getId() === id) {
  4394. return baseLayer;
  4395. }
  4396. return null;
  4397. };
  4398. _proto.addLayer = function addLayer(layers) {
  4399. if (!layers) {
  4400. return this;
  4401. }
  4402. if (!Array.isArray(layers)) {
  4403. layers = Array.prototype.slice.call(arguments, 0);
  4404. return this.addLayer(layers);
  4405. }
  4406. if (!this._layerCache) {
  4407. this._layerCache = {};
  4408. }
  4409. var mapLayers = this._layers;
  4410. for (var i = 0, len = layers.length; i < len; i++) {
  4411. var layer = layers[i];
  4412. var id = layer.getId();
  4413. if (isNil(id)) {
  4414. throw new Error('Invalid id for the layer: ' + id);
  4415. }
  4416. if (layer.getMap() === this) {
  4417. continue;
  4418. }
  4419. if (this._layerCache[id]) {
  4420. throw new Error('Duplicate layer id in the map: ' + id);
  4421. }
  4422. this._layerCache[id] = layer;
  4423. layer._bindMap(this);
  4424. mapLayers.push(layer);
  4425. if (this._loaded) {
  4426. layer.load();
  4427. }
  4428. }
  4429. this._sortLayersByZIndex();
  4430. this._fireEvent('addlayer', {
  4431. 'layers': layers
  4432. });
  4433. return this;
  4434. };
  4435. _proto.removeLayer = function removeLayer(layers) {
  4436. if (!layers) {
  4437. return this;
  4438. }
  4439. if (!Array.isArray(layers)) {
  4440. return this.removeLayer([layers]);
  4441. }
  4442. var removed = [];
  4443. for (var i = 0, len = layers.length; i < len; i++) {
  4444. var layer = layers[i];
  4445. if (!(layer instanceof Layer)) {
  4446. layer = this.getLayer(layer);
  4447. }
  4448. if (!layer) {
  4449. continue;
  4450. }
  4451. var map = layer.getMap();
  4452. if (!map || map !== this) {
  4453. continue;
  4454. }
  4455. removed.push(layer);
  4456. this._removeLayer(layer, this._layers);
  4457. if (this._loaded) {
  4458. layer._doRemove();
  4459. }
  4460. var id = layer.getId();
  4461. if (this._layerCache) {
  4462. delete this._layerCache[id];
  4463. }
  4464. }
  4465. if (removed.length > 0) {
  4466. this.once('frameend', function () {
  4467. removed.forEach(function (layer) {
  4468. layer.fire('remove');
  4469. });
  4470. });
  4471. }
  4472. this._fireEvent('removelayer', {
  4473. 'layers': layers
  4474. });
  4475. return this;
  4476. };
  4477. _proto.sortLayers = function sortLayers(layers) {
  4478. if (!layers || !Array.isArray(layers)) {
  4479. return this;
  4480. }
  4481. var layersToOrder = [];
  4482. var minZ = Number.MAX_VALUE;
  4483. for (var i = 0, l = layers.length; i < l; i++) {
  4484. var layer = layers[i];
  4485. if (isString(layers[i])) {
  4486. layer = this.getLayer(layer);
  4487. }
  4488. if (!(layer instanceof Layer) || !layer.getMap() || layer.getMap() !== this) {
  4489. throw new Error('It must be a layer added to this map to order.');
  4490. }
  4491. if (layer.getZIndex() < minZ) {
  4492. minZ = layer.getZIndex();
  4493. }
  4494. layersToOrder.push(layer);
  4495. }
  4496. for (var _i = 0, _l = layersToOrder.length; _i < _l; _i++) {
  4497. layersToOrder[_i].setZIndex(minZ + _i);
  4498. }
  4499. return this;
  4500. };
  4501. _proto.toDataURL = function toDataURL(options) {
  4502. if (!options) {
  4503. options = {};
  4504. }
  4505. var mimeType = options['mimeType'];
  4506. if (!mimeType) {
  4507. mimeType = 'image/png';
  4508. }
  4509. var save = options['save'];
  4510. var renderer = this._getRenderer();
  4511. if (renderer && renderer.toDataURL) {
  4512. var file = options['fileName'];
  4513. if (!file) {
  4514. file = 'export';
  4515. }
  4516. var dataURL = renderer.toDataURL(mimeType);
  4517. if (save && dataURL) {
  4518. var imgURL;
  4519. if (typeof Blob !== 'undefined' && typeof atob !== 'undefined') {
  4520. var blob = b64toBlob(dataURL.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''), mimeType);
  4521. imgURL = URL.createObjectURL(blob);
  4522. } else {
  4523. imgURL = dataURL;
  4524. }
  4525. var dlLink = document.createElement('a');
  4526. dlLink.download = file;
  4527. dlLink.href = imgURL;
  4528. document.body.appendChild(dlLink);
  4529. dlLink.click();
  4530. document.body.removeChild(dlLink);
  4531. }
  4532. return dataURL;
  4533. }
  4534. return null;
  4535. };
  4536. _proto.coordinateToPoint = function coordinateToPoint(coordinate, zoom) {
  4537. var prjCoord = this.getProjection().project(coordinate);
  4538. return this._prjToPoint(prjCoord, zoom);
  4539. };
  4540. _proto.coordToPoint = function coordToPoint(coordinate, zoom) {
  4541. return this.coordinateToPoint(coordinate, zoom);
  4542. };
  4543. _proto.pointToCoordinate = function pointToCoordinate(point, zoom) {
  4544. var prjCoord = this._pointToPrj(point, zoom);
  4545. return this.getProjection().unproject(prjCoord);
  4546. };
  4547. _proto.pointToCoord = function pointToCoord(point, zoom) {
  4548. return this.pointToCoordinate(point, zoom);
  4549. };
  4550. _proto.coordinateToViewPoint = function coordinateToViewPoint(coordinate) {
  4551. return this._prjToViewPoint(this.getProjection().project(coordinate));
  4552. };
  4553. _proto.coordToViewPoint = function coordToViewPoint(coordinate) {
  4554. return this.coordinateToViewPoint(coordinate);
  4555. };
  4556. _proto.viewPointToCoordinate = function viewPointToCoordinate(viewPoint) {
  4557. return this.getProjection().unproject(this._viewPointToPrj(viewPoint));
  4558. };
  4559. _proto.viewPointToCoord = function viewPointToCoord(viewPoint) {
  4560. return this.viewPointToCoordinate(viewPoint);
  4561. };
  4562. _proto.coordinateToContainerPoint = function coordinateToContainerPoint(coordinate, zoom) {
  4563. var pCoordinate = this.getProjection().project(coordinate);
  4564. return this._prjToContainerPoint(pCoordinate, zoom);
  4565. };
  4566. _proto.coordToContainerPoint = function coordToContainerPoint(coordinate, zoom) {
  4567. return this.coordinateToContainerPoint(coordinate, zoom);
  4568. };
  4569. _proto.containerPointToCoordinate = function containerPointToCoordinate(containerPoint) {
  4570. var pCoordinate = this._containerPointToPrj(containerPoint);
  4571. return this.getProjection().unproject(pCoordinate);
  4572. };
  4573. _proto.containerPointToCoord = function containerPointToCoord(containerPoint) {
  4574. return this.containerPointToCoordinate(containerPoint);
  4575. };
  4576. _proto.containerPointToViewPoint = function containerPointToViewPoint(containerPoint) {
  4577. return containerPoint.sub(this.getViewPoint());
  4578. };
  4579. _proto.viewPointToContainerPoint = function viewPointToContainerPoint(viewPoint) {
  4580. return viewPoint.add(this.getViewPoint());
  4581. };
  4582. _proto.containerToExtent = function containerToExtent(containerExtent) {
  4583. var extent2D = new PointExtent(this._containerPointToPoint(containerExtent.getMin()), this._containerPointToPoint(containerExtent.getMax()));
  4584. return this._pointToExtent(extent2D);
  4585. };
  4586. _proto.checkSize = function checkSize() {
  4587. var justStart = now() - this._initTime < 1500 && this.width === 0 || this.height === 0;
  4588. var watched = this._getContainerDomSize(),
  4589. oldHeight = this.height,
  4590. oldWidth = this.width;
  4591. if (watched['width'] === oldWidth && watched['height'] === oldHeight) {
  4592. return this;
  4593. }
  4594. var center = this.getCenter();
  4595. this._updateMapSize(watched);
  4596. var resizeOffset = new Point((oldWidth - watched.width) / 2, (oldHeight - watched.height) / 2);
  4597. this._offsetCenterByPixel(resizeOffset);
  4598. this._mapViewCoord = this._getPrjCenter();
  4599. var hided = watched['width'] === 0 || watched['height'] === 0 || oldWidth === 0 || oldHeight === 0;
  4600. if (justStart || hided) {
  4601. this._noEvent = true;
  4602. this.setCenter(center);
  4603. delete this._noEvent;
  4604. }
  4605. this._fireEvent('resize');
  4606. return this;
  4607. };
  4608. _proto.distanceToPixel = function distanceToPixel(xDist, yDist, zoom) {
  4609. var projection = this.getProjection();
  4610. if (!projection) {
  4611. return null;
  4612. }
  4613. var scale = this.getScale() / this.getScale(zoom);
  4614. var center = this.getCenter(),
  4615. target = projection.locate(center, xDist, yDist);
  4616. var p0 = this.coordToContainerPoint(center),
  4617. p1 = this.coordToContainerPoint(target);
  4618. p1._sub(p0)._multi(scale)._abs();
  4619. return new Size(p1.x, p1.y);
  4620. };
  4621. _proto.distanceToPoint = function distanceToPoint(xDist, yDist, zoom) {
  4622. var projection = this.getProjection();
  4623. if (!projection) {
  4624. return null;
  4625. }
  4626. var center = this.getCenter(),
  4627. target = projection.locate(center, xDist, yDist);
  4628. var p0 = this.coordToPoint(center, zoom),
  4629. p1 = this.coordToPoint(target, zoom);
  4630. p1._sub(p0)._abs();
  4631. return p1;
  4632. };
  4633. _proto.pixelToDistance = function pixelToDistance(width, height) {
  4634. var projection = this.getProjection();
  4635. if (!projection) {
  4636. return null;
  4637. }
  4638. var fullExt = this.getFullExtent();
  4639. var d = fullExt['top'] > fullExt['bottom'] ? -1 : 1;
  4640. var target = new Point(this.width / 2 + width, this.height / 2 + d * height);
  4641. var coord = this.containerPointToCoord(target);
  4642. return projection.measureLength(this.getCenter(), coord);
  4643. };
  4644. _proto.pointToDistance = function pointToDistance(dx, dy, zoom) {
  4645. var projection = this.getProjection();
  4646. if (!projection) {
  4647. return null;
  4648. }
  4649. var c = this._prjToPoint(this._getPrjCenter(), zoom);
  4650. c._add(dx, dy);
  4651. var target = this.pointToCoord(c, zoom);
  4652. return projection.measureLength(this.getCenter(), target);
  4653. };
  4654. _proto.locate = function locate(coordinate, dx, dy) {
  4655. return this.getProjection()._locate(new Coordinate(coordinate), dx, dy);
  4656. };
  4657. _proto.locateByPoint = function locateByPoint(coordinate, px, py) {
  4658. var point = this.coordToContainerPoint(coordinate);
  4659. return this.containerPointToCoord(point._add(px, py));
  4660. };
  4661. _proto.getMainPanel = function getMainPanel() {
  4662. return this._getRenderer().getMainPanel();
  4663. };
  4664. _proto.getPanels = function getPanels() {
  4665. return this._panels;
  4666. };
  4667. _proto.remove = function remove() {
  4668. if (this.isRemoved()) {
  4669. return this;
  4670. }
  4671. this._fireEvent('removestart');
  4672. this._removeDomEvents();
  4673. this._clearHandlers();
  4674. this.removeBaseLayer();
  4675. var layers = this.getLayers();
  4676. for (var i = 0; i < layers.length; i++) {
  4677. layers[i].remove();
  4678. }
  4679. if (this._getRenderer()) {
  4680. this._getRenderer().remove();
  4681. }
  4682. if (this._containerDOM.innerHTML) {
  4683. this._containerDOM.innerHTML = '';
  4684. }
  4685. delete this._panels;
  4686. delete this._containerDOM;
  4687. delete this.renderer;
  4688. this._fireEvent('removeend');
  4689. this._clearAllListeners();
  4690. return this;
  4691. };
  4692. _proto.isRemoved = function isRemoved() {
  4693. return !this._containerDOM;
  4694. };
  4695. _proto.isMoving = function isMoving() {
  4696. return !!this._moving;
  4697. };
  4698. _proto.onMoveStart = function onMoveStart(param) {
  4699. this._originCenter = this.getCenter();
  4700. this._moving = true;
  4701. this._trySetCursor('move');
  4702. this._fireEvent('movestart', this._parseEvent(param ? param['domEvent'] : null, 'movestart'));
  4703. };
  4704. _proto.onMoving = function onMoving(param) {
  4705. this._fireEvent('moving', this._parseEvent(param ? param['domEvent'] : null, 'moving'));
  4706. };
  4707. _proto.onMoveEnd = function onMoveEnd(param) {
  4708. this._moving = false;
  4709. this._trySetCursor('default');
  4710. this._fireEvent('moveend', param && param['domEvent'] ? this._parseEvent(param['domEvent'], 'moveend') : param);
  4711. if (!this._verifyExtent(this.getCenter())) {
  4712. var moveTo = this._originCenter;
  4713. if (!this._verifyExtent(moveTo)) {
  4714. moveTo = this.getMaxExtent().getCenter();
  4715. }
  4716. this.panTo(moveTo);
  4717. }
  4718. };
  4719. _proto.onDragRotateStart = function onDragRotateStart(param) {
  4720. this._dragRotating = true;
  4721. this._fireEvent('dragrotatestart', this._parseEvent(param ? param['domEvent'] : null, 'dragrotatestart'));
  4722. };
  4723. _proto.onDragRotating = function onDragRotating(param) {
  4724. this._fireEvent('dragrotating', this._parseEvent(param ? param['domEvent'] : null, 'dragrotating'));
  4725. };
  4726. _proto.onDragRotateEnd = function onDragRotateEnd(param) {
  4727. this._dragRotating = false;
  4728. this._fireEvent('dragrotateend', this._parseEvent(param ? param['domEvent'] : null, 'dragrotateend'));
  4729. };
  4730. _proto.isDragRotating = function isDragRotating() {
  4731. return !!this._dragRotating;
  4732. };
  4733. _proto.getRenderer = function getRenderer() {
  4734. return this._getRenderer();
  4735. };
  4736. _proto._initContainer = function _initContainer(container) {
  4737. if (isString(container)) {
  4738. this._containerDOM = document.getElementById(container);
  4739. if (!this._containerDOM) {
  4740. throw new Error('Invalid container when creating map: \'' + container + '\'');
  4741. }
  4742. } else {
  4743. this._containerDOM = container;
  4744. if (IS_NODE) {
  4745. this.CanvasClass = this._containerDOM.constructor;
  4746. }
  4747. }
  4748. if (this._containerDOM.childNodes && this._containerDOM.childNodes.length > 0) {
  4749. if (this._containerDOM.childNodes[0].className === 'maptalks-wrapper') {
  4750. throw new Error('Container is already loaded with another map instance, use map.remove() to clear it.');
  4751. }
  4752. }
  4753. };
  4754. _proto._trySetCursor = function _trySetCursor(cursor) {
  4755. if (!this._cursor && !this._priorityCursor) {
  4756. if (!cursor) {
  4757. cursor = 'default';
  4758. }
  4759. this._setCursorToPanel(cursor);
  4760. }
  4761. return this;
  4762. };
  4763. _proto._setPriorityCursor = function _setPriorityCursor(cursor) {
  4764. if (!cursor) {
  4765. var hasCursor = false;
  4766. if (this._priorityCursor) {
  4767. hasCursor = true;
  4768. }
  4769. delete this._priorityCursor;
  4770. if (hasCursor) {
  4771. this.setCursor(this._cursor);
  4772. }
  4773. } else {
  4774. this._priorityCursor = cursor;
  4775. this._setCursorToPanel(cursor);
  4776. }
  4777. return this;
  4778. };
  4779. _proto._setCursorToPanel = function _setCursorToPanel(cursor) {
  4780. var panel = this.getMainPanel();
  4781. if (panel && panel.style && panel.style.cursor !== cursor) {
  4782. panel.style.cursor = cursor;
  4783. }
  4784. };
  4785. _proto._get2DExtent = function _get2DExtent(zoom) {
  4786. var _this3 = this;
  4787. var cExtent = this.getContainerExtent();
  4788. return cExtent.convertTo(function (c) {
  4789. return _this3._containerPointToPoint(c, zoom);
  4790. });
  4791. };
  4792. _proto._pointToExtent = function _pointToExtent(extent2D) {
  4793. var min2d = extent2D.getMin(),
  4794. max2d = extent2D.getMax();
  4795. var fullExtent = this.getFullExtent();
  4796. var _ref = !fullExtent || fullExtent.left <= fullExtent.right ? [min2d.x, max2d.x] : [max2d.x, min2d.x],
  4797. minx = _ref[0],
  4798. maxx = _ref[1];
  4799. var _ref2 = !fullExtent || fullExtent.top > fullExtent.bottom ? [max2d.y, min2d.y] : [min2d.y, max2d.y],
  4800. miny = _ref2[0],
  4801. maxy = _ref2[1];
  4802. var min = new Coordinate(minx, miny),
  4803. max = new Coordinate(maxx, maxy);
  4804. return new Extent(this.pointToCoord(min), this.pointToCoord(max), this.getProjection());
  4805. };
  4806. _proto._removeLayer = function _removeLayer(layer, layerList) {
  4807. if (!layer || !layerList) {
  4808. return;
  4809. }
  4810. var index = layerList.indexOf(layer);
  4811. if (index > -1) {
  4812. layerList.splice(index, 1);
  4813. }
  4814. };
  4815. _proto._sortLayersByZIndex = function _sortLayersByZIndex() {
  4816. if (!this._layers) {
  4817. return;
  4818. }
  4819. for (var i = 0, l = this._layers.length; i < l; i++) {
  4820. this._layers[i]._order = i;
  4821. }
  4822. this._layers.sort(function (a, b) {
  4823. var c = a.getZIndex() - b.getZIndex();
  4824. if (c === 0) {
  4825. return a._order - b._order;
  4826. }
  4827. return c;
  4828. });
  4829. };
  4830. _proto._fireEvent = function _fireEvent(eventName, param) {
  4831. if (this._noEvent) {
  4832. return;
  4833. }
  4834. this.fire('_' + eventName, param);
  4835. this.fire(eventName, param);
  4836. };
  4837. _proto._Load = function _Load() {
  4838. this._resetMapStatus();
  4839. if (this.options['pitch']) {
  4840. this.setPitch(this.options['pitch']);
  4841. delete this.options['pitch'];
  4842. }
  4843. if (this.options['bearing']) {
  4844. this.setBearing(this.options['bearing']);
  4845. delete this.options['bearing'];
  4846. }
  4847. this._loadAllLayers();
  4848. this._getRenderer().onLoad();
  4849. this._loaded = true;
  4850. this._callOnLoadHooks();
  4851. this._initTime = now();
  4852. };
  4853. _proto._initRenderer = function _initRenderer() {
  4854. var renderer = this.options['renderer'];
  4855. var clazz = Map.getRendererClass(renderer);
  4856. this._renderer = new clazz(this);
  4857. this._renderer.load();
  4858. };
  4859. _proto._getRenderer = function _getRenderer() {
  4860. return this._renderer;
  4861. };
  4862. _proto._loadAllLayers = function _loadAllLayers() {
  4863. function loadLayer(layer) {
  4864. if (layer) {
  4865. layer.load();
  4866. }
  4867. }
  4868. if (this._baseLayer) {
  4869. this._baseLayer.load();
  4870. }
  4871. this._eachLayer(loadLayer, this.getLayers());
  4872. };
  4873. _proto._getLayers = function _getLayers(filter) {
  4874. var layers = this._baseLayer ? [this._baseLayer].concat(this._layers) : this._layers;
  4875. var result = [];
  4876. for (var i = 0; i < layers.length; i++) {
  4877. if (!filter || filter.call(this, layers[i])) {
  4878. result.push(layers[i]);
  4879. }
  4880. }
  4881. return result;
  4882. };
  4883. _proto._eachLayer = function _eachLayer(fn) {
  4884. if (arguments.length < 2) {
  4885. return;
  4886. }
  4887. var layerLists = Array.prototype.slice.call(arguments, 1);
  4888. if (layerLists && !Array.isArray(layerLists)) {
  4889. layerLists = [layerLists];
  4890. }
  4891. var layers = [];
  4892. for (var i = 0, len = layerLists.length; i < len; i++) {
  4893. layers = layers.concat(layerLists[i]);
  4894. }
  4895. for (var j = 0, jlen = layers.length; j < jlen; j++) {
  4896. fn.call(fn, layers[j]);
  4897. }
  4898. };
  4899. _proto._onLayerEvent = function _onLayerEvent(param) {
  4900. if (!param) {
  4901. return;
  4902. }
  4903. if (param['type'] === 'idchange') {
  4904. delete this._layerCache[param['old']];
  4905. this._layerCache[param['new']] = param['target'];
  4906. }
  4907. };
  4908. _proto._resetMapStatus = function _resetMapStatus() {
  4909. var maxZoom = this.getMaxZoom(),
  4910. minZoom = this.getMinZoom();
  4911. var viewMaxZoom = this._spatialReference.getMaxZoom(),
  4912. viewMinZoom = this._spatialReference.getMinZoom();
  4913. if (isNil(maxZoom) || maxZoom === -1 || maxZoom > viewMaxZoom) {
  4914. this.setMaxZoom(viewMaxZoom);
  4915. }
  4916. if (isNil(minZoom) || minZoom === -1 || minZoom < viewMinZoom) {
  4917. this.setMinZoom(viewMinZoom);
  4918. }
  4919. maxZoom = this.getMaxZoom();
  4920. minZoom = this.getMinZoom();
  4921. if (maxZoom < minZoom) {
  4922. this.setMaxZoom(minZoom);
  4923. }
  4924. if (isNil(this._zoomLevel) || this._zoomLevel > maxZoom) {
  4925. this._zoomLevel = maxZoom;
  4926. }
  4927. if (this._zoomLevel < minZoom) {
  4928. this._zoomLevel = minZoom;
  4929. }
  4930. delete this._prjCenter;
  4931. var projection = this.getProjection();
  4932. this._prjCenter = projection.project(this._center);
  4933. // this._calcMatrices();
  4934. // var renderer = this._getRenderer();
  4935. // if (renderer) {
  4936. // renderer.resetContainer();
  4937. // }
  4938. };
  4939. _proto._getContainerDomSize = function _getContainerDomSize() {
  4940. if (!this._containerDOM) {
  4941. return null;
  4942. }
  4943. var containerDOM = this._containerDOM;
  4944. var width, height;
  4945. if (!isNil(containerDOM.width) && !isNil(containerDOM.height)) {
  4946. width = containerDOM.width;
  4947. height = containerDOM.height;
  4948. if (Browser$1.retina && containerDOM['layer']) {
  4949. width /= 2;
  4950. height /= 2;
  4951. }
  4952. } else if (!isNil(containerDOM.clientWidth) && !isNil(containerDOM.clientHeight)) {
  4953. width = parseInt(containerDOM.clientWidth, 0);
  4954. height = parseInt(containerDOM.clientHeight, 0);
  4955. } else {
  4956. throw new Error('can not get size of container');
  4957. }
  4958. return new Size(width, height);
  4959. };
  4960. _proto._updateMapSize = function _updateMapSize(mSize) {
  4961. this.width = mSize['width'];
  4962. this.height = mSize['height'];
  4963. this._getRenderer().updateMapSize(mSize);
  4964. this._calcMatrices();
  4965. return this;
  4966. };
  4967. _proto._getPrjCenter = function _getPrjCenter() {
  4968. return this._prjCenter;
  4969. };
  4970. _proto._setPrjCenter = function _setPrjCenter(pcenter) {
  4971. this._prjCenter = pcenter;
  4972. if (this.isInteracting() && !this.isMoving()) {
  4973. this._mapViewCoord = pcenter;
  4974. }
  4975. this._calcMatrices();
  4976. };
  4977. _proto._setPrjCoordAtContainerPoint = function _setPrjCoordAtContainerPoint(coordinate, point) {
  4978. if (point.x === this.width / 2 && point.y === this.height / 2) {
  4979. return this;
  4980. }
  4981. var t = this._containerPointToPoint(point)._sub(this._prjToPoint(this._getPrjCenter()));
  4982. var pcenter = this._pointToPrj(this._prjToPoint(coordinate).sub(t));
  4983. this._setPrjCenter(pcenter);
  4984. return this;
  4985. };
  4986. _proto._verifyExtent = function _verifyExtent(center) {
  4987. if (!center) {
  4988. return false;
  4989. }
  4990. var maxExt = this.getMaxExtent();
  4991. if (!maxExt) {
  4992. return true;
  4993. }
  4994. return maxExt.contains(center);
  4995. };
  4996. _proto._offsetCenterByPixel = function _offsetCenterByPixel(pixel) {
  4997. var pos = new Point(this.width / 2 - pixel.x, this.height / 2 - pixel.y);
  4998. var pCenter = this._containerPointToPrj(pos);
  4999. this._setPrjCenter(pCenter);
  5000. return pCenter;
  5001. };
  5002. _proto.offsetPlatform = function offsetPlatform(offset) {
  5003. if (!offset) {
  5004. return this._mapViewPoint;
  5005. } else {
  5006. this._getRenderer().offsetPlatform(offset);
  5007. this._mapViewCoord = this._getPrjCenter();
  5008. this._mapViewPoint = this._mapViewPoint.add(offset);
  5009. return this;
  5010. }
  5011. };
  5012. _proto.getViewPoint = function getViewPoint() {
  5013. var offset = this._getViewPointFrameOffset();
  5014. var panelOffset = this.offsetPlatform();
  5015. if (offset) {
  5016. panelOffset = panelOffset.add(offset);
  5017. }
  5018. return panelOffset;
  5019. };
  5020. _proto._getViewPointFrameOffset = function _getViewPointFrameOffset() {
  5021. if (this.isZooming()) {
  5022. return null;
  5023. }
  5024. var pcenter = this._getPrjCenter();
  5025. if (this._mapViewCoord && !this._mapViewCoord.equals(pcenter)) {
  5026. return this._prjToContainerPoint(this._mapViewCoord).sub(this._prjToContainerPoint(pcenter));
  5027. }
  5028. return null;
  5029. };
  5030. _proto._resetMapViewPoint = function _resetMapViewPoint() {
  5031. this._mapViewPoint = new Point(0, 0);
  5032. this._mapViewCoord = this._getPrjCenter();
  5033. };
  5034. _proto._getResolution = function _getResolution(zoom) {
  5035. if (isNil(zoom)) {
  5036. zoom = this.getZoom();
  5037. }
  5038. return this._spatialReference.getResolution(zoom);
  5039. };
  5040. _proto._getResolutions = function _getResolutions() {
  5041. return this._spatialReference.getResolutions();
  5042. };
  5043. _proto._prjToPoint = function _prjToPoint(pCoord, zoom) {
  5044. zoom = isNil(zoom) ? this.getZoom() : zoom;
  5045. return this._spatialReference.getTransformation().transform(pCoord, this._getResolution(zoom));
  5046. };
  5047. _proto._pointToPrj = function _pointToPrj(point, zoom) {
  5048. zoom = isNil(zoom) ? this.getZoom() : zoom;
  5049. return this._spatialReference.getTransformation().untransform(point, this._getResolution(zoom));
  5050. };
  5051. _proto._pointToPoint = function _pointToPoint(point, zoom) {
  5052. if (!isNil(zoom)) {
  5053. return point.multi(this._getResolution(zoom) / this._getResolution());
  5054. }
  5055. return point.copy();
  5056. };
  5057. _proto._pointToPointAtZoom = function _pointToPointAtZoom(point, zoom) {
  5058. if (!isNil(zoom)) {
  5059. return point.multi(this._getResolution() / this._getResolution(zoom));
  5060. }
  5061. return point.copy();
  5062. };
  5063. _proto._containerPointToPrj = function _containerPointToPrj(containerPoint) {
  5064. return this._pointToPrj(this._containerPointToPoint(containerPoint));
  5065. };
  5066. _proto._viewPointToPrj = function _viewPointToPrj(viewPoint) {
  5067. return this._containerPointToPrj(this.viewPointToContainerPoint(viewPoint));
  5068. };
  5069. _proto._prjToContainerPoint = function _prjToContainerPoint(pCoordinate, zoom) {
  5070. return this._pointToContainerPoint(this._prjToPoint(pCoordinate, zoom), zoom);
  5071. };
  5072. _proto._prjToViewPoint = function _prjToViewPoint(pCoordinate) {
  5073. var containerPoint = this._prjToContainerPoint(pCoordinate);
  5074. return this._containerPointToViewPoint(containerPoint);
  5075. };
  5076. _proto._containerPointToViewPoint = function _containerPointToViewPoint(containerPoint) {
  5077. if (!containerPoint) {
  5078. return null;
  5079. }
  5080. return containerPoint._sub(this.getViewPoint());
  5081. };
  5082. _proto._viewPointToPoint = function _viewPointToPoint(viewPoint, zoom) {
  5083. return this._containerPointToPoint(this.viewPointToContainerPoint(viewPoint), zoom);
  5084. };
  5085. _proto._pointToViewPoint = function _pointToViewPoint(point, zoom) {
  5086. return this._prjToViewPoint(this._pointToPrj(point, zoom));
  5087. };
  5088. _proto._callOnLoadHooks = function _callOnLoadHooks() {
  5089. var proto = Map.prototype;
  5090. if (!proto._onLoadHooks) {
  5091. return;
  5092. }
  5093. for (var i = 0, l = proto._onLoadHooks.length; i < l; i++) {
  5094. proto._onLoadHooks[i].call(this);
  5095. }
  5096. };
  5097. return Map;
  5098. }(Handlerable(Eventable(Renderable(Class))));
  5099. Map$1.mergeOptions(options$1);
  5100. var RADIAN = Math.PI / 180;
  5101. var DEFAULT_FOV = 0.6435011087932844;
  5102. Map$1.include({
  5103. getFov: function getFov() {
  5104. if (!this._fov) {
  5105. this._fov = DEFAULT_FOV;
  5106. }
  5107. return this._fov / RADIAN;
  5108. },
  5109. setFov: function setFov(fov) {
  5110. if (this.isZooming()) {
  5111. return this;
  5112. }
  5113. fov = Math.max(0.01, Math.min(60, fov));
  5114. if (this._fov === fov) return this;
  5115. var from = this.getFov();
  5116. this._fov = fov * RADIAN;
  5117. this._calcMatrices();
  5118. this._renderLayers();
  5119. this._fireEvent('fovchange', {
  5120. 'from': from,
  5121. 'to': this.getFov()
  5122. });
  5123. return this;
  5124. },
  5125. getBearing: function getBearing() {
  5126. if (!this._angle) {
  5127. return 0;
  5128. }
  5129. return -this._angle / RADIAN;
  5130. },
  5131. setBearing: function setBearing(bearing) {
  5132. if (Browser$1.ie9) {
  5133. throw new Error('map can\'t rotate in IE9.');
  5134. }
  5135. var b = -wrap(bearing, -180, 180) * RADIAN;
  5136. if (this._angle === b) return this;
  5137. var from = this.getBearing();
  5138. this._fireEvent('rotatestart', {
  5139. 'from': from,
  5140. 'to': b
  5141. });
  5142. this._angle = b;
  5143. this._calcMatrices();
  5144. this._renderLayers();
  5145. this._fireEvent('rotate', {
  5146. 'from': from,
  5147. 'to': b
  5148. });
  5149. this._fireEvent('rotateend', {
  5150. 'from': from,
  5151. 'to': b
  5152. });
  5153. return this;
  5154. },
  5155. getPitch: function getPitch() {
  5156. if (!this._pitch) {
  5157. return 0;
  5158. }
  5159. return this._pitch / Math.PI * 180;
  5160. },
  5161. setPitch: function setPitch(pitch) {
  5162. if (Browser$1.ie9) {
  5163. throw new Error('map can\'t tilt in IE9.');
  5164. }
  5165. var p = clamp(pitch, 0, this.options['maxPitch']) * RADIAN;
  5166. if (this._pitch === p) return this;
  5167. var from = this.getPitch();
  5168. this._fireEvent('pitchstart', {
  5169. 'from': from,
  5170. 'to': p
  5171. });
  5172. this._pitch = p;
  5173. this._calcMatrices();
  5174. this._renderLayers();
  5175. this._fireEvent('pitch', {
  5176. 'from': from,
  5177. 'to': p
  5178. });
  5179. this._fireEvent('pitchend', {
  5180. 'from': from,
  5181. 'to': p
  5182. });
  5183. return this;
  5184. },
  5185. isTransforming: function isTransforming() {
  5186. return !!(this._pitch || this._angle);
  5187. },
  5188. getFrustumAltitude: function getFrustumAltitude() {
  5189. var pitch = 90 - this.getPitch();
  5190. var fov = this.getFov() / 2;
  5191. var cameraAlt = this.cameraPosition ? this.cameraPosition[2] : 0;
  5192. if (fov <= pitch) {
  5193. return cameraAlt;
  5194. }
  5195. fov = Math.PI * fov / 180;
  5196. var d1 = new Point(this.cameraPosition).distanceTo(new Point(this.cameraLookAt)),
  5197. d2 = cameraAlt * Math.tan(fov * 2);
  5198. var d = Math.tan(fov) * (d1 + d2);
  5199. return cameraAlt + d;
  5200. },
  5201. _pointToContainerPoint: function () {
  5202. var a = [0, 0, 0];
  5203. return function (point, zoom, altitude) {
  5204. if (altitude === void 0) {
  5205. altitude = 0;
  5206. }
  5207. point = this._pointToPoint(point, zoom);
  5208. if (this.isTransforming() || altitude) {
  5209. altitude *= this.getResolution(zoom) / this.getResolution();
  5210. var _scale = this._glScale;
  5211. set$2(a, point.x * _scale, point.y * _scale, altitude * _scale);
  5212. var t = this._projIfBehindCamera(a, this.cameraPosition, this.cameraForward);
  5213. applyMatrix(t, t, this.projViewMatrix);
  5214. var w2 = this.width / 2,
  5215. h2 = this.height / 2;
  5216. t[0] = t[0] * w2 + w2;
  5217. t[1] = -(t[1] * h2) + h2;
  5218. return new Point(t[0], t[1]);
  5219. } else {
  5220. var centerPoint = this._prjToPoint(this._getPrjCenter());
  5221. return point._sub(centerPoint)._add(this.width / 2, this.height / 2);
  5222. }
  5223. };
  5224. }(),
  5225. _projIfBehindCamera: function () {
  5226. var vectorFromCam = new Array(3);
  5227. var proj = new Array(3);
  5228. var sub = new Array(3);
  5229. return function (position, cameraPos, camForward) {
  5230. subtract(vectorFromCam, position, cameraPos);
  5231. var camNormDot = dot(camForward, vectorFromCam);
  5232. if (camNormDot <= 0) {
  5233. scale$1(proj, camForward, camNormDot * 1.01);
  5234. add(position, cameraPos, subtract(sub, vectorFromCam, proj));
  5235. }
  5236. return position;
  5237. };
  5238. }(),
  5239. _containerPointToPoint: function () {
  5240. var cp = [0, 0, 0],
  5241. coord0 = [0, 0, 0, 1],
  5242. coord1 = [0, 0, 0, 1];
  5243. return function (p, zoom) {
  5244. if (this.isTransforming()) {
  5245. var w2 = this.width / 2 || 1,
  5246. h2 = this.height / 2 || 1;
  5247. set$2(cp, (p.x - w2) / w2, (h2 - p.y) / h2, 0);
  5248. set$2(coord0, cp[0], cp[1], 0);
  5249. set$2(coord1, cp[0], cp[1], 1);
  5250. coord0[3] = coord1[3] = 1;
  5251. applyMatrix(coord0, coord0, this.projViewMatrixInverse);
  5252. applyMatrix(coord1, coord1, this.projViewMatrixInverse);
  5253. var x0 = coord0[0];
  5254. var x1 = coord1[0];
  5255. var y0 = coord0[1];
  5256. var y1 = coord1[1];
  5257. var z0 = coord0[2];
  5258. var z1 = coord1[2];
  5259. var t = z0 === z1 ? 0 : (0 - z0) / (z1 - z0);
  5260. var point = new Point(interpolate(x0, x1, t), interpolate(y0, y1, t))._multi(1 / this._glScale);
  5261. return zoom === undefined || this.getZoom() === zoom ? point : this._pointToPointAtZoom(point, zoom);
  5262. }
  5263. var centerPoint = this._prjToPoint(this._getPrjCenter(), zoom),
  5264. scale$$1 = zoom !== undefined ? this._getResolution() / this._getResolution(zoom) : 1;
  5265. var x = scale$$1 * (p.x - this.width / 2),
  5266. y = scale$$1 * (p.y - this.height / 2);
  5267. return centerPoint._add(x, y);
  5268. };
  5269. }(),
  5270. _calcMatrices: function () {
  5271. var m0 = Browser$1.ie9 ? null : createMat4(),
  5272. m1 = Browser$1.ie9 ? null : createMat4();
  5273. return function () {
  5274. if (Browser$1.ie9) {
  5275. return;
  5276. }
  5277. var size = this.getSize();
  5278. var w = size.width || 1,
  5279. h = size.height || 1;
  5280. this._glScale = this.getGLScale();
  5281. var fov = this.getFov() * Math.PI / 180;
  5282. var maxScale = this.getScale(this.getMinZoom()) / this.getScale(this.getMaxNativeZoom());
  5283. var farZ = maxScale * h / 2 / this._getFovRatio() * 1.4;
  5284. var projMatrix = this.projMatrix || createMat4();
  5285. perspective(projMatrix, fov, w / h, 0.1, farZ);
  5286. this.projMatrix = projMatrix;
  5287. var worldMatrix = this._getCameraWorldMatrix();
  5288. this.viewMatrix = invert(m0, worldMatrix);
  5289. this.projViewMatrix = multiply(this.projViewMatrix || createMat4(), projMatrix, this.viewMatrix);
  5290. this.projViewMatrixInverse = multiply(this.projViewMatrixInverse || createMat4(), worldMatrix, invert(m1, projMatrix));
  5291. this.domCssMatrix = this._calcDomMatrix();
  5292. };
  5293. }(),
  5294. _calcDomMatrix: function () {
  5295. var m = Browser$1.ie9 ? null : createMat4(),
  5296. minusY = [1, -1, 1],
  5297. arr = [0, 0, 0];
  5298. return function () {
  5299. var cameraToCenterDistance = 0.5 / Math.tan(this._fov / 2) * this.height;
  5300. scale(m, this.projMatrix, minusY);
  5301. translate(m, m, set$2(arr, 0, 0, -cameraToCenterDistance));
  5302. if (this._pitch) {
  5303. rotateX(m, m, this._pitch);
  5304. }
  5305. if (this._angle) {
  5306. rotateZ(m, m, this._angle);
  5307. }
  5308. var m1 = createMat4();
  5309. scale(m1, m1, set$2(arr, this.width / 2, -this.height / 2, 1));
  5310. return multiply(this.domCssMatrix || createMat4(), m1, m);
  5311. };
  5312. }(),
  5313. _getCameraWorldMatrix: function () {
  5314. var q = {},
  5315. minusY = [1, -1, 1];
  5316. return function () {
  5317. var targetZ = this.getGLZoom();
  5318. var size = this.getSize(),
  5319. scale$$1 = this.getGLScale();
  5320. var center2D = this._prjToPoint(this._prjCenter, targetZ);
  5321. this.cameraLookAt = set$2(this.cameraLookAt || [0, 0, 0], center2D.x, center2D.y, 0);
  5322. var pitch = this.getPitch() * RADIAN;
  5323. var bearing = -this.getBearing() * RADIAN;
  5324. var ratio = this._getFovRatio();
  5325. var z = scale$$1 * (size.height || 1) / 2 / ratio;
  5326. var cz = z * Math.cos(pitch);
  5327. var dist = Math.sin(pitch) * z;
  5328. var cx = center2D.x + dist * Math.sin(bearing);
  5329. var cy = center2D.y + dist * Math.cos(bearing);
  5330. this.cameraPosition = set$2(this.cameraPosition || [0, 0, 0], cx, cy, cz);
  5331. var d = dist || 1;
  5332. var up = this.cameraUp = set$2(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0);
  5333. var m = this.cameraWorldMatrix = this.cameraWorldMatrix || createMat4();
  5334. lookAt(m, this.cameraPosition, this.cameraLookAt, up);
  5335. var cameraForward = this.cameraForward || [0, 0, 0];
  5336. subtract(cameraForward, this.cameraLookAt, this.cameraPosition);
  5337. this.cameraForward = normalize(cameraForward, cameraForward);
  5338. matrixToQuaternion(q, m);
  5339. quaternionToMatrix(m, q);
  5340. setPosition(m, this.cameraPosition);
  5341. scale(m, m, minusY);
  5342. return m;
  5343. };
  5344. }(),
  5345. _getFovRatio: function _getFovRatio() {
  5346. var fov = this.getFov();
  5347. return Math.tan(fov / 2 * RADIAN);
  5348. },
  5349. _renderLayers: function _renderLayers() {
  5350. if (this.isInteracting()) {
  5351. return;
  5352. }
  5353. var layers = this._getLayers();
  5354. layers.forEach(function (layer) {
  5355. if (!layer) {
  5356. return;
  5357. }
  5358. var renderer = layer._getRenderer();
  5359. if (renderer && renderer.setToRedraw) {
  5360. renderer.setToRedraw();
  5361. }
  5362. });
  5363. }
  5364. });
  5365. function createMat4() {
  5366. return identity(new Array(16));
  5367. }
  5368. function identity(out) {
  5369. out[0] = 1;
  5370. out[1] = 0;
  5371. out[2] = 0;
  5372. out[3] = 0;
  5373. out[4] = 0;
  5374. out[5] = 1;
  5375. out[6] = 0;
  5376. out[7] = 0;
  5377. out[8] = 0;
  5378. out[9] = 0;
  5379. out[10] = 1;
  5380. out[11] = 0;
  5381. out[12] = 0;
  5382. out[13] = 0;
  5383. out[14] = 0;
  5384. out[15] = 1;
  5385. return out;
  5386. }
  5387. Map$1.include({
  5388. _zoom: function _zoom(nextZoom, origin) {
  5389. if (!this.options['zoomable'] || this.isZooming()) {
  5390. return;
  5391. }
  5392. origin = this._checkZoomOrigin(origin);
  5393. nextZoom = this._checkZoom(nextZoom);
  5394. this.onZoomStart(nextZoom, origin);
  5395. this._frameZoom = this.getZoom();
  5396. this.onZoomEnd(nextZoom, origin);
  5397. },
  5398. _zoomAnimation: function _zoomAnimation(nextZoom, origin, startScale) {
  5399. if (!this.options['zoomable'] || this.isZooming()) {
  5400. return;
  5401. }
  5402. nextZoom = this._checkZoom(nextZoom);
  5403. if (this.getZoom() === nextZoom) {
  5404. return;
  5405. }
  5406. origin = this._checkZoomOrigin(origin);
  5407. this._startZoomAnim(nextZoom, origin, startScale);
  5408. },
  5409. _checkZoomOrigin: function _checkZoomOrigin(origin) {
  5410. if (!origin || this.options['zoomInCenter']) {
  5411. origin = new Point(this.width / 2, this.height / 2);
  5412. }
  5413. return origin;
  5414. },
  5415. _startZoomAnim: function _startZoomAnim(nextZoom, origin, startScale) {
  5416. if (isNil(startScale)) {
  5417. startScale = 1;
  5418. }
  5419. var endScale = this._getResolution(this._startZoomVal) / this._getResolution(nextZoom);
  5420. var duration = this.options['zoomAnimationDuration'] * Math.abs(endScale - startScale) / Math.abs(endScale - 1);
  5421. this._frameZoom = this._startZoomVal;
  5422. this.animateTo({
  5423. 'zoom': nextZoom,
  5424. 'around': origin
  5425. }, {
  5426. 'continueOnViewChanged': true,
  5427. 'duration': duration
  5428. });
  5429. },
  5430. onZoomStart: function onZoomStart(nextZoom, origin) {
  5431. if (!this.options['zoomable'] || this.isZooming()) {
  5432. return;
  5433. }
  5434. this._zooming = true;
  5435. this._startZoomVal = this.getZoom();
  5436. this._startZoomCoord = this._containerPointToPrj(origin);
  5437. this._fireEvent('zoomstart', {
  5438. 'from': this._startZoomVal,
  5439. 'to': nextZoom
  5440. });
  5441. },
  5442. onZooming: function onZooming(nextZoom, origin, startScale) {
  5443. if (!this.options['zoomable']) {
  5444. return;
  5445. }
  5446. var frameZoom = this._frameZoom;
  5447. if (frameZoom === nextZoom) {
  5448. return;
  5449. }
  5450. if (isNil(startScale)) {
  5451. startScale = 1;
  5452. }
  5453. this._zoomTo(nextZoom, origin);
  5454. var res = this.getResolution(nextZoom),
  5455. fromRes = this.getResolution(this._startZoomVal),
  5456. scale = fromRes / res / startScale,
  5457. startPoint = this._prjToContainerPoint(this._startZoomCoord, this._startZoomVal);
  5458. var offset = this.getViewPoint();
  5459. if (!this.isRotating() && !startPoint.equals(origin) && scale !== 1) {
  5460. var pitch = this.getPitch();
  5461. var originOffset = startPoint._sub(origin)._multi(1 / (1 - scale));
  5462. if (pitch) {
  5463. originOffset.y /= Math.cos(pitch * Math.PI / 180);
  5464. }
  5465. origin = origin.add(originOffset);
  5466. }
  5467. var matrix = {
  5468. 'view': [scale, 0, 0, scale, (origin.x - offset.x) * (1 - scale), (origin.y - offset.y) * (1 - scale)]
  5469. };
  5470. if (Browser$1.retina) {
  5471. origin = origin.multi(2);
  5472. }
  5473. matrix['container'] = [scale, 0, 0, scale, origin.x * (1 - scale), origin.y * (1 - scale)];
  5474. this._fireEvent('zooming', {
  5475. 'from': this._startZoomVal,
  5476. 'to': nextZoom,
  5477. 'origin': origin,
  5478. 'matrix': matrix
  5479. });
  5480. this._frameZoom = nextZoom;
  5481. },
  5482. onZoomEnd: function onZoomEnd(nextZoom, origin) {
  5483. if (!this.options['zoomable']) {
  5484. return;
  5485. }
  5486. var startZoomVal = this._startZoomVal;
  5487. this._zoomTo(nextZoom, origin);
  5488. this._zooming = false;
  5489. // this._getRenderer().onZoomEnd();
  5490. this._fireEvent('zoomend', {
  5491. 'from': startZoomVal,
  5492. 'to': nextZoom
  5493. });
  5494. if (!this._verifyExtent(this.getCenter())) {
  5495. this.panTo(this.getMaxExtent().getCenter());
  5496. }
  5497. },
  5498. _zoomTo: function _zoomTo(nextZoom, origin) {
  5499. this._zoomLevel = nextZoom;
  5500. this._calcMatrices();
  5501. if (origin) {
  5502. this._setPrjCoordAtContainerPoint(this._startZoomCoord, origin);
  5503. }
  5504. },
  5505. _checkZoom: function _checkZoom(nextZoom) {
  5506. var maxZoom = this.getMaxZoom(),
  5507. minZoom = this.getMinZoom();
  5508. if (nextZoom < minZoom) {
  5509. nextZoom = minZoom;
  5510. }
  5511. if (nextZoom > maxZoom) {
  5512. nextZoom = maxZoom;
  5513. }
  5514. return nextZoom;
  5515. }
  5516. });
  5517. var Size = function () {
  5518. function Size(width, height) {
  5519. if (isNumber(width) && isNumber(height)) {
  5520. this.width = width;
  5521. this.height = height;
  5522. } else if (isNumber(width['width'])) {
  5523. this.width = width.width;
  5524. this.height = width.height;
  5525. } else if (Array.isArray(width)) {
  5526. this.width = width[0];
  5527. this.height = width[1];
  5528. }
  5529. }
  5530. var _proto = Size.prototype;
  5531. _proto.copy = function copy() {
  5532. return new Size(this['width'], this['height']);
  5533. };
  5534. _proto.add = function add(x, y) {
  5535. var w, h;
  5536. if (x instanceof Size) {
  5537. w = this.width + x.width;
  5538. h = this.height + x.height;
  5539. } else {
  5540. w = this.width + x;
  5541. h = this.height + y;
  5542. }
  5543. return new Size(w, h);
  5544. };
  5545. _proto.equals = function equals(size) {
  5546. return this['width'] === size['width'] && this['height'] === size['height'];
  5547. };
  5548. _proto.multi = function multi(ratio) {
  5549. return new Size(this['width'] * ratio, this['height'] * ratio);
  5550. };
  5551. _proto._multi = function _multi(ratio) {
  5552. this['width'] *= ratio;
  5553. this['height'] *= ratio;
  5554. return this;
  5555. };
  5556. _proto._round = function _round() {
  5557. this['width'] = Math.round(this['width']);
  5558. this['height'] = Math.round(this['height']);
  5559. return this;
  5560. };
  5561. _proto.toPoint = function toPoint() {
  5562. return new Point(this['width'], this['height']);
  5563. };
  5564. _proto.toArray = function toArray() {
  5565. return [this['width'], this['height']];
  5566. };
  5567. _proto.toJSON = function toJSON() {
  5568. return {
  5569. 'width': this['width'],
  5570. 'height': this['height']
  5571. };
  5572. };
  5573. return Size;
  5574. }();
  5575. function perspective(out, fovy, aspect, near, far) {
  5576. var f = 1.0 / Math.tan(fovy / 2),
  5577. nf = 1 / (near - far);
  5578. out[0] = f / aspect;
  5579. out[1] = 0;
  5580. out[2] = 0;
  5581. out[3] = 0;
  5582. out[4] = 0;
  5583. out[5] = f;
  5584. out[6] = 0;
  5585. out[7] = 0;
  5586. out[8] = 0;
  5587. out[9] = 0;
  5588. out[10] = (far + near) * nf;
  5589. out[11] = -1;
  5590. out[12] = 0;
  5591. out[13] = 0;
  5592. out[14] = 2 * far * near * nf;
  5593. out[15] = 0;
  5594. return out;
  5595. }
  5596. function set$2(out, x, y, z) {
  5597. out[0] = x;
  5598. out[1] = y;
  5599. out[2] = z;
  5600. return out;
  5601. }
  5602. function lookAt(te, eye, target, up) {
  5603. var x = [0, 0, 0];
  5604. var y = [0, 0, 0];
  5605. var z = [0, 0, 0];
  5606. subtract(z, eye, target);
  5607. if (length(z) === 0) {
  5608. z[2] = 1;
  5609. }
  5610. normalize(z, z);
  5611. cross(x, up, z);
  5612. if (length(z) === 0) {
  5613. if (Math.abs(up[2]) === 1) {
  5614. z[0] += 0.0001;
  5615. } else {
  5616. z[2] += 0.0001;
  5617. }
  5618. normalize(z, z);
  5619. cross(x, up, z);
  5620. }
  5621. normalize(x, x);
  5622. cross(y, z, x);
  5623. te[0] = x[0];
  5624. te[4] = y[0];
  5625. te[8] = z[0];
  5626. te[1] = x[1];
  5627. te[5] = y[1];
  5628. te[9] = z[1];
  5629. te[2] = x[2];
  5630. te[6] = y[2];
  5631. te[10] = z[2];
  5632. return te;
  5633. }
  5634. function subtract(out, a, b) {
  5635. out[0] = a[0] - b[0];
  5636. out[1] = a[1] - b[1];
  5637. out[2] = a[2] - b[2];
  5638. return out;
  5639. }
  5640. function length(a) {
  5641. var x = a[0],
  5642. y = a[1],
  5643. z = a[2];
  5644. return Math.sqrt(x * x + y * y + z * z);
  5645. }
  5646. function normalize(out, a) {
  5647. var x = a[0],
  5648. y = a[1],
  5649. z = a[2];
  5650. var len = x * x + y * y + z * z;
  5651. if (len > 0) {
  5652. len = 1 / Math.sqrt(len);
  5653. out[0] = a[0] * len;
  5654. out[1] = a[1] * len;
  5655. out[2] = a[2] * len;
  5656. }
  5657. return out;
  5658. }
  5659. function cross(out, a, b) {
  5660. var ax = a[0],
  5661. ay = a[1],
  5662. az = a[2],
  5663. bx = b[0],
  5664. by = b[1],
  5665. bz = b[2];
  5666. out[0] = ay * bz - az * by;
  5667. out[1] = az * bx - ax * bz;
  5668. out[2] = ax * by - ay * bx;
  5669. return out;
  5670. }
  5671. function matrixToQuaternion(out, te) {
  5672. var m11 = te[0],
  5673. m12 = te[4],
  5674. m13 = te[8],
  5675. m21 = te[1],
  5676. m22 = te[5],
  5677. m23 = te[9],
  5678. m31 = te[2],
  5679. m32 = te[6],
  5680. m33 = te[10],
  5681. trace = m11 + m22 + m33;
  5682. var s;
  5683. if (trace > 0) {
  5684. s = 0.5 / Math.sqrt(trace + 1.0);
  5685. out.w = 0.25 / s;
  5686. out.x = (m32 - m23) * s;
  5687. out.y = (m13 - m31) * s;
  5688. out.z = (m21 - m12) * s;
  5689. } else if (m11 > m22 && m11 > m33) {
  5690. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  5691. out.w = (m32 - m23) / s;
  5692. out.x = 0.25 * s;
  5693. out.y = (m12 + m21) / s;
  5694. out.z = (m13 + m31) / s;
  5695. } else if (m22 > m33) {
  5696. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  5697. out.w = (m13 - m31) / s;
  5698. out.x = (m12 + m21) / s;
  5699. out.y = 0.25 * s;
  5700. out.z = (m23 + m32) / s;
  5701. } else {
  5702. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  5703. out.w = (m21 - m12) / s;
  5704. out.x = (m13 + m31) / s;
  5705. out.y = (m23 + m32) / s;
  5706. out.z = 0.25 * s;
  5707. }
  5708. return this;
  5709. }
  5710. function quaternionToMatrix(out, q) {
  5711. var te = out;
  5712. var x = q.x,
  5713. y = q.y,
  5714. z = q.z,
  5715. w = q.w;
  5716. var x2 = x + x,
  5717. y2 = y + y,
  5718. z2 = z + z;
  5719. var xx = x * x2,
  5720. xy = x * y2,
  5721. xz = x * z2;
  5722. var yy = y * y2,
  5723. yz = y * z2,
  5724. zz = z * z2;
  5725. var wx = w * x2,
  5726. wy = w * y2,
  5727. wz = w * z2;
  5728. te[0] = 1 - (yy + zz);
  5729. te[4] = xy - wz;
  5730. te[8] = xz + wy;
  5731. te[1] = xy + wz;
  5732. te[5] = 1 - (xx + zz);
  5733. te[9] = yz - wx;
  5734. te[2] = xz - wy;
  5735. te[6] = yz + wx;
  5736. te[10] = 1 - (xx + yy);
  5737. te[3] = 0;
  5738. te[7] = 0;
  5739. te[11] = 0;
  5740. te[12] = 0;
  5741. te[13] = 0;
  5742. te[14] = 0;
  5743. te[15] = 1;
  5744. return te;
  5745. }
  5746. function setPosition(out, v) {
  5747. var te = out;
  5748. te[12] = v[0];
  5749. te[13] = v[1];
  5750. te[14] = v[2];
  5751. return out;
  5752. }
  5753. function scale(out, a, v) {
  5754. var x = v[0],
  5755. y = v[1],
  5756. z = v[2];
  5757. out[0] = a[0] * x;
  5758. out[1] = a[1] * x;
  5759. out[2] = a[2] * x;
  5760. out[3] = a[3] * x;
  5761. out[4] = a[4] * y;
  5762. out[5] = a[5] * y;
  5763. out[6] = a[6] * y;
  5764. out[7] = a[7] * y;
  5765. out[8] = a[8] * z;
  5766. out[9] = a[9] * z;
  5767. out[10] = a[10] * z;
  5768. out[11] = a[11] * z;
  5769. out[12] = a[12];
  5770. out[13] = a[13];
  5771. out[14] = a[14];
  5772. out[15] = a[15];
  5773. return out;
  5774. }
  5775. function invert(out, a) {
  5776. var a00 = a[0],
  5777. a01 = a[1],
  5778. a02 = a[2],
  5779. a03 = a[3],
  5780. a10 = a[4],
  5781. a11 = a[5],
  5782. a12 = a[6],
  5783. a13 = a[7],
  5784. a20 = a[8],
  5785. a21 = a[9],
  5786. a22 = a[10],
  5787. a23 = a[11],
  5788. a30 = a[12],
  5789. a31 = a[13],
  5790. a32 = a[14],
  5791. a33 = a[15],
  5792. b00 = a00 * a11 - a01 * a10,
  5793. b01 = a00 * a12 - a02 * a10,
  5794. b02 = a00 * a13 - a03 * a10,
  5795. b03 = a01 * a12 - a02 * a11,
  5796. b04 = a01 * a13 - a03 * a11,
  5797. b05 = a02 * a13 - a03 * a12,
  5798. b06 = a20 * a31 - a21 * a30,
  5799. b07 = a20 * a32 - a22 * a30,
  5800. b08 = a20 * a33 - a23 * a30,
  5801. b09 = a21 * a32 - a22 * a31,
  5802. b10 = a21 * a33 - a23 * a31,
  5803. b11 = a22 * a33 - a23 * a32,
  5804. det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
  5805. if (!det) {
  5806. return null;
  5807. }
  5808. det = 1.0 / det;
  5809. out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
  5810. out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
  5811. out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
  5812. out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
  5813. out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
  5814. out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
  5815. out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
  5816. out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
  5817. out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
  5818. out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
  5819. out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
  5820. out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
  5821. out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
  5822. out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
  5823. out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
  5824. out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
  5825. return out;
  5826. }
  5827. function multiply(out, a, b) {
  5828. var a00 = a[0],
  5829. a01 = a[1],
  5830. a02 = a[2],
  5831. a03 = a[3],
  5832. a10 = a[4],
  5833. a11 = a[5],
  5834. a12 = a[6],
  5835. a13 = a[7],
  5836. a20 = a[8],
  5837. a21 = a[9],
  5838. a22 = a[10],
  5839. a23 = a[11],
  5840. a30 = a[12],
  5841. a31 = a[13],
  5842. a32 = a[14],
  5843. a33 = a[15];
  5844. var b0 = b[0],
  5845. b1 = b[1],
  5846. b2 = b[2],
  5847. b3 = b[3];
  5848. out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
  5849. out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
  5850. out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
  5851. out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
  5852. b0 = b[4];
  5853. b1 = b[5];
  5854. b2 = b[6];
  5855. b3 = b[7];
  5856. out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
  5857. out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
  5858. out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
  5859. out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
  5860. b0 = b[8];
  5861. b1 = b[9];
  5862. b2 = b[10];
  5863. b3 = b[11];
  5864. out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
  5865. out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
  5866. out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
  5867. out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
  5868. b0 = b[12];
  5869. b1 = b[13];
  5870. b2 = b[14];
  5871. b3 = b[15];
  5872. out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
  5873. out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
  5874. out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
  5875. out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
  5876. return out;
  5877. }
  5878. function translate(out, a, v) {
  5879. var x = v[0],
  5880. y = v[1],
  5881. z = v[2],
  5882. a00,
  5883. a01,
  5884. a02,
  5885. a03,
  5886. a10,
  5887. a11,
  5888. a12,
  5889. a13,
  5890. a20,
  5891. a21,
  5892. a22,
  5893. a23;
  5894. if (a === out) {
  5895. out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
  5896. out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
  5897. out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
  5898. out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
  5899. } else {
  5900. a00 = a[0];
  5901. a01 = a[1];
  5902. a02 = a[2];
  5903. a03 = a[3];
  5904. a10 = a[4];
  5905. a11 = a[5];
  5906. a12 = a[6];
  5907. a13 = a[7];
  5908. a20 = a[8];
  5909. a21 = a[9];
  5910. a22 = a[10];
  5911. a23 = a[11];
  5912. out[0] = a00;
  5913. out[1] = a01;
  5914. out[2] = a02;
  5915. out[3] = a03;
  5916. out[4] = a10;
  5917. out[5] = a11;
  5918. out[6] = a12;
  5919. out[7] = a13;
  5920. out[8] = a20;
  5921. out[9] = a21;
  5922. out[10] = a22;
  5923. out[11] = a23;
  5924. out[12] = a00 * x + a10 * y + a20 * z + a[12];
  5925. out[13] = a01 * x + a11 * y + a21 * z + a[13];
  5926. out[14] = a02 * x + a12 * y + a22 * z + a[14];
  5927. out[15] = a03 * x + a13 * y + a23 * z + a[15];
  5928. }
  5929. return out;
  5930. }
  5931. Map$1.include({
  5932. animateTo: function animateTo(view, options, step) {
  5933. var _this = this;
  5934. if (options === void 0) {
  5935. options = {};
  5936. }
  5937. this._stopAnim(this._animPlayer);
  5938. if (isFunction(options)) {
  5939. step = options;
  5940. options = {};
  5941. }
  5942. var projection = this.getProjection(),
  5943. currView = this.getView(),
  5944. props = {};
  5945. var empty = true;
  5946. for (var p in view) {
  5947. if (hasOwn(view, p) && !isNil(currView[p])) {
  5948. empty = false;
  5949. if (p === 'center') {
  5950. var from = new Coordinate(currView[p]).toFixed(7),
  5951. to = new Coordinate(view[p]).toFixed(7);
  5952. if (!from.equals(to)) {
  5953. props['center'] = [from, to];
  5954. }
  5955. } else if (currView[p] !== view[p] && p !== 'around') {
  5956. props[p] = [currView[p], view[p]];
  5957. }
  5958. }
  5959. }
  5960. if (empty) {
  5961. return null;
  5962. }
  5963. var zoomOrigin = view['around'] || new Point(this.width / 2, this.height / 2);
  5964. var preView = this.getView();
  5965. var renderer = this._getRenderer(),
  5966. framer = function framer(fn) {
  5967. renderer.callInNextFrame(fn);
  5968. };
  5969. var player = this._animPlayer = Animation.animate(props, {
  5970. 'easing': options['easing'] || 'out',
  5971. 'duration': options['duration'] || this.options['zoomAnimationDuration'],
  5972. 'framer': framer
  5973. }, function (frame) {
  5974. if (_this.isRemoved()) {
  5975. player.finish();
  5976. return;
  5977. }
  5978. if (player.playState === 'running') {
  5979. var _view = _this.getView();
  5980. if (!options['continueOnViewChanged'] && !equalView(_view, preView)) {
  5981. _this._stopAnim(player);
  5982. return;
  5983. }
  5984. if (frame.styles['center']) {
  5985. var center = frame.styles['center'];
  5986. _this._setPrjCenter(projection.project(center));
  5987. _this.onMoving(_this._parseEventFromCoord(_this.getCenter()));
  5988. }
  5989. if (!isNil(frame.styles['zoom'])) {
  5990. _this.onZooming(frame.styles['zoom'], zoomOrigin);
  5991. }
  5992. if (!isNil(frame.styles['pitch'])) {
  5993. _this.setPitch(frame.styles['pitch']);
  5994. }
  5995. if (!isNil(frame.styles['bearing'])) {
  5996. _this.setBearing(frame.styles['bearing']);
  5997. }
  5998. preView = _this.getView();
  5999. _this._fireEvent('animating');
  6000. } else if (player.playState === 'finished') {
  6001. if (!player._interupted) {
  6002. if (props['center']) {
  6003. _this._setPrjCenter(projection.project(props['center'][1]));
  6004. }
  6005. if (!isNil(props['pitch'])) {
  6006. _this.setPitch(props['pitch'][1]);
  6007. }
  6008. if (!isNil(props['bearing'])) {
  6009. _this.setBearing(props['bearing'][1]);
  6010. }
  6011. }
  6012. _this._endAnim(player, props, zoomOrigin, options);
  6013. preView = _this.getView();
  6014. }
  6015. if (step) {
  6016. step(frame);
  6017. }
  6018. });
  6019. this._startAnim(props, zoomOrigin);
  6020. return player;
  6021. },
  6022. isAnimating: function isAnimating() {
  6023. return !!this._animPlayer;
  6024. },
  6025. isRotating: function isRotating() {
  6026. return this.isDragRotating() || !!this._animRotating;
  6027. },
  6028. _endAnim: function _endAnim(player, props, zoomOrigin, options) {
  6029. delete this._animRotating;
  6030. var evtType = player._interupted ? 'animateinterrupted' : 'animateend';
  6031. if (player === this._animPlayer) {
  6032. delete this._animPlayer;
  6033. }
  6034. if (props['center']) {
  6035. var endCoord;
  6036. if (player._interupted) {
  6037. endCoord = this.getCenter();
  6038. } else {
  6039. endCoord = props['center'][1];
  6040. }
  6041. this.onMoveEnd(this._parseEventFromCoord(endCoord));
  6042. }
  6043. if (!isNil(props['zoom'])) {
  6044. if (player._interupted) {
  6045. this.onZoomEnd(this.getZoom(), zoomOrigin);
  6046. } else if (!options['wheelZoom']) {
  6047. this.onZoomEnd(props['zoom'][1], zoomOrigin);
  6048. } else {
  6049. this.onZooming(props['zoom'][1], zoomOrigin);
  6050. }
  6051. }
  6052. if (evtType) {
  6053. this._fireEvent(evtType);
  6054. }
  6055. if (!isNil(props['pitch']) && !this.getPitch()) {
  6056. this.getRenderer().setToRedraw();
  6057. }
  6058. },
  6059. _startAnim: function _startAnim(props, zoomOrigin) {
  6060. if (!this._animPlayer) {
  6061. return;
  6062. }
  6063. if (props['center']) {
  6064. this.onMoveStart();
  6065. }
  6066. if (props['zoom'] && !this.isZooming()) {
  6067. this.onZoomStart(props['zoom'][1], zoomOrigin);
  6068. }
  6069. if (props['pitch'] || props['bearing']) {
  6070. this._animRotating = true;
  6071. }
  6072. this._fireEvent('animatestart');
  6073. this._animPlayer.play();
  6074. },
  6075. _stopAnim: function _stopAnim(player) {
  6076. if (player && player.playState !== 'finished') {
  6077. player._interupted = true;
  6078. player.finish();
  6079. }
  6080. }
  6081. });
  6082. function rotateZ(out, a, rad) {
  6083. var s = Math.sin(rad),
  6084. c = Math.cos(rad),
  6085. a00 = a[0],
  6086. a01 = a[1],
  6087. a02 = a[2],
  6088. a03 = a[3],
  6089. a10 = a[4],
  6090. a11 = a[5],
  6091. a12 = a[6],
  6092. a13 = a[7];
  6093. if (a !== out) {
  6094. out[8] = a[8];
  6095. out[9] = a[9];
  6096. out[10] = a[10];
  6097. out[11] = a[11];
  6098. out[12] = a[12];
  6099. out[13] = a[13];
  6100. out[14] = a[14];
  6101. out[15] = a[15];
  6102. }
  6103. out[0] = a00 * c + a10 * s;
  6104. out[1] = a01 * c + a11 * s;
  6105. out[2] = a02 * c + a12 * s;
  6106. out[3] = a03 * c + a13 * s;
  6107. out[4] = a10 * c - a00 * s;
  6108. out[5] = a11 * c - a01 * s;
  6109. out[6] = a12 * c - a02 * s;
  6110. out[7] = a13 * c - a03 * s;
  6111. return out;
  6112. }
  6113. function clamp(n, min, max) {
  6114. return Math.min(max, Math.max(min, n));
  6115. }
  6116. function rotateX(out, a, rad) {
  6117. var s = Math.sin(rad),
  6118. c = Math.cos(rad),
  6119. a10 = a[4],
  6120. a11 = a[5],
  6121. a12 = a[6],
  6122. a13 = a[7],
  6123. a20 = a[8],
  6124. a21 = a[9],
  6125. a22 = a[10],
  6126. a23 = a[11];
  6127. if (a !== out) {
  6128. out[0] = a[0];
  6129. out[1] = a[1];
  6130. out[2] = a[2];
  6131. out[3] = a[3];
  6132. out[12] = a[12];
  6133. out[13] = a[13];
  6134. out[14] = a[14];
  6135. out[15] = a[15];
  6136. }
  6137. out[4] = a10 * c + a20 * s;
  6138. out[5] = a11 * c + a21 * s;
  6139. out[6] = a12 * c + a22 * s;
  6140. out[7] = a13 * c + a23 * s;
  6141. out[8] = a20 * c - a10 * s;
  6142. out[9] = a21 * c - a11 * s;
  6143. out[10] = a22 * c - a12 * s;
  6144. out[11] = a23 * c - a13 * s;
  6145. return out;
  6146. }
  6147. function applyMatrix(out, v, e) {
  6148. var x = v[0],
  6149. y = v[1],
  6150. z = v[2];
  6151. var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
  6152. out[0] = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
  6153. out[1] = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
  6154. out[2] = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
  6155. return out;
  6156. }
  6157. function interpolate(a, b, t) {
  6158. return a * (1 - t) + b * t;
  6159. }
  6160. export default toGeometry
  6161. export {
  6162. Map$1,
  6163. Coordinate,
  6164. MultiPolygon,
  6165. Polygon
  6166. }