1

For some reason, I can't get GeoXML3 to parse my KML file at all. My ultimate goal is to use the GeoXML3 parser to allow me to import polygon overlays via a KML file, then change the fill property of those polygons on a click event (to symbolize selecting/deselecting). Here is my current HTML file's code:

<script type="text/javascript">
var myStyle = [
   {
     featureType: "poi",
     elementType: "labels",
     stylers: [
       { visibility: "off" }
     ]
   },{
     featureType: "water",
     elementType: "labels",
     stylers: [
       { visibility: "off" }
     ]
   },{
     featureType: "road",
     stylers: [
       { visibility: "off" }
     ]
   }
 ];

function initialize() {
    var mapOptions = {
        center: new google.maps.LatLng(32.565333,-83.311043),
        mapTypeControlOptions: {
            mapTypeIds: ['mystyle', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.TERRAIN]
            },
        scrollwheel: false,
        navigationControl: false,
        mapTypeControl: false,
        scaleControl: false,
        disableDoubleClickZoom: true,
        streetViewControl: false,
        draggable: false,
        zoom: 7,
        mapTypeId: 'mystyle'
    }

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    map.mapTypes.set('mystyle', new google.maps.StyledMapType(myStyle, { name: 'My Style' }));
    var myParser = new geoXML3.parser({map: map});
    myParser.parse('tristate_area.xml');
    /*
    var ctaLayer = new google.maps.KmlLayer('tristate_area.kml',{
        suppressInfoWindows: true
    });
    google.maps.event.addListener( ctaLayer, "click", function( kmlEvent ) {
        $.ajax({
            ... my AJAX call ...
        });
    });
    ctaLayer.setMap(map);
    */
}

</script>

If you un-comment the block that is commented out and remove the GeoXML3 stuff, the overlay appears as it should. But I need to use GeoXML3 to parse my KML data because I need to change the properties of individual polygons on click events.

Below are SOME OF the contents to tristate_area.kml (I omitted the other two states to save space):

<!-- Georgia -->
<Style id="georgia_style">
    <LineStyle>
        <color>41F06414</color>
        <width>4</width>
    </LineStyle>
    <PolyStyle>
        <color>41F06414</color>
    </PolyStyle>
