Google Map - 计算多边形的中心(KML信息)

时间:2014-04-16 18:50:22

标签: google-maps kml google-fusion-tables

我正在制作加拿大地图,其中包含省名的下拉列表。选择省份后,该区域将突出显示。但我也希望选择区域中心和缩放。我该如何存档?组成多边形的字段采用KML格式。如下所示:

<Polygon><outerBoundaryIs><LinearRing><coordinates>
 -79.4899109797,43.7593230106,0 
 -79.4896677095,43.758325766,0 
 -79.489598978,43.7580440068,0 
 -79.4894469845,43.7574330077,0 
 -79.4893805858,43.7571877791,0 
 -79.4891539442,43.7563508348,0 
 -79.489063906,43.7559532696,0 
 -79.4890139973,43.7557329664,0 
 -79.489012622,43.7557273679,0 
 -79.4887962379,43.7548472638,0 
 -79.4887176649,43.7545276665,0 
 -79.4887039739,43.7544719908,0 
 -79.4884681409,43.7534358788,0 
 -79.488464993,43.7534219808,0 
 -79.4881372456,43.7520529398,0 
 -79.4885846288,43.7519653535,0 
 -79.4889461482,43.7518945811,0 
 -79.4891329882,43.7518580045,0 
 -79.4891953615,43.7518634918,0 
 -79.4893030121,43.751872975,0 
 -79.4894520045,43.7519039794,0 
 -79.4896689859,43.7519869959,0 
 -79.4897999689,43.7520580128,0 
 -79.4903528109,43.7525308022,0 
 -79.4903787855,43.752550664,0 
 -79.4905769956,43.7527020091,0 
 -79.4906948839,43.7527666016,0 
 -79.4908380055,43.7528450075,0 
 -79.4910340076,43.7529160225,0 
 -79.4913231677,43.7529780113,0 
 -79.4915775552,43.7530058953,0 
 -79.4917059989,43.7530199724,0 
 -79.4917426287,43.7530155761,0 
 -79.4919640114,43.7529890337,0 
 -79.4922600104,43.7529309901,0 
 -79.4929275419,43.7527826466,0 
 -79.4938799972,43.7525709696,0 
 -79.494122591,43.7524908682,0 
 -79.4942069936,43.7524629975,0 
 -79.4942594921,43.752445484,0 
 -79.4944079903,43.7523959746,0 
 -79.4944613769,43.7523738796,0 
 -79.4945069801,43.7523550127,0 
 -79.4945316271,43.7523398641,0 
 -79.4945460135,43.7523310061,0 
 -79.4948609787,43.7521670156,0 
 -79.4952056693,43.7519384471,0 
 -79.4952742311,43.7518929835,0 
 -79.4956059848,43.7516729839,0 
 -79.495730552,43.751583492,0 
 -79.4963349543,43.7511492976,0 
 -79.496642989,43.7509280128,0 
 -79.4968329923,43.7508090041,0 
 -79.4971180071,43.750667032,0 
 -79.4974937434,43.7505380585,0 
 -79.497728718,43.7504800702,0 
 -79.4984306578,43.7503266947,0 
 -79.4992852129,43.7501399539,0 
 -79.4996058997,43.7500635278,0 
 -79.4999060057,43.7499919983,0 
 -79.5012319916,43.7496940378,0 
 -79.502193992,43.7494720135,0 
 -79.5024582146,43.7494159592,0 
 -79.5027220193,43.7493599941,0 
 -79.5037508031,43.7492332964,0 
 -79.5045692823,43.7491325029,0 
 -79.5046060055,43.7491279802,0 
 -79.5044531796,43.7490428694,0 
 -79.5041472435,43.7488587929,0 
 -79.5040388348,43.7487521115,0 
 -79.5039896248,43.7487036613,0 
 -79.5038291451,43.7486655606,0 
 -79.5038211336,43.7486611786,0 
 -79.503694359,43.7485917495,0 
 -79.5036112614,43.7484375975,0 
 -79.503614171,43.7483205956,0 
 -79.5035784673,43.74825707,0 
 -79.5032098135,43.748099206,0 
 -79.5031517419,43.748061358,0 
 -79.5030264727,43.7479797366,0 
 -79.5028418109,43.7479354342,0 
 -79.5024709319,43.7478464186,0 
 -79.5022875804,43.7477269564,0 
 -79.5021663388,43.747608306,0 
 -79.5021355996,43.7473468159,0 
 -79.5016088831,43.7470517943,0 
 -79.5012517446,43.7469300583,0 
 -79.5009181351,43.7468626467,0 
 -79.5004388507,43.7466582843,0 
 -79.5001670176,43.7466006928,0 
 -79.4999905535,43.7466073259,0 
 -79.4996579943,43.746594017,0 
 -79.4994237107,43.7465103158,0 
 -79.4992394209,43.7464444542,0 
 -79.4991493574,43.7464064038,0 
 -79.4988215883,43.7462679046,0 
 -79.4983036978,43.7461170339,0 
 -79.4980702952,43.746014897,0 
 -79.4977498887,43.7457813345,0 
 -79.4977573524,43.7456146298,0 
 -79.4978364044,43.745435616,0 
 -79.4978398951,43.7452953417,0 
 -79.4978402154,43.7452825945,0 
 -79.4977786735,43.7450091387,0 
 -79.4977731511,43.7449845655,0 
 -79.4977877855,43.7443995607,0 
 -79.4978848081,43.7441847916,0 
 -79.4978929411,43.7441667912,0 
 -79.4978947266,43.7440948143,0 
 -79.49766312,43.7439206909,0 
 -79.4976516369,43.7438845207,0 
 -79.4976748868,43.7438218782,0 
 -79.4976854723,43.7438092256,0 
 -79.4979046539,43.7436987702,0 
 -79.497932196,43.7435910876,0 
 -79.4979034416,43.7435474582,0 
 -79.4978723602,43.7435002696,0 
 -79.4977486588,43.7434806237,0 
 -79.4976360461,43.743515151,0 
 -79.4974342537,43.7436385548,0 
 -79.497336267,43.7435832639,0 
 -79.4971917601,43.7434012509,0 
 -79.4971967066,43.7432032417,0 
 -79.4972980317,43.7431235655,0 
 -79.4973626151,43.7430253718,0 
 -79.4973646389,43.7429443546,0 
 -79.497269615,43.7427720466,0 
 -79.49709648,43.7427427421,0 
 -79.4969188181,43.7425189974,0 
 -79.4969919195,43.7425027653,0 
 -79.498522002,43.742163022,0 
 -79.4996768709,43.7419061671,0 
 -79.5000958179,43.7418129798,0 
 -79.5014489939,43.7415120034,0 
 -79.5033647525,43.741066072,0 
 -79.5047034464,43.7407752878,0 
 -79.5054858641,43.7406053434,0 
 -79.505528993,43.7405959742,0 
 -79.5068309986,43.740312975,0 
 -79.5096160121,43.7396919652,0 
 -79.5100820431,43.73958646,0 
 -79.5103710148,43.7395210323,0 
 -79.5108839699,43.7394330003,0 
 -79.5111821414,43.7394429937,0 
 -79.511577995,43.739487015,0 
 -79.5118077999,43.7395161912,0 
 -79.5120110175,43.7395419825,0 
 -79.5123665182,43.7395460162,0 
 -79.5123679831,43.7395460256,0 
 -79.5127047201,43.7395050559,0 
 -79.5129410106,43.7394628624,0 
 -79.5131920141,43.7394180182,0 
 -79.5128438974,43.738202616,0 
 -79.5123860242,43.7366039714,0 
 -79.5123820278,43.7365879488,0 
 -79.5120558178,43.7352793528,0 
 -79.5118829869,43.7345860051,0 
 -79.5116479815,43.7335320082,0 
 -79.5116099784,43.7333597815,0 
 -79.5116078384,43.733350026,0 
 -79.5115372875,43.73302726,0 
 -79.5112709785,43.7318090005,0 
 -79.5112416637,43.7316813489,0 
 -79.5112031972,43.7315138753,0 
 -79.5110564558,43.7308749711,0 
 -79.5109065494,43.7302222149,0 
 -79.5109039051,43.7302107445,0 
 -79.5109035511,43.7302091623,0 
 -79.5106970016,43.7292840253,0 
 -79.5105703266,43.7287773617,0 
 -79.5105545391,43.7287142346,0 
 -79.5103639984,43.7279520418,0 
 -79.5103626077,43.7279464612,0 
 -79.5101460372,43.727077166,0 
 -79.5099780251,43.7264029686,0 
 -79.5095792634,43.724892732,0 
 -79.5095780246,43.7248880226,0 
 -79.5093869529,43.7239469084,0 
 -79.509385561,43.7239413458,0 
 -79.5092749296,43.7235028017,0 
 -79.5092361969,43.7233554353,0 
 -79.5091600995,43.7230659578,0 
 -79.5090251199,43.7225525333,0 
 -79.5090147234,43.7225129367,0 
 -79.5089789929,43.7223770741,0 
 -79.5089072337,43.722125553,0 
 -79.5088559467,43.7219458179,0 
 -79.5087820268,43.7216659806,0 
 -79.5087121185,43.7214010589,0 
 -79.5085910061,43.7209420153,0 
 -79.5083833099,43.7201361358,0 
 -79.5081160178,43.7190990025,0 
 -79.5079705006,43.7184929532,0 
 -79.5079469173,43.7183947731,0 
 -79.5079189534,43.7182887307,0 
 -79.5077652866,43.7177049406,0 
 -79.5128730026,43.7171329855,0 
 -79.5128752452,43.7171327404,0 
 -79.5187529964,43.7164910019,0 
 -79.5206136097,43.7162931136,0 
 -79.5215158177,43.7161971482,0 
 -79.5235570703,43.7159799722,0 
 -79.5252130293,43.7157839954,0 
 -79.5262865643,43.7155758807,0 
 -79.5265130209,43.7155319776,0 
 -79.5296219253,43.7148306135,0 
 -79.5297186274,43.7148087965,0 
 -79.5311384274,43.7144884372,0 
 -79.5311398052,43.7144881364,0 
 -79.5329439705,43.7140810317,0 
 -79.5355219768,43.713499008,0 
 -79.5359643184,43.7133991718,0 
 -79.5359652675,43.7133989515,0 
 -79.5365207082,43.7132617697,0 
 -79.537824418,43.7129397534,0 
 -79.5378329958,43.7129376374,0 
 -79.5378316274,43.7129555704,0 
 -79.5378147175,43.7136304319,0 
 -79.5380062649,43.7144824746,0 
 -79.5380318395,43.7145962463,0 
 -79.5383646474,43.7147054616,0 
 -79.5392436348,43.7149233936,0 
 -79.5401672308,43.7150548808,0 
 -79.5406111638,43.7152262779,0 
 -79.540896048,43.7155915325,0 
 -79.5409031095,43.7161955401,0 
 -79.5409300022,43.7166477128,0 
 -79.5414073035,43.716932141,0 
 -79.5420267499,43.716927543,0 
 -79.5429291704,43.7169013524,0 
 -79.5433811213,43.7170429872,0 
 -79.5437513659,43.717250265,0 
 -79.5440015383,43.7175584573,0 
 -79.5441276504,43.7178295092,0 
 -79.5441457344,43.7181567721,0 
 -79.54383169,43.7185295385,0 
 -79.543640209,43.7188645038,0 
 -79.5434615175,43.7191771012,0 
 -79.5434565621,43.7191857761,0 
 -79.5434428269,43.719209508,0 
 -79.5431940159,43.7196395501,0 
 -79.5431022092,43.7197987371,0 
 -79.5430264008,43.7199302012,0 
 -79.5428934706,43.7204215083,0 
 -79.5424193123,43.7208766806,0 
 -79.542346404,43.7209466747,0 
 -79.5416961826,43.7213798454,0 
 -79.5412178961,43.7217292066,0 
 -79.5409082094,43.7221644705,0 
 -79.5406517319,43.7225609243,0 
 -79.5407804949,43.7228729797,0 
 -79.5407608045,43.7232565149,0 
 -79.5407355895,43.7237479549,0 
 -79.5408442063,43.7241344987,0 
 -79.5409674853,43.7242888461,0 
 -79.541290087,43.7246927362,0 
 -79.5414336917,43.725501738,0 
 -79.5410918053,43.7260560913,0 
 -79.540534952,43.7263015494,0 
 -79.5397921736,43.7262886069,0 
 -79.5393739239,43.7263373267,0 
 -79.5389809586,43.7265287841,0 
 -79.5385018117,43.7267234285,0 
 -79.5382654211,43.7270454352,0 
 -79.5382097883,43.7274086232,0 
 -79.5383634415,43.7277861335,0 
 -79.5386036888,43.7282378185,0 
 -79.538757374,43.7286153028,0 
 -79.5388369871,43.7289513629,0 
 -79.5388513662,43.7293708942,0 
 -79.5386281972,43.7298803574,0 
 -79.5385554144,43.7309368766,0 
 -79.5385416487,43.7311978947,0 
 -79.5385141319,43.7317195986,0 
 -79.5385287838,43.7318021588,0 
 -79.5385479286,43.7319099379,0 
 -79.5387455754,43.7320463279,0 
 -79.5391316642,43.7321167593,0 
 -79.5394437179,43.7321456951,0 
 -79.539500132,43.7319372563,0 
 -79.5394208598,43.731678565,0 
 -79.5393214486,43.7314943358,0 
 -79.5392828909,43.7311641212,0 
 -79.5393796192,43.7308067786,0 
 -79.5396281421,43.7304401281,0 
 -79.5399708612,43.7300404741,0 
 -79.540264427,43.7296647566,0 
 -79.5404894934,43.7295421629,0 
 -79.5408422398,43.7294996066,0 
 -79.5414006333,43.7295636104,0 
 -79.5429449699,43.729845198,0 
 -79.5436680422,43.7300099782,0 
 -79.5437236686,43.7300480482,0 
 -79.5444175941,43.7305495338,0 
 -79.5448290178,43.7307627023,0 
 -79.5449079455,43.7309440098,0 
 -79.5446920665,43.7312689041,0 
 -79.5441025898,43.7315561534,0 
 -79.5439479569,43.7318124935,0 
 -79.543916529,43.7320863141,0 
 -79.5441185962,43.7322851542,0 
 -79.5443162591,43.7324215247,0 
 -79.5448083225,43.7323368908,0 
 -79.5452749709,43.7321094838,0 
 -79.5455886906,43.731659307,0 
 -79.5458709343,43.7314829932,0 
 -79.546433392,43.731532051,0 
 -79.5469016506,43.7316141422,0 
 -79.5473380767,43.7318926893,0 
 -79.5476794541,43.7320494544,0 
 -79.5477422872,43.7322903399,0 
 -79.5480019383,43.7325127983,0 
 -79.5482483733,43.7325478402,0 
 -79.5485567335,43.7326690458,0 
 -79.5487523946,43.732778522,0 
 -79.5487639152,43.7327849601,0 
 -79.5488512294,43.7328338163,0 
 -79.5490636877,43.733081306,0 
 -79.549339462,43.7332442177,0 
 -79.5497050617,43.733311658,0 
 -79.5500171257,43.733340589,0 
 -79.5502429539,43.7333726881,0 
 -79.5504793432,43.7336631842,0 
 -79.5504990837,43.7336874449,0 
 -79.550481337,43.734226102,0 
 -79.5505169655,43.7343841863,0 
 -79.5506027156,43.7347647157,0 
 -79.550607331,43.7347851575,0 
 -79.5503139589,43.7350171458,0 
 -79.5499686749,43.7351804826,0 
 -79.5499363768,43.7351931982,0 
 -79.5497777483,43.7352556384,0 
 -79.5492161551,43.7355924292,0 
 -79.5489838016,43.7358995532,0 
 -79.5492100991,43.7360090652,0 
 -79.5493740102,43.7359832606,0 
 -79.5499473402,43.735928349,0 
 -79.5500798718,43.7359471948,0 
 -79.5504510977,43.7363092175,0 
 -79.5505231885,43.7367524233,0 
 -79.5499835895,43.737170481,0 
 -79.5499727009,43.7374472663,0 
 -79.5498716437,43.7377421359,0 
 -79.5496392693,43.7380492977,0 
 -79.5491589064,43.7380118982,0 
 -79.5487980996,43.7380842979,0 
 -79.5484425117,43.7383739379,0 
 -79.5483289267,43.7386360931,0 
 -79.5483595509,43.73906903,0 
 -79.548359871,43.7390734743,0 
 -79.5477695581,43.7392059953,0 
 -79.5477196769,43.7392289597,0 
 -79.5476617433,43.7392556217,0 
 -79.5469554429,43.7395807415,0 
 -79.5468416297,43.7396298844,0 
 -79.5466515988,43.7397119183,0 
 -79.54627546,43.7399986345,0 
 -79.5461582461,43.7403530449,0 
 -79.5462104467,43.7405386532,0 
 -79.546266954,43.7407396565,0 
 -79.5464159453,43.7409773131,0 
 -79.5464629465,43.7410005576,0 
 -79.5468109392,43.7411726485,0 
 -79.5471737705,43.7414871008,0 
 -79.547602229,43.741795437,0 
 -79.5481483113,43.7418267043,0 
 -79.5488132081,43.7418130276,0 
 -79.549470387,43.7419064665,0 
 -79.5495413133,43.7421175423,0 
 -79.5493250258,43.7423651245,0 
 -79.5492851325,43.742591381,0 
 -79.5494454438,43.7426296644,0 
 -79.5497281337,43.7425307009,0 
 -79.5500394487,43.7424048689,0 
 -79.550425653,43.7424752245,0 
 -79.5505416417,43.7426772472,0 
 -79.5501655138,43.7429639973,0 
 -79.5498666428,43.743122522,0 
 -79.5498766972,43.7434795906,0 
 -79.5500797177,43.7438331809,0 
 -79.5506559826,43.7441470735,0 
 -79.5511899734,43.7442229755,0 
 -79.5517602712,43.7441648487,0 
 -79.5524972979,43.7438057279,0 
 -79.5529056995,43.7435349872,0 
 -79.5529390679,43.7435128607,0 
 -79.5531763898,43.7434652261,0 
 -79.5535253946,43.7433951758,0 
 -79.5539684115,43.7433344602,0 
 -79.5544480621,43.7432170494,0 
 -79.555309902,43.7431848943,0 
 -79.5558805412,43.7432041604,0 
 -79.5559014193,43.7432014442,0 
 -79.5562784142,43.7431524323,0 
 -79.5565732072,43.74300879,0 
 -79.5569037949,43.7426537158,0 
 -79.5570293772,43.7423468318,0 
 -79.5569335452,43.7420703705,0 
 -79.5568831592,43.7418621984,0 
 -79.556734571,43.7417018948,0 
 -79.5568359726,43.7414843878,0 
 -79.5574376275,43.7411523847,0 
 -79.5577528878,43.7410116432,0 
 -79.5581721348,43.7411175875,0 
 -79.5581767329,43.7411250247,0 
 -79.5583502001,43.741405747,0 
 -79.5582544546,43.7419178423,0 
 -79.5580837117,43.7422337877,0 
 -79.5581354415,43.7425203172,0 
 -79.5583161458,43.7427151969,0 
 -79.5586286921,43.7428215026,0 
 -79.5588715409,43.7429487305,0 
 -79.5592006154,43.7430727983,0 
 -79.5595123019,43.7430243094,0 
 -79.559564632,43.742830723,0 
 -79.5597522425,43.7426099714,0 
 -79.560030491,43.7424484833,0 
 -79.560091094,43.7424609754,0 
 -79.5606636068,43.7427244271,0 
 -79.5615821932,43.7426807101,0 
 -79.5618986819,43.7427485871,0 
 -79.5620477894,43.7427968801,0 
 -79.562463446,43.7429950642,0 
 -79.5624526319,43.7432718538,0 
 -79.5623846759,43.7436023813,0 
 -79.5622014855,43.7438856341,0 
 -79.562158078,43.7442041911,0 
 -79.5625536366,43.7444767981,0 
 -79.5632693833,43.7447485624,0 
 -79.5637765005,43.7451607377,0 
 -79.5644145414,43.7454832903,0 
 -79.5649405894,43.7455888851,0 
 -79.566173881,43.7459186154,0 
 -79.5669991005,43.7459430052,0 
 -79.5684005114,43.7462307819,0 
 -79.5685080771,43.7462528675,0 
 -79.5685247785,43.7462563009,0 
 -79.5695636371,43.7464771183,0 
 -79.5706032748,43.7466555887,0 
 -79.5715070417,43.7467838408,0 
 -79.5723488313,43.746825969,0 
 -79.5727847046,43.7469496539,0 
 -79.5733616566,43.7473407718,0 
 -79.5733468713,43.7476036596,0 
 -79.5733280958,43.7479390581,0 
 -79.572683685,43.7479558498,0 
 -79.5720468386,43.7478654834,0 
 -79.571637733,43.7481166911,0 
 -79.5714104194,43.7485637452,0 
 -79.5711696285,43.7488233651,0 
 -79.5710936946,43.7491836899,0 
 -79.5716233697,43.7492086903,0 
 -79.5719176699,43.7489758937,0 
 -79.5724294972,43.7487392556,0 
 -79.572959342,43.7488274012,0 
 -79.573062262,43.7488445198,0 
 -79.5730559892,43.7489828873,0 
 -79.5729523535,43.7497257519,0 
 -79.573127836,43.7502608966,0 
 -79.5737445025,43.7504257047,0 
 -79.5741911754,43.7502726001,0 
 -79.5746830698,43.7501313564,0 
 -79.5752640029,43.750097398,0 
 -79.5760328116,43.7501846569,0 
 -79.577185766,43.7502609293,0 
 -79.5778290314,43.7503303294,0 
 -79.5787577359,43.7506801796,0 
 -79.5795425497,43.7511913748,0 
 -79.5801537339,43.7517143081,0 
 -79.5806086889,43.7518461653,0 
 -79.5810375127,43.751970459,0 
 -79.581751934,43.7522610983,0 
 -79.5819007032,43.7522930838,0 
 -79.5822152927,43.7523264877,0 
 -79.5822377226,43.7523334587,0 
 -79.5826456772,43.7524602695,0 
 -79.5829464267,43.7525537675,0 
 -79.5831821254,43.7529070763,0 
 -79.58306885,43.7536095652,0 
 -79.5830618571,43.7536529155,0 
 -79.5830480155,43.753738758,0 
 -79.583145476,43.753897997,0 
 -79.5842820491,43.7544444349,0 
 -79.584258385,43.7545956964,0 
 -79.5841573843,43.7552411401,0 
 -79.5842021228,43.7555519964,0 
 -79.5842097303,43.7556048299,0 
 -79.5845575699,43.7557728741,0 
 -79.5851682001,43.7560678854,0 
 -79.5851281573,43.7564766391,0 
 -79.5851126102,43.7570010456,0 
 -79.5850042909,43.7570561568,0 
 -79.5848594253,43.7571003106,0 
 -79.5841020132,43.7573055384,0 
 -79.5837533222,43.7574981168,0 
 -79.5837248514,43.7575138343,0 
 -79.5837244612,43.7577755285,0 
 -79.5839305041,43.7580155849,0 
 -79.5839224408,43.7586034025,0 
 -79.5834372491,43.7588400662,0 
 -79.5825241712,43.7585433732,0 
 -79.5819316155,43.7585829777,0 
 -79.5811101286,43.7587646805,0 
 -79.5805545615,43.7591875881,0 
 -79.5805858803,43.7595919822,0 
 -79.5808360999,43.7601146328,0 
 -79.5802746299,43.7605221959,0 
 -79.5798064264,43.760695766,0 
 -79.5794905314,43.7607812252,0 
 -79.579330259,43.7608245803,0 
 -79.5782930246,43.7617682216,0 
 -79.5775859249,43.7620460462,0 
 -79.5774849159,43.7622716909,0 
 -79.5777506584,43.7624766379,0 
 -79.5782119254,43.7624402379,0 
 -79.5787190375,43.7623085053,0 
 -79.5792652064,43.7622550888,0 
 -79.5795716105,43.7624226808,0 
 -79.5799471059,43.7626280492,0 
 -79.5804785593,43.7629724498,0 
 -79.580009434,43.7630758132,0 
 -79.5780562949,43.7635151565,0 
 -79.5779498328,43.7635543294,0 
 -79.5778429034,43.7636115021,0 
 -79.5777357578,43.7636416403,0 
 -79.5775910225,43.763689402,0 
 -79.5774760623,43.7637195219,0 
 -79.5773622094,43.7637405935,0 
 -79.5772171805,43.7637657927,0 
 -79.5766909841,43.7638851962,0 
 -79.574787826,43.7643257299,0 
 -79.574753215,43.7643337449,0 
 -79.5745772701,43.7643810896,0 
 -79.5723996672,43.7648578967,0 
 -79.5712506561,43.765109468,0 
 -79.5710681015,43.7651431247,0 
 -79.5710379875,43.7651502228,0 
 -79.5691449301,43.7655962943,0 
 -79.5690075584,43.7656260783,0 
 -79.5689867189,43.7656296006,0 
 -79.5689084249,43.7656428438,0 
 -79.5684735559,43.7657453335,0 
 -79.5674213948,43.7659438896,0 
 -79.5647740067,43.7665093957,0 
 -79.5647075686,43.7665232058,0 
 -79.5646513693,43.7665348872,0 
 -79.5605696599,43.767392816,0 
 -79.5605349285,43.7673999657,0 
 -79.5603637207,43.7674352427,0 
 -79.5577927128,43.7679790733,0 
 -79.5577501707,43.7679885803,0 
 -79.5571440902,43.7681239737,0 
 -79.5570832173,43.768132272,0 
 -79.557030084,43.7681450173,0 
 -79.556984149,43.7681624476,0 
 -79.5569612208,43.7681711375,0 
 -79.5567956028,43.768203028,0 
 -79.5550076118,43.768547187,0 
 -79.5549702423,43.7685549694,0 
 -79.5548859071,43.7685725453,0 
 -79.5524747048,43.7690868597,0 
 -79.5522713527,43.7691281752,0 
 -79.5520784011,43.7691673697,0 
 -79.5495706894,43.7696751752,0 
 -79.5495679347,43.7696757325,0 
 -79.5494156443,43.7697142804,0 
 -79.5482360175,43.7699477776,0 
 -79.5465135987,43.7702887026,0 
 -79.5465089875,43.7702896213,0 
 -79.5463559195,43.7703282036,0 
 -79.5433881587,43.7709296642,0 
 -79.5433794156,43.7709314139,0 
 -79.5431977951,43.7709677383,0 
 -79.5406269119,43.771497757,0 
 -79.5406205918,43.7714992054,0 
 -79.540275446,43.7715787286,0 
 -79.5400466216,43.7716299039,0 
 -79.5397723428,43.7716984416,0 
 -79.539387951,43.7717759411,0 
 -79.538177095,43.7720200623,0 
 -79.5377884847,43.7721007518,0 
 -79.536926139,43.772278682,0 
 -79.5354613294,43.7725706804,0 
 -79.5351716597,43.7726344374,0 
 -79.5351256023,43.7726429106,0 
 -79.534939075,43.7726790549,0 
 -79.5348205512,43.772702051,0 
 -79.5343928885,43.7727865858,0 
 -79.5336076138,43.7729520563,0 
 -79.5329368345,43.773079053,0 
 -79.532783663,43.7731080565,0 
 -79.5324489732,43.7731808814,0 
 -79.5324473286,43.7731812339,0 
 -79.5318066718,43.7733206251,0 
 -79.5317387678,43.7733339015,0 
 -79.5298842518,43.773696465,0 
 -79.5297695991,43.773717515,0 
 -79.5297314067,43.773725082,0 
 -79.5283896489,43.7739911002,0 
 -79.5282977973,43.774009322,0 
 -79.5268553118,43.7742787058,0 
 -79.52683975,43.7742818983,0 
 -79.5262753801,43.7743973216,0 
 -79.5256196495,43.7745284161,0 
 -79.5253402252,43.7746019638,0 
 -79.5249021601,43.7747172538,0 
 -79.5248323917,43.7747344171,0 
 -79.5247803205,43.7747472105,0 
 -79.5247525211,43.7747517029,0 
 -79.5240325592,43.7748680117,0 
 -79.523529005,43.7749741841,0 
 -79.5226361506,43.7752097897,0 
 -79.5226350327,43.7752100836,0 
 -79.5222931935,43.7753002743,0 
 -79.5218658753,43.7754027593,0 
 -79.5217212747,43.7754414833,0 
 -79.5216864548,43.775448968,0 
 -79.5205765413,43.7756876768,0 
 -79.5189512036,43.7759953225,0 
 -79.5170590786,43.7763804205,0 
 -79.5168120899,43.7764371381,0 
 -79.4944882665,43.7815609994,0 
 -79.4944592231,43.7815371774,0 
 -79.4943631862,43.7810931969,0 
 -79.4943390263,43.7809812091,0 
 -79.494311884,43.7808367595,0 
 -79.4942580393,43.780550212,0 
 -79.494295295,43.7801534138,0 
 -79.4943099703,43.7799972262,0 
 -79.4943395919,43.7798597543,0 
 -79.4944370629,43.7794077612,0 
 -79.4944577197,43.7793322138,0 
 -79.4945750206,43.7789029853,0 
 -79.4946306823,43.7786119544,0 
 -79.4946549703,43.7784849955,0 
 -79.4946629929,43.7781519805,0 
 -79.4946140004,43.7776980133,0 
 -79.4939795896,43.775239391,0 
 -79.4939789415,43.7752368591,0 
 -79.493947539,43.7751152541,0 
 -79.4939399921,43.7750859895,0 
 -79.4939080054,43.7749420059,0 
 -79.4931901224,43.7721235595,0 
 -79.4931639981,43.7720209707,0 
 -79.4920080648,43.7672951904,0 
 -79.4918283679,43.7666458976,0 
 -79.4917470891,43.7663522622,0 
 -79.4916604192,43.7660390927,0 
 -79.4915709929,43.7657159957,0 
 -79.4910169873,43.7634950117,0 
 -79.4900349842,43.7598289994,0 
 -79.4899109797,43.7593230106,0
</coordinates></LinearRing></outerBoundaryIs></Polygon>

执行高光的代码:

function changeMap_1() {
  var whereClause;
  var searchString = document.getElementById('search-string_1').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
    whereClause = "'Province' = '" + searchString + "'";
  }
  layer_1.setOptions({
    query: {
      select: "col0",
      from: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX(my map ID)",
      where: whereClause
    }
  });
}

col0是KML信息。任何帮助表示赞赏。 TKS!

1 个答案:

答案 0 :(得分:0)

一种方法是使用Google地球API的GEarthExtension Utility library来解析KML,然后计算几何边界和中心。

另见geo.Bounds Class Reference

  function initCB(instance) {
    ge = instance;
    gex = new GEarthExtensions(ge); // ge is an instance of GEPlugin
    ge.getWindow().setVisibility(true);
  }

  function checkObject(kmlObject) {
    var bounds = gex.dom.computeBounds(kmlObject); // Feature or Geometry
    var pt = bounds.center();
    // get center coordinates in lat/lon decimal degrees
    var lat = pt.lat();
    var lon = pt.lng();
    // ...
  }

如果你只想计算多边形的中心,那么这是一个免费的online center point tool。它计算中心并输出KML与该位置。只需使用多边形几何体粘贴KML即可。