Google Earth and Google Maps KML Mismatch

437 Views Asked by At

I am working on KML. I have generated the following KML which works fine for the Google Earth but not working fine for Google Maps.

The problem is that all icons are not getting displayed. All icons that are inputted in URL are of 32x32.

http://theinternallight.com/KML/GetAllCountryScalars%20(47).kml

Can anybody please tell me what I am doing wrong.

Thanks in Advance

1

There are 1 best solutions below

2
On

When KML is not displaying correctly the first thing to check is if the KML conforms to the standard. The order of elements in KML has a strict ordering and Style element, for example, must precede the Point geometry so the KML is not valid. The correct structure of the KML Placemark with element ordering can be found here.

Here is an example found in the original KML with incorrect ordering:

<Placemark>
    <Point>
        <coordinates>180,-5,0</coordinates>
    </Point>
    <Style id="-5180.png">
        <IconStyle>
            <Icon>
                <href>http://theinternallight.com/KML/IconLatLong/-5180.png</href>
            </Icon>
        </IconStyle>
    </Style>
</Placemark>

Also from a strict XML perspective the "id" attributes must be a valid NCNAME data type which starts with an alphanumeric character not "-", but to simplify you can just remove the "id" attribute from the inline Styles within the Placemark -- these are not needed.

You can rather rewrite this as following:

<Placemark>
    <Style>
        <IconStyle>
            <Icon>
                <href>http://theinternallight.com/KML/IconLatLong/-5180.png</href>
            </Icon>
        </IconStyle>
    </Style>
    <Point>
        <coordinates>180,-5,0</coordinates>
    </Point>
</Placemark>

You should make changes then validate the KML using Galdos KML Validator. If you want a standalone command-line KML validator then you can use the XML Validate tool.