</Style>
<Placemark id="pm294">
    <name>Georgia</name>
    <Snippet maxLines="0">empty</Snippet>
    <description>Georgia outline</description>
    <styleUrl>#georgia_style</styleUrl>
    <MultiGeometry>
        <MultiGeometry>
            <Polygon id="g990">
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            -85.1301648712312,31.778853672117,0 -85.11528693111811,31.731565957183,0 -85.11867442354141,31.7085715963854,0 -85.1112049587349,31.6842421102739,0 -85.0592853056629,31.6212651525335,0 -85.04272135787051,31.5543898029988,0 -85.04269843494509,31.5196599288858,0 -85.0663120282063,31.4760895555663,0 -85.0614062661802,31.4406634414676,0 -85.0879419916334,31.3672341961667,0 -85.08256319000949,31.33233449639,0 -85.0812280506442,31.3030803697052,0 -85.10336136850169,31.2714361848353,0 -85.09360326113141,31.2270745000222,0 -85.1029571297253,31.1969220462589,0 -85.0933668734253,31.1722112527352,0 -85.06866250314511,31.1623640897378,0 -85.038068227176,31.1267131739262,0 -85.01699565076569,31.0801028338282,0 -85.0016071976334,31.0012534003007,0 -85.0001419997276,30.9793194525836,0 -84.97356770002369,30.9636643794248,0 -84.9690122705718,30.9270937759378,0 -84.9377761495732,30.8949576392884,0 -84.9269262387193,30.8469221763844,0 -84.93256395069341,30.802625045985,0 -84.9268948431928,30.7760887042882,0 -84.915343413445,30.7540898084089,0 -84.8882887897453,30.7438893824889,0 -84.86458306959619,30.7145032030319,0 -84.8630037111776,30.7126645389724,0 -84.3744481609224,30.6940918759687,0 -84.2816633081929,30.6904191353307,0 -84.07556221707689,30.6785776000623,0 -84.00073015189621,30.6755376606981,0 -83.7378439398488,30.6604911909877,0 -83.6090560569222,30.6507845923385,0 -83.31060073866981,30.6343032375269,0 -83.30131548232799,30.6332849379512,0 -83.13244038033891,30.62134139874239,0 -82.6963559598951,30.5957200992445,0 -82.5829575782702,30.5890537915584,0 -82.46313488325031,30.5826898377285,0 -82.4120926709198,30.5773075208331,0 -82.2210395703097,30.5670760290347,0 -82.2383961480861,30.53144474306101,0 -82.2193674835883,30.5029705380916,0 -82.1991871719511,30.4900145014502,0 -82.2055648250395,30.4238531552503,0 -82.1802341078135,30.3686309203557,0 -82.1646391875519,30.3612918341259,0 -82.0527668135565,30.3637944548298,0 -82.0383547553639,30.3789045785554,0 -82.04609949457389,30.4340681576703,0 -82.0351206760364,30.442878325233,0 -82.0225094921996,30.4777178378262,0 -82.00580162815341,30.5709905104499,0 -82.0136526868731,30.5986905381626,0 -82.044911618847,30.6509107642683,0 -82.0318811960902,30.75753276526,0 -82.0129673359901,30.7642564144355,0 -82.015538717102,30.7913192479577,0 -81.9814798819521,30.7783517328393,0 -81.96155137217021,30.7960077712109,0 -81.95302920945851,30.8204309615747,0 -81.9438049950591,30.8242494271993,0 -81.9075183587545,30.8134750654558,0 -81.899141093328,30.8283082947867,0 -81.87300178764769,30.7990844044587,0 -81.80319816057199,30.7880849801985,0 -81.77670793959879,30.7615846557533,0 -81.7577101754202,30.7696316702207,0 -81.7366750235978,30.7638888413088,0 -81.7167688183456,30.7453688965497,0 -81.64247751744411,30.7290809870991,0 -81.6279809976449,30.7317742622409,0 -81.6047710156425,30.7163212810582,0 -81.6011698908184,30.7248871300769,0 -81.5365912711366,30.706577299159,0 -81.52859548779161,30.7214526527694,0 -81.49838215972861,30.7575148369311,0 -81.529269052571,30.8647786931871,0 -81.4848273848571,30.9449000982573,0 -81.5285609645024,30.9621190260309,0 -81.4908554850397,30.9858121631104,0 -81.5354294328489,31.07675630369249,0 -81.4753376980902,31.0438233173066,0 -81.52525924876009,31.0865485378616,0 -81.52838810570471,31.1311281139373,0 -81.3810060604754,31.1489458440312,0 -81.31024963168881,31.2426949085912,0 -81.30083493289349,31.2758189009071,0 -81.3888131895834,31.2971490597463,0 -81.3947715908228,31.2640900090948,0 -81.4103443748257,31.3114801993601,0 -81.3655812868468,31.3445548526356,0 -81.3130659410716,31.3375975453654,0 -81.2085717415423,31.466897315876,0 -81.1947704996618,31.5051521393949,0 -81.23914509534541,31.5568831089359,0 -81.2407192840183,31.6401735904022,0 -81.1871897446126,31.5998982648136,0 -81.1349370156985,31.64607010904041,0 -81.2897291147454,31.799665157239,0 -81.1751775864286,31.7358025222833,0 -81.19636638291649,31.7848438785274,0 -81.1740127367476,31.7998108690079,0 -81.13682407277911,31.7270738398996,0 -81.06104273006601,31.7775429698153,0 -81.0390109744209,31.8233600040029,0 -81.1414678053095,31.8535166905114,0 -81.1802499193908,31.89767267427,0 -81.2201057693034,31.8931398643438,0 -81.20648835595649,31.9206507082445,0 -81.244947183707,31.8946916725745,0 -81.28429436407509,31.9494280109591,0 -81.23968322486699,31.9034156747495,0 -81.2039099248023,31.9284324409696,0 -81.19730252637351,31.9198956907679,0 -81.20725811895009,31.900120837565,0 -81.1799984795161,31.9058911046943,0 -81.13985081872011,31.8643404881217,0 -80.97087558424499,31.8903139501193,0 -80.9735561398863,31.9479287150516,0 -80.8947535795152,32.0059939238177,0 -81.10487575967311,32.1054460026813,0 -81.11911230742351,32.1176140300944,0 -81.1147177986615,32.1905932444351,0 -81.14769255179129,32.2244467846609,0 -81.14817311099929,32.2577131389355,0 -81.1240481751459,32.2766445515914,0 -81.131890044888,32.3326183284591,0 -81.1418842567213,32.348467456337,0 -81.15747907871371,32.3387404019195,0 -81.1791229158612,32.3717812943982,0 -81.17825274918771,32.3868294350367,0 -81.19992690502011,32.4203165559094,0 -81.19515724784431,32.4645607584348,0 -81.23623978837119,32.520613973536,0 -81.26798547886391,32.5339298482675,0 -81.2743023822226,32.5548140176008,0 -81.298983534041,32.567287009571,0 -81.3404038613665,32.5713602924434,0 -81.3514893657912,32.5835283490035,0 -81.36670254638879,32.5819794584472,0 -81.3662676134818,32.5883649179497,0 -81.3849063649096,32.5958830263814,0 -81.41210528286091,32.6256090136088,0 -81.3994783141749,32.6508153349079,0 -81.4071915250438,32.6867019963945,0 -81.4205354721022,32.7015669413645,0 -81.4076260787666,32.7418061601564,0 -81.4230377099309,32.7498126483616,0 -81.41607199831719,32.7567284399427,0 -81.4302403174263,32.7861535714108,0 -81.4208333313248,32.8094947304519,0 -81.4303092863297,32.8203050210012,0 -81.4239616394502,32.831771535068,0 -81.4323312938326,32.8416816085137,0 -81.4553190013329,32.8445766582975,0 -81.4585388413489,32.8714003875851,0 -81.4832049987009,32.876092075685,0 -81.4650317117614,32.8977282069894,0 -81.47704813306041,32.8975717263241,0 -81.5102366685686,32.9472214740899,0 -81.509839970123,32.9554188973732,0 -81.4978997781492,32.9596759183359,0 -81.4927348468244,33.0048133137248,0 -81.50874915476361,33.0127933490709,0 -81.5296007135576,33.0439278437875,0 -81.5476598503141,33.0436837254085,0 -81.56003498198071,33.0608149350319,0 -81.59582519226061,33.07079003117,0 -81.610962223749,33.087875452303,0 -81.7042792512713,33.1229388681766,0 -81.740374666284,33.1446970762157,0 -81.76340826403511,33.1698348857377,0 -81.7595935205582,33.1953809754874,0 -81.7698781322982,33.2138814847346,0 -81.7798346609471,33.2173679140961,0 -81.8015635396811,33.2079267401357,0 -81.8107647427681,33.2264425091539,0 -81.85396307448509,33.2435008646337,0 -81.83679654832591,33.2606131041944,0 -81.8398406003094,33.2733079499958,0 -81.826572899138,33.2694248257545,0 -81.86071475702811,33.2970915898305,0 -81.8401072844714,33.3083447178855,0 -81.86554408069119,33.3156684726899,0 -81.87687401673379,33.3068376679828,0 -81.893483278419,33.3352369460829,0 -81.9120917492517,33.3321965848843,0 -81.9114125905005,33.3494956248163,0 -81.9367121514194,33.3504376050416,0 -81.9450663328463,33.3771470802287,0 -81.9258093500634,33.3765598081382,0 -81.9403358095376,33.408163308089,0 -81.91356363208369,33.4154417359506,0 -81.9272738095671,33.4361432282633,0 -81.9166380824955,33.451332910189,0 -81.93638328061149,33.4710196640405,0 -81.9809170141647,33.4907366765445,0 -81.9965347107135,33.5204905181363,0 -82.02014061005811,33.5387321304637,0 -82.0385431417392,33.5475058176817,0 -82.0656815446151,33.5738649217255,0 -82.1164029880357,33.5947766297079,0 -82.13897891040349,33.5939068648655,0 -82.1671320836866,33.6152152043502,0 -82.1921876394497,33.6238399454958,0 -82.21420671543,33.6807345454544,0 -82.2348981721706,33.6903395482787,0 -82.2662179171499,33.7615957491367,0 -82.3055105866775,33.7826480434626,0 -82.3111185523946,33.8039143524229,0 -82.3513115818956,33.8353919365428,0 -82.3657086388162,33.8360097346945,0 -82.390596547794,33.8541402272832,0 -82.424525414299,33.8602546364245,0 -82.4566308989782,33.8782248379062,0 -82.51753847434971,33.931029734258,0 -82.576614784124,33.9592878315125,0 -82.5736087006275,33.9689044112754,0 -82.5961385808407,34.0134202383713,0 -82.6029437979289,34.0346366848087,0 -82.66035530356881,34.1083560439036,0 -82.73578078298991,34.1697961502507,0 -82.7425935601244,34.2055536194311,0 -82.7580279876581,34.2333729594522,0 -82.76416996771751,34.2809601537556,0 -82.78287043804779,34.2905157146731,0 -82.80858305350149,34.3398998890232,0 -82.8364394858077,34.3710462423795,0 -82.844092601526,34.4126753526629,0 -82.8680428963264,34.4575429723072,0 -82.9050550411483,34.4779853553029,0 -82.98196281154389,34.4764970914664,0 -83.0079495911058,34.4708283883787,0 -83.0549948395099,34.4900615932447,0 -83.0790212167266,34.5189724434825,0 -83.1081211059023,34.5350165151609,0 -83.13736602628759,34.5678676740658,0 -83.1589505272632,34.5768318282397,0 -83.1648789222652,34.5989373632901,0 -83.23698727342099,34.6133215989917,0 -83.29889480454101,34.6629454181783,0 -83.3397900149061,34.6776926363039,0 -83.3506851506329,34.7096474786312,0 -83.3503341394554,34.72738151575,0 -83.3234241306547,34.752233551772,0 -83.32269057154549,34.787244331982,0 -83.3027537558249,34.8055316318054,0 -83.2701139291264,34.8150795057964,0 -83.26777101073991,34.8392299311095,0 -83.25042127245131,34.8397104674801,0 -83.25030657832789,34.8501663657462,0 -83.23568791389251,34.8623846921569,0 -83.243073026274,34.8780818464701,0 -83.2328036461865,34.8738209511595,0 -83.21942855420581,34.8891824860544,0 -83.203513267742,34.8841701297206,0 -83.1821802554349,34.9106474165588,0 -83.1583528037159,34.9176510672928,0 -83.1550259840766,34.9322800740411,0 -83.13756183146759,34.9304757693624,0 -83.1256365359246,34.940790436291,0 -83.1131011728063,34.9361251832685,0 -83.1273147785663,34.9543742120639,0 -83.12140170134001,34.9608933437966,0 -83.1155422841629,34.9546869901268,0 -83.1004503495987,34.9841622888642,0 -83.1061569738507,35.000366708131,0 -83.5128876420542,34.9921157535224,0 -83.5492972918908,34.9896284845873,0 -83.93789913149431,34.9894775119032,0 -83.9884542500545,34.9891518047362,0 -84.11815239780699,34.9883069959845,0 -84.3237734916339,34.989090556154,0 -84.6186847093286,34.9887597674461,0 -84.7711343281899,34.9907572255424,0 -84.8004169251833,34.9928322796908,0 -84.96785715657791,34.9926829480827,0 -84.97279353781779,34.9926295267483,0 -85.2677172911793,34.9891498087636,0 -85.3599438878245,34.9899781417047,0 -85.4673839007084,34.9901237462044,0 -85.60896021625049,34.9901641616199,0 -85.5830580356282,34.8623226551191,0 -85.5346925955902,34.6224884025546,0 -85.52583413117669,34.5846856151065,0 -85.5118559301513,34.5230148510197,0 -85.46028592417321,34.2901615301398,0 -85.4165672299404,34.0869203579979,0 -85.3957377905852,33.9598292697156,0 -85.3840109358491,33.9054097874599,0 -85.33528685109771,33.6549230949434,0 -85.3049800767665,33.4905940310641,0 -85.2938249844532,33.425875708363,0 -85.2338462673976,33.129237260647,0 -85.2335028922441,33.1201394011529,0 -85.1807197284529,32.8718130182966,0 -85.1623013377526,32.8074457725548,0 -85.1280898176054,32.7770703815279,0 -85.1333007048373,32.7563151798039,0 -85.1248851250497,32.7443832224212,0 -85.11386785194109,32.7343891188468,0 -85.10773330416841,32.6899723746491,0 -85.0904749305908,32.6761523261383,0 -85.10380371878141,32.6459103823229,0 -85.0863240406897,32.6284512647951,0 -85.0841493949267,32.603004344931,0 -85.0707744216369,32.5812538387594,0 -84.9956522169706,32.518928479096,0 -84.9898150430422,32.4548361836926,0 -84.96538505189019,32.4294501858587,0 -84.970961884914,32.3968128124947,0 -84.9844889642181,32.3870933241337,0 -84.97166353138461,32.3715031963467,0 -85.0020899980221,32.3470785227396,0 -85.0053324510846,32.3295925258289,0 -84.92107090555641,32.2931369847317,0 -84.8946035025639,32.2687353881118,0 -84.8940158788823,32.2591761298648,0 -84.9053609608961,32.2495557759674,0 -84.92367962799079,32.2473889995768,0 -84.9160041260552,32.2285563686775,0 -84.9283716437355,32.2179784387895,0 -84.9757438025875,32.2122487204353,0 -84.9603852752889,32.1919284376309,0 -85.0078260926386,32.1788785384061,0 -85.0243823514691,32.1662750781008,0 -85.0533136579289,32.1266376448382,0 -85.046187259254,32.0908949913561,0 -85.0566549357244,32.0696439454843,0 -85.06201076173519,32.0500102920991,0 -85.0567002477577,32.0173765203509,0 -85.0700671081992,31.9807030736301,0 -85.11515025581549,31.9074247500776,0 -85.1355669344631,31.8548844137198,0 -85.1315611123421,31.7838145657199,0 -85.1301648712312,31.778853672117,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
            <Polygon id="g991">
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            -81.48505559674619,30.9038830704629,0 -81.50330537724329,30.8817350483411,0 -81.4698871419111,30.8602588644255,0 -81.4794603415988,30.7368833934474,0 -81.45571660482371,30.7164274298842,0 -81.4030527080982,30.9388031406114,0 -81.416405104746,30.970600047506,0 -81.48505559674619,30.9038830704629,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </MultiGeometry>
    </MultiGeometry>
