Display Data From KML Files on info window using google maps API

580 views Asked by At

im pretty new to KML. I have a kmlfile containing a bunch of (approx. 35 Polygon) addresses.

this is my KML FILES :

<name>communes.kml</name>
    <Folder>
        <name>communes</name>
        <Placemark>
            <Style>
                <LineStyle>
                    <color>51626F</color>
                </LineStyle>
                <PolyStyle>
                    <fill>0</fill>
                </PolyStyle>
            </Style>
            <ExtendedData>
                <SchemaData schemaUrl="#communes">
                    <SimpleData name="ID">0</SimpleData>
                    <SimpleData name="COMMUNE">EL-JADIDA (M)</SimpleData>
                    <SimpleData name="AGR">2</SimpleData>
                    <SimpleData name="PISTES">0</SimpleData>
                    <SimpleData name="AEP">1</SimpleData>
                    <SimpleData name="T_SPORT">0</SimpleData>
                    <SimpleData name="SANTE">4</SimpleData>
                    <SimpleData name="SCOLAIRE">0</SimpleData>
                    <SimpleData name="DAR_TALIBA">2</SimpleData>
                    <SimpleData name="SOCIAUX">12</SimpleData>
                    <SimpleData name="SCOLAIRE0">1</SimpleData>
                    <SimpleData name="SOUK">0</SimpleData>
                    <SimpleData name="CULTURE">0</SimpleData>
                    <SimpleData name="ELECTRIFIC">1</SimpleData>
                    <SimpleData name="JEUNES">0</SimpleData>
                    <SimpleData name="ROUTE">3</SimpleData>
                    <SimpleData name="C_SCOLAIRE">2</SimpleData>
                    <SimpleData name="ASSAINIS">1</SimpleData>
                </SchemaData>
            </ExtendedData>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            -8.461349948243498,33.24700422091534,0 -8.460905054507018,33.24512784080741,0 -8.459536048714972,33.24163057053077,0 -8.458701134327818,33.23709488277507,0 -8.458647132554479,33.23342867640563,0 -8.459188842170056,33.23000580554068,0 -8.460743775831958,33.22617842924176,0 -8.463164680849967,33.22350098043162,0 -8.463468364841564,33.22319724170752,0 -8.462995294073748,33.22288332274442,0 -8.460965678902424,33.22218254787435,0 -8.463563911409167,33.22021401862163,0 -8.465251070738599,33.21920376685804,0 -8.467800289625798,33.21811416470625,0 -8.470446382761553,33.21710265745728,0 -8.473663679299277,33.21593974575067,0 -8.477046224117071,33.21509142164186,0 -8.481921315798015,33.21433700462716,0 -8.481641785016519,33.20971050458491,0 -8.481786270076865,33.20434855736348,0 -8.481424236300324,33.19711863870921,0 -8.493687480519826,33.19747354703218,0 -8.493754304355726,33.19819406811635,0 -8.493703301964672,33.1989578001801,0 -8.493571538562355,33.19973378463665,0 -8.493330708611545,33.20091658490414,0 -8.492971804257509,33.2025733189174,0 -8.492753736958949,33.204747361684,0 -8.492702558887959,33.20518413337071,0 -8.492717298158748,33.20567113940537,0 -8.492703461142396,33.20636090595621,0 -8.492785131266585,33.20727218346266,0 -8.492905497894775,33.20789921920513,0 -8.492955743073427,33.20837987935168,0 -8.493108211069853,33.20952556994921,0 -8.493310636401883,33.21112052798755,0 -8.493444431970092,33.21235815119572,0 -8.492888582478413,33.21441842593228,0 -8.492499781366449,33.21580490899177,0 -8.493007899780208,33.21593627377965,0 -8.52019932526448,33.21912731047546,0 -8.528835828292104,33.22455840409565,0 -8.530461545715749,33.22302797396202,0 -8.532561987986734,33.22371628293054,0 -8.534432195639786,33.22511959542914,0 -8.532512337356517,33.22675920947232,0 -8.53974159362042,33.23120459241204,0 -8.542520045868677,33.24400202051444,0 -8.541639290264941,33.24497176385498,0 -8.539163491860929,33.24599959077924,0 -8.537460571002836,33.24733275473458,0 -8.535736770296564,33.24899202141078,0 -8.534838172523411,33.24998878469221,0 -8.53399283222411,33.25097600524642,0 -8.533379615485115,33.25125291878187,0 -8.532885558337441,33.25154525254783,0 -8.532369899304714,33.25184700305344,0 -8.531648659888827,33.25178396834851,0 -8.531330541347506,33.25161178601415,0 -8.531324957039169,33.2516146572541,0 -8.531319989492497,33.2516120521465,0 -8.530569732301821,33.25196476318524,0 -8.530189483797352,33.25214568291624,0 -8.529142510926404,33.25290313779797,0 -8.527926173857814,33.25371877553748,0 -8.527498788866444,33.25408176263742,0 -8.527321606174843,33.25423912764953,0 -8.52704469878552,33.25460719644693,0 -8.525635393968368,33.25513893160906,0 -8.524974725821339,33.2558866235909,0 -8.524864944468909,33.2564306862492,0 -8.524367304478556,33.25662409804728,0 -8.523312770978274,33.25687588665467,0 -8.522331253037075,33.25764938164544,0 -8.522180029038443,33.25703065629354,0 -8.522037795961838,33.25666426544355,0 -8.521346578753436,33.25655536385862,0 -8.520783105534109,33.25610945802543,0 -8.520306311786243,33.25567911891167,0 -8.519581720356641,33.25584203719334,0 -8.518986670160032,33.25633480398069,0 -8.518684126564734,33.25657721670779,0 -8.518140093119268,33.25699702512443,0 -8.517963068647655,33.2571366246826,0 -8.517416189616437,33.25807049568887,0 -8.516968108231746,33.25847014187926,0 -8.516612628043554,33.25902923710719,0 -8.516086198165594,33.25994484058172,0 -8.515995369524489,33.26010957763851,0 -8.515568849526797,33.26049912081588,0 -8.515371520443798,33.26068495966608,0 -8.514808608973024,33.26146631848056,0 -8.514592848302456,33.26175091196853,0 -8.514154198653955,33.26239399666574,0 -8.513950452889452,33.26269671760668,0 -8.512825157439993,33.26368124727322,0 -8.511593012977238,33.26438038890526,0 -8.510444781473279,33.26474294498431,0 -8.50927193442719,33.26436617537852,0 -8.508800412959232,33.26410699181678,0 -8.508176015816455,33.26375265727422,0 -8.507618947848275,33.26348673697335,0 -8.506774790748978,33.2633276561745,0 -8.506732263091706,33.26331984650586,0 -8.505851953628831,33.26303470176416,0 -8.504191819747199,33.26257109672773,0 -8.504014155220656,33.26239533369935,0 -8.502977648494724,33.26134683967945,0 -8.502671468240196,33.26027189915025,0 -8.502614704545723,33.2601832153356,0 -8.502085736868404,33.25919506867178,0 -8.50134095492113,33.25878910126667,0 -8.501143606596207,33.25867662452149,0 -8.501110509025061,33.25865970376376,0 -8.49865905020731,33.2576649370366,0 -8.49747670588531,33.2564405172503,0 -8.497771912473317,33.25536830881794,0 -8.498383978100799,33.2538369989779,0 -8.497371861539085,33.25347385754836,0 -8.496595867248136,33.25399901466167,0 -8.496292320641114,33.25299566631848,0 -8.496067287157617,33.25209889152917,0 -8.495485547487919,33.25083217189811,0 -8.495179310298093,33.24977496327367,0 -8.493751131238922,33.24885424921065,0 -8.491656925077749,33.24795898072699,0 -8.490898560865199,33.24746318978507,0 -8.49010711420207,33.24695047045856,0 -8.488699126364839,33.24630018652282,0 -8.487200501205571,33.24612039841448,0 -8.485607054314681,33.24601598635277,0 -8.484151917372937,33.24587125812521,0 -8.482161128106212,33.2457404952651,0 -8.480353397826296,33.24564065331525,0 -8.479320266768573,33.24557618156206,0 -8.478141212984475,33.24533511586464,0 -8.477042198716509,33.24524495525337,0 -8.476113027313682,33.24508709591213,0 -8.474421517155005,33.24521978136013,0 -8.472757208889091,33.24522480895888,0 -8.4696045759159,33.24536559836136,0 -8.46876355337451,33.24556727608002,0 -8.467841649772229,33.2456166820051,0 -8.466432589861583,33.24585900035822,0 -8.464993274159211,33.24616553004724,0 -8.463093861063786,33.24651001646926,0 -8.461349948243498,33.24700422091534,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
        <Placemark>
            <Style>
                <LineStyle>
                    <color>51626F</color>
                </LineStyle>
                <PolyStyle>
                    <fill>0</fill>
                </PolyStyle>
            </Style>
            <ExtendedData>
                <SchemaData schemaUrl="#communes">
                    <SimpleData name="ID">0</SimpleData>
                    <SimpleData name="COMMUNE">HAOUZIA</SimpleData>
                    <SimpleData name="AGR">0</SimpleData>
                    <SimpleData name="PISTES">0</SimpleData>
                    <SimpleData name="AEP">0</SimpleData>
                    <SimpleData name="T_SPORT">0</SimpleData>
                    <SimpleData name="SANTE">2</SimpleData>
                    <SimpleData name="SCOLAIRE">0</SimpleData>
                    <SimpleData name="DAR_TALIBA">0</SimpleData>
                    <SimpleData name="SOCIAUX">1</SimpleData>
                    <SimpleData name="SCOLAIRE0">0</SimpleData>
                    <SimpleData name="SOUK">0</SimpleData>
                    <SimpleData name="CULTURE">0</SimpleData>
                    <SimpleData name="ELECTRIFIC">0</SimpleData>
                    <SimpleData name="JEUNES">0</SimpleData>
                    <SimpleData name="ROUTE">0</SimpleData>
                    <SimpleData name="C_SCOLAIRE">2</SimpleData>
                    <SimpleData name="ASSAINIS">0</SimpleData>
                </SchemaData>
            </ExtendedData>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            -8.344981650079998,33.316645839008,0 -8.342286695529189,33.31863176252878,0 -8.339244800895056,33.32118484380307,0 -8.338338503276097,33.32206356716078,0 -8.336801173431955,33.32332714332663,0 -8.341180507749117,33.30321920635785,0 -8.342546351187639,33.30356568213505,0 -8.355066872886001,33.2943897465123,0 -8.36550554221621,33.276149281093,0 -8.365381935197839,33.27605053040687,0 -8.364528088641661,33.27622449203911,0 -8.359948885799472,33.27624293377377,0 -8.358029549886437,33.27621972445602,0 -8.355910774725695,33.27621010583005,0 -8.354545504559617,33.27620709977533,0 -8.351957967315885,33.27617648425697,0 -8.34972585913154,33.27613123049348,0 -8.34588637728139,33.27610837542813,0 -8.345617105735483,33.27595436046263,0 -8.345447370325829,33.27576385624398,0 -8.345720965539458,33.27495877058817,0 -8.362156879518771,33.23276269057124,0 -8.363358933518537,33.22956688048173,0 -8.36412260810248,33.2283486896884,0 -8.365009476430158,33.22695554320069,0 -8.369362537964125,33.22011996962177,0 -8.371247375466338,33.21712410442969,0 -8.372262125768492,33.21570121655359,0 -8.373286597744201,33.21490127484039,0 -8.374093958926761,33.2133748096529,0 -8.375774790886901,33.21009502621607,0 -8.377715644762418,33.20687245576027,0 -8.380444750010073,33.20345891108126,0 -8.382682297629268,33.20140178987123,0 -8.383965213143471,33.20030681015291,0 -8.386782235890673,33.19414772337498,0 -8.387109826458037,33.19337330344083,0 -8.38775502596056,33.19184176512284,0 -8.388404474129594,33.18883916627855,0 -8.389216129195182,33.18590500689412,0 -8.390730202281189,33.18402760384953,0 -8.393032161442175,33.18104860412831,0 -8.395349357462331,33.17852037398783,0 -8.396609136186498,33.17550297957047,0 -8.398421743652763,33.17139850787627,0 -8.39988924641351,33.1681958494874,0 -8.401135210230885,33.16447499037012,0 -8.401164566963583,33.16438417924445,0 -8.402491388032447,33.16082380020106,0 -8.404273077959969,33.15803735536024,0 -8.4064987204051,33.15568243372213,0 -8.40944848708279,33.1522273200176,0 -8.413957448973484,33.14671242552465,0 -8.416085043060575,33.1439992931335,0 -8.41781417696847,33.13970675638814,0 -8.420073256111461,33.1352115230523,0 -8.422520106029577,33.13214714658471,0 -8.423863328231874,33.13067959285934,0 -8.426378195677692,33.12957182214731,0 -8.429646097993492,33.12793092658965,0 -8.431756089524045,33.12630870664595,0 -8.433261045327418,33.12516200225266,0 -8.433928016372043,33.12429790381944,0 -8.434654743513997,33.12298046326271,0 -8.43673741386842,33.12057452332729,0 -8.438532317869548,33.11883361786224,0 -8.440422837942734,33.11767736901756,0 -8.442053409862947,33.1164646708537,0 -8.442074653951526,33.11644571950352,0 -8.442680165814366,33.11598922070519,0 -8.443487917377368,33.11453457997107,0 -8.445229717464098,33.11344470346676,0 -8.445822958977074,33.1129161347335,0 -8.44734013793526,33.11215666103376,0 -8.449096439496705,33.11146364130782,0 -8.454953892057166,33.10877470051721,0 -8.459292909034767,33.10683627514333,0 -8.460608342157219,33.10674031903013,0 -8.461234286354868,33.10685114174444,0 -8.462003559901536,33.10676934108091,0 -8.462530071148466,33.10649421552074,0 -8.463112112888606,33.10536992869138,0 -8.464162476432097,33.10504635350002,0 -8.466177869779992,33.1038142520304,0 -8.469960460028847,33.10128442119764,0 -8.47448353029756,33.09880845772817,0 -8.478277169097058,33.09662962628012,0 -8.478683598455907,33.09751237343073,0 -8.479418536027424,33.09860470729707,0 -8.479615834112201,33.10147833544514,0 -8.480403479192303,33.10404855181661,0 -8.480566383673237,33.1062643225623,0 -8.481051286876873,33.10774034071283,0 -8.482242257134367,33.10978242583354,0 -8.483047998582391,33.11219381353126,0 -8.483610166286969,33.11385834667394,0 -8.483837659144763,33.11453870163048,0 -8.484179255356773,33.11936711516502,0 -8.484183210801639,33.12222711471051,0 -8.484207463904898,33.1256647711606,0 -8.482825953842855,33.13060839260209,0 -8.482549344159811,33.13372792532932,0 -8.48255947646139,33.1340164130809,0 -8.48262122984691,33.13577461954186,0 -8.481740717022678,33.13849482270211,0 -8.480217462629335,33.14458800513876,0 -8.479807776974091,33.14697157519642,0 -8.479652162053061,33.14804029297707,0 -8.479662602182435,33.15018748686596,0 -8.479659154675476,33.1509909901386,0 -8.479877175556331,33.15720267465957,0 -8.480252733339151,33.15964796758967,0 -8.480477001408525,33.16115844586846,0 -8.482041237850517,33.16292437177285,0 -8.484471117931797,33.1652100546488,0 -8.486167904918668,33.16769414096579,0 -8.486909322358015,33.17047365938358,0 -8.487929140556467,33.17505034869006,0 -8.488789686946694,33.17846648456872,0 -8.489443113127328,33.18026387410387,0 -8.489859603364657,33.18141801208461,0 -8.491513522432177,33.18877616124601,0 -8.492594201341479,33.19506597967748,0 -8.493687480519826,33.19747354703218,0 -8.481424236300324,33.19711863870921,0 -8.481786270076865,33.20434855736348,0 -8.481641785016519,33.20971050458491,0 -8.481921315798015,33.21433700462716,0 -8.477046224117071,33.21509142164186,0 -8.473663679299277,33.21593974575067,0 -8.470446382761553,33.21710265745728,0 -8.467800289625798,33.21811416470625,0 -8.465251070738599,33.21920376685804,0 -8.463563911409167,33.22021401862163,0 -8.460965678902424,33.22218254787435,0 -8.462995294073748,33.22288332274442,0 -8.463468364841564,33.22319724170752,0 -8.463164680849967,33.22350098043162,0 -8.460743775831958,33.22617842924176,0 -8.459188842170056,33.23000580554068,0 -8.458647132554479,33.23342867640563,0 -8.458701134327818,33.23709488277507,0 -8.459536048714972,33.24163057053077,0 -8.460905054507018,33.24512784080741,0 -8.461349948243498,33.24700422091534,0 -8.459076744436912,33.24771894930219,0 -8.458836925045349,33.24792349058613,0 -8.458458449921935,33.24815875065841,0 -8.45801394747145,33.2483410290823,0 -8.457165883209761,33.24866839587055,0 -8.455834874870117,33.24928750436097,0 -8.454260395728097,33.25003067494149,0 -8.452794942822914,33.25049947569057,0 -8.451876246951082,33.25094594636418,0 -8.450864926071009,33.25120561049117,0 -8.449844613370718,33.25151053759761,0 -8.449088691329985,33.25170930624088,0 -8.447261708923168,33.2522961315079,0 -8.446077281937136,33.25281187729184,0 -8.444777481400008,33.2534212242123,0 -8.443081173109956,33.25407645270602,0 -8.442028219394613,33.25435549331674,0 -8.440840437565289,33.25479959874206,0 -8.438510847031278,33.25574944690082,0 -8.437758313938245,33.25604771873677,0 -8.436271472308984,33.25684243345258,0 -8.434981152028694,33.25742413933539,0 -8.433966637645332,33.25790011832017,0 -8.432310575880587,33.25845523777926,0 -8.430973431392774,33.25892951412953,0 -8.430514267091992,33.25930180588698,0 -8.429424847685793,33.25979800429118,0 -8.428092356388675,33.26040796817222,0 -8.426585471290457,33.26123854531085,0 -8.425703357386162,33.26181020082902,0 -8.425060075979292,33.26216921061533,0 -8.424334938721025,33.26262850175267,0 -8.423687774908396,33.2628517658319,0 -8.421915527812052,33.26378840157376,0 -8.420534326553579,33.26454417282857,0 -8.419102292946521,33.26538170792243,0 -8.417333679370625,33.26642671665989,0 -8.415509282147534,33.26741025675966,0 -8.414553384394985,33.26803754440567,0 -8.413869952656382,33.26846026521282,0 -8.412444641442237,33.26918971006965,0 -8.411165675691805,33.26978043979072,0 -8.409220059232212,33.27100026299953,0 -8.407586530602558,33.27191557704219,0 -8.40637036917437,33.27246787542785,0 -8.405349117467441,33.27308848006262,0 -8.404651632824178,33.27341183231123,0 -8.403783221607464,33.27408264867028,0 -8.402757585766885,33.27457637861642,0 -8.402125179914092,33.27492612799048,0 -8.401548178604719,33.27532777553495,0 -8.400139577837029,33.27621912133678,0 -8.398937272954747,33.27687066463119,0 -8.39742178736793,33.27810720949157,0 -8.396028902468046,33.27915170519859,0 -8.394825019560404,33.28009197180005,0 -8.39243376284386,33.28179187169808,0 -8.390832640479884,33.28271504743752,0 -8.38980858573237,33.28356970630311,0 -8.388422269284254,33.28481189820848,0 -8.386104440813245,33.28678975491163,0 -8.384313636601791,33.28844774880625,0 -8.383357611266145,33.28908434244578,0 -8.382038903820117,33.28981086142093,0 -8.380958343395262,33.2902517986737,0 -8.379695956095576,33.29105816546316,0 -8.378079651618835,33.29218903229327,0 -8.37610754481865,33.29358982439482,0 -8.375883778599967,33.29396513550255,0 -8.375618539291635,33.29405271474262,0 -8.375303775329655,33.2942855007812,0 -8.375321239976678,33.2947997361958,0 -8.375263197617224,33.29498132347226,0 -8.374916313355874,33.29489065958257,0 -8.374800340831282,33.29528113356218,0 -8.37465989413279,33.29557322162351,0 -8.374489717064627,33.29594724654759,0 -8.374222942161509,33.29598981013213,0 -8.373826576138326,33.29571057502535,0 -8.373617848034227,33.29557155072927,0 -8.373258201986578,33.29575148309352,0 -8.372655390936647,33.29633448587048,0 -8.370689360297433,33.2976080845428,0 -8.370296137202264,33.29806866185303,0 -8.369965754934748,33.29846493958908,0 -8.369398774327923,33.29852354283811,0 -8.368764626330753,33.2988547261797,0 -8.367615195946527,33.29981115800613,0 -8.367118001281172,33.3003465597859,0 -8.36679771790701,33.30041768750272,0 -8.366074239967071,33.30125608581585,0 -8.36481735099111,33.30223348470344,0 -8.364313086323085,33.30256086172618,0 -8.363397685517994,33.30313352818468,0 -8.362580124222099,33.30373934759869,0 -8.361252402787315,33.30483579783695,0 -8.359592645388746,33.30628278858126,0 -8.358309719840849,33.30714333731645,0 -8.357006163705803,33.30799548984008,0 -8.356395649468686,33.30837996650172,0 -8.355580955835475,33.30876042419605,0 -8.354733857586751,33.30945767192295,0 -8.35261199929881,33.31121314801863,0 -8.35122983161858,33.31229303153347,0 -8.350392902737331,33.31298045026666,0 -8.348829726054252,33.31411852563003,0 -8.347098140013959,33.31535067234365,0 -8.344981650079998,33.316645839008,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
        <Placemark>

i want to show the value of this Simple data on infoWindow:

<SimpleData name="COMMUNE">EL-JADIDA (M)</SimpleData>

i tried this code :

google.maps.event.addListener(ctaLayer, 'click', function(kmlEvent) {
    showInContentWindow(kmlEvent.latLng, kmlEvent.featureData.COMMUNE);

     });

it doesn't work,i show the infowindow but the value is undefined after that i see on https://developers.google.com/kml/documentation/kmlelementsinmaps

that the SimpleData is not supported on googleMaps

i tried to add this code after each closing tag ExtendedData :

<description>Commune</description>

but it doesn't work

Does anyone know a better solution to displaye feature data from kml file on infoWindow ?

0

There are 0 answers