Question

I have been trying to render my KML service in the google maps by the following.

var ctaLayer = new google.maps.KmlLayer({
   url: 'http://DomainName/GeoSystem/redrawKML'
});
ctaLayer.setMap(map);

But I am getting undefined as a result with ctaLayer object when i have checked the status.

But the same service is working good, If i have tried to parse the KML service with geoXML parser. Now, I am confused and having no idea . Why I can not render my KML Service with the google maps KML Layer in google maps.

Any help is much appreciated.

My Woring code with GeoXML library follows.

var geoXml = new geoXML3.parser({
    map : map,
    singleInfoWindow : true
});
geoXml.parse('http://DomainName/GeoSystem/redrawKML');

The following is My KML Content which will be produced by my rest service ( http://DomainName/GeoSystem/redrawKML)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
    <name>My KML Document</name>
    <Placemark>
        <name>Fort Worth</name>
        <open>1</open>
        <description>Fort Worth , Dallas</description>
        <ExtendedData>
            <Data name="GeoRegionId">
                <value>1</value>
            </Data>
            <Data name="PolygonId">
                <value>132</value>
            </Data>
        </ExtendedData>
        <Polygon>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>-97.47551,32.778615 -97.45079,32.79651 -97.437744,32.798242 -97.420578,32.806322 -97.417145,32.813824 -97.34848,32.843251 -97.338867,32.842674 -97.317581,32.838635 -97.292862,32.838058 -97.264709,32.839212 -97.229691,32.840943 -97.207718,32.831135 -97.206345,32.814978 -97.211838,32.802859 -97.212524,32.758985 -97.224884,32.739927 -97.225571,32.716822 -97.240677,32.691977 -97.239304,32.667125 -97.245483,32.661922 -97.281876,32.6625 -97.304535,32.668859 -97.334061,32.663656 -97.380066,32.671749 -97.402725,32.684464 -97.459717,32.683308 -97.47139,32.695444 -97.478943,32.720288 -97.482376,32.741082 -97.47551,32.778615
                    </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>
</Document>
</kml>
Was it helpful?

Solution

Got the answer.

If KMLLayer of google maps API3 has to display contents, The KML File should be in PUBLICALLY ACCESIBLE. Then only the google server can parse the file and will render it in the google maps.

Since I am developing in my local environment. Google Server can not parse the KML File which i am providing. That is why the contents are not rendered in the Google maps.

OTHER TIPS

Have you checked the KML limits of Google Maps API v3 ? If you surpass the limit on feature quantity or file weight, then nothing will be displayed.

Edit: I uploaded your kml to my public dropbox folder. And I'm loading it fine with

var fortw = new google.maps.KmlLayer({    
    url: 'https://dl.dropboxusercontent.com/u/3133731/fortworth.kml',  
    map: map  
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top