</Placemark>

Why is this not rendering?

Nate Kibler
  • 652
  • 3
  • 14
  • Do you have tristate_area.kml available at a public URL or somewhere I can download it? Where/how are you including geoxml3.js? Which version of geoxml3.js are you using the polys branch or the kmz branch (the trunk is old and doesn't support polygons)? – geocodezip Jun 13 '13 at 14:39
  • Sure, I uploaded it to a public Dropbox URL here: https://dl.dropboxusercontent.com/u/124860071/tristate_area.kml Edit: Here is my geoxml3.js descriptor: `` – Nate Kibler Jun 13 '13 at 14:41
  • Your original snippet works for me: http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_tristatearea.kml – geocodezip Jun 13 '13 at 14:45
  • Hmm, does the HTML file need to be up on a server somewhere? I've just been previewing it as a file on `localhost` before I upload it to my server. – Nate Kibler Jun 13 '13 at 14:48
  • Your html does not need to be on a live server to work, but different browsers deal differently with loading local files using XmlHttpRequest (which geoxml3 uses), so it may depend on what browser you are using (what browser are you using?). Your full file also works for me: http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_tristate_area_full.kml – geocodezip Jun 13 '13 at 14:55
  • I'm using Chrome 27.0. Your examples have worked for me as well; I'm curious as to why it will not work for me. I just see the map with no overlays. Is there any other information I could provide or any further troubleshooting steps I could take that you know of? – Nate Kibler Jun 13 '13 at 15:00
  • Wait a second, Firefox displays it fine. Is Chrome the issue? – Nate Kibler Jun 13 '13 at 15:05

1 Answers1

0

Chrome is giving me these errors:

 XMLHttpRequest cannot load file:<path on the computer>/tristate_area.xml. Cross origin requests are only supported for HTTP. v3_geoxml3_SO_simpleMap_tristate.html:1
 Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 

I think you can configure Chrome to allow this, don't know how offhand.

geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • Luckily, this won't be run on my machine; it's hosted on a server. I was just using mine to test and didn't realize Chrome was throwing a fit about loading a local file! Thanks for your help! – Nate Kibler Jun 13 '13 at 15:17