Why is my KML not loading?

81 views
Skip to first unread message

Niklas Rosencrantz

unread,
Nov 10, 2011, 2:25:08 AM11/10/11
to google-map...@googlegroups.com
Hello
My KML is not loading and I can't understand why. I debugged with firebug and there was no error.
The address to the KML file is here
Could you tell me what's wrong? This is the python that generates the KML:

    def get(self):
        self.response.headers['Cache-Control'] = 'public,max-age=%s' \
            % 86400
        start = datetime.datetime.now() - timedelta(days=60)
        from google.appengine.api import memcache
        memcache_key = 'ads'
        data = memcache.get(memcache_key)
        if data is None:
            a = Ad.all().filter('modified >', start).filter('url IN',
                    ['www.koolbusiness.com']).filter('published =',
                    True).order('-modified').fetch(1000)
            memcache.set('ads', a)
        else:
            a = data
        dispatch = 'templates/kml.html'
        template_values = {'a': a, 'request': self.request,
                           'host': os.environ.get('HTTP_HOST',
                           os.environ['SERVER_NAME'])}
        path = os.path.join(os.path.dirname(__file__), dispatch)
        output = template.render(path, template_values)
        self.response.headers['Content-Type'] = \
            'application/vnd.google-earth.kml+xml'
        self.response.headers['Content-Length'] = len(output)
        self.response.out.write(output)

Thank you for any help

/Niklas

Pil

unread,
Nov 10, 2011, 3:00:37 AM11/10/11
to Google Maps JavaScript API v3


On Nov 10, 8:25 am, Niklas Rosencrantz <nikla...@gmail.com> wrote:

> The address to the KML file is here <http://www.koolbusiness.com/list.kml>

Have you tried to call this file in your browser?

I get a file with valid headers. Apart from that the rest of the file
is empty.

Niklas Rosencrantz

unread,
Nov 10, 2011, 3:20:27 AM11/10/11
to google-map...@googlegroups.com
Thank you for the prompt resonse. I see the file validates via validation and if I save the file I get KML:

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document><Placemark><name></name><description><![CDATA[<img src="http://lh5.ggpht.com/uGkZDiofn7J1qMTcnhNG--T7NmYddDrEiEYcLwRvXCvIy_dVoIZa5gLh4j8ENegMGGmo0FKr3BapYqTK....

What has happened?


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Rossko

unread,
Nov 10, 2011, 3:24:19 AM11/10/11
to Google Maps JavaScript API v3
> What has happened?

Perhaps its a security thing at your server, are you logged in or
something?
I too see a a valid KML file with no placemarks at http://www.koolbusiness.com/list.kml

Pil

unread,
Nov 10, 2011, 5:24:17 AM11/10/11
to Google Maps JavaScript API v3
The kml file is now loading correctly - although nothing is visible.
It seems the kml file doesn't contain any defined icons.

http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%2Fwww.koolbusiness.com%2Flist.kml

Niklas Rosencrantz

unread,
Nov 10, 2011, 5:50:52 AM11/10/11
to google-map...@googlegroups.com
ah...Thank you so much for letting me know that I must add icons. And how come the KML validates and how could I add icons to the template most basically? This is my django template

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document>{% for ad in a %}{% if ad.geopt %}<Placemark><name></name><description><![CDATA[{% if ad.uri2view %}<img src="{{ ad.uri2view }}">{% endif %}<a href="http://{{host}}/vi/{{ad.key.id}}"> {{ ad.title }} </a><br/>{{ad.text|truncatewords:20}}]]></description><Point><coordinates>{{ad.geopt.lon|floatformat:2}},{{ad.geopt.lat|floatformat:2}}</coordinates></Point></Placemark>{% endif %}{% endfor %}</Document></kml>



Pil

unread,
Nov 10, 2011, 5:58:23 AM11/10/11
to Google Maps JavaScript API v3
Don't know how to code that in Python.

You have to add something like this to the kml


<Style id="blue">
<IconStyle>
<Icon>
<href>http://maps.gstatic.com/mapfiles/ms/icons/blue-dot.png</href>
</Icon>
</IconStyle>
</Style>


http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=https:%2F%2Fsites.google.com%2Fsite%2Fxxamples%2Flist.kml



On Nov 10, 11:50 am, Niklas Rosencrantz <nikla...@gmail.com> wrote:
> ah...Thank you so much for letting me know that I must add icons. And how
> come the KML validates and how could I add icons to the template most
> basically? This is my django template
>
> <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"
> xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document>{% for ad in a %}{% if ad.geopt
> %}<Placemark><name></name><description><![CDATA[{% if ad.uri2view %}<img
> src="{{ ad.uri2view }}">{% endif %}<a href="http://{{host}}/vi/{{ad.key.id}}">
> {{ ad.title }}
> </a><br/>{{ad.text|truncatewords:20}}]]></description><Point><coordinates>{{ad.geopt.lon|floatformat:2}},{{ad.geopt.lat|floatformat:2}}</coordinates></Point></Placemark>{%
> endif %}{% endfor %}</Document></kml>
>
> On Thu, Nov 10, 2011 at 10:24 AM, Pil <wolf...@gmail.com> wrote:
> > The kml file is now loading correctly - although nothing is visible.
> > It seems the kml file doesn't contain any defined icons.
>
> >http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%...

Niklas Rosencrantz

unread,
Nov 10, 2011, 6:06:57 AM11/10/11
to google-map...@googlegroups.com
Thanks for the help. Now it looks like the icons are included with the code and it still won't load on the map:

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document><Placemark><name></name><Style id="blue">

<IconStyle>
<Icon>
<href>http://maps.gstatic.com/mapfiles/ms/icons/blue-dot.png</href>
</Icon>
</IconStyle>
</Style><description><![CDATA[<img src="http://lh5.ggpht.com/uGkZDiofn7J1qMTcnhNG--T7NmYddDrEiEYcLwRvXCvIy_dVoIZa5gLh4j8ENegMGGmo0FKr3BapYqTKCY

It validates:

Congratulations!

[Valid KML 2.2] This is a valid KML 2.2 feed.

Pil

unread,
Nov 10, 2011, 8:41:27 AM11/10/11
to Google Maps JavaScript API v3
Now you have the same reference with the same id to one and the same
icon many times. An id - as in HTML - should always be unique,
otherwise its invalid.

If there is a style definition like

<Style id="blue">
<IconStyle>
<Icon>
<href>http://whatever.com/bluedoth.png</href>
</Icon>
</IconStyle>
</Style>


you can refer to this style like


<Placemark>
<name>Whatever</name>
<description><![CDATA[
Whatever]]></description>

<styleUrl>#blue</styleUrl>
<Point>
<coordinates>-121.434599,37.740223</coordinates>
</Point>
</Placemark>

Niklas Rosencrantz

unread,
Nov 10, 2011, 10:06:52 AM11/10/11
to google-map...@googlegroups.com
Thank you for the help. THing is it used to work without the icon tags so I suspect it's something else. And I added the icon part and it still won't work:

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document><Placemark><name></name><Style id="blue">
<IconStyle>
<Icon>
</Style><description><![CDATA[<img src="http://lh5.ggpht.com/uGkZDiofn7J1qMTcnhNG--T7NmYddDrEiEYcLwRvXCvIy_dVoIZa5gLh4j8ENegMGGmo0FKr3BapYqTKCYUWgotyOQ=s100"><a href="http://www.koolbusiness.com/vi/4394184"> Samsung NP-N310 </a><br/>Samsung NP-N310 is a 15.6 inch laptop comes with attractive price and outstanding features. Samsung NP-N310 featuring with Intel Atom ...]]></description><styleUrl>#blue</styleUrl><Point><coordinates>77.58,12.98</coordinates></Point></Placemark><Placemark><name></name><Style id="blue">
<IconStyle>
<Icon>
</Style><description><![CDATA[<img src="http://lh4.ggpht.com/fG6X2fXec7a98S-R6QDufwAfYtPOI_BTSwY-6QJQCrUGndeTmQk3TTaPC7kF_Y9gADjo3cD6uGcCj2sAb70PQ1JmdQI=s100"><a href="http://www.koolbusiness.com/vi/4395183"> Part Time Job or Data Entry Job or Work At Home </a><br/>Take the Franchisee of Amit Info Service at free of cost &amp; easily earn Rs.40000+ Per Month &amp; get Hero ...]]></description><styleUrl>#blue</styleUrl><Point><coordinates>77.22,28.67</coordinates></Point></Placemark>

geoco...@gmail.com

unread,
Nov 10, 2011, 10:19:49 AM11/10/11
to Google Maps JavaScript API v3
On Nov 10, 7:06 am, Niklas Rosencrantz <nikla...@gmail.com> wrote:
> Thank you for the help. THing is it used to work without the icon tags so I
> suspect it's something else.

Maybe google changed their kml parser.

It does seem to work now with google maps:

http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%2Fwww.koolbusiness.com%2Flist.kml

And in the api with both geoxml3 and KmlLayer:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/xmlproxy060215.asp?http:%2F%2Fwww.koolbusiness.com%2Flist.kml

Perhaps you should investigate the javascript errors on your page:
=============================================================
Error: syntax error
Source File: http://www.koolbusiness.com/static/js/home.js
Line: 231
Source Code:
)
=============================================================
Error: initialize is not defined
Source File: http://www.koolbusiness.com/
Line: 1
=============================================================

-- Larry

> And I added the icon part and it still won't
> work:
>
> <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"
> xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document><Placemark><name></name><Style
> id="blue">
> <IconStyle>
> <Icon>
> <href>http://maps.gstatic.com/mapfiles/ms/icons/blue-dot.png</href>
> </Icon>
> </IconStyle>
> </Style><description><![CDATA[<img src="http://lh5.ggpht.com/uGkZDiofn7J1qMTcnhNG--T7NmYddDrEiEYcLwRvXCvIy_dV..."><a
> href="http://www.koolbusiness.com/vi/4394184"> Samsung NP-N310
> </a><br/>Samsung NP-N310 is a 15.6 inch laptop comes with attractive price
> and outstanding features. Samsung NP-N310 featuring with Intel Atom
> ...]]></description><styleUrl>#blue</styleUrl><Point><coordinates>77.58,12.98</coordinates></Point></Placemark><Placemark><name></name><Style
> id="blue">
> <IconStyle>
> <Icon>
> <href>http://maps.gstatic.com/mapfiles/ms/icons/blue-dot.png</href>
> </Icon>
> </IconStyle>
> </Style><description><![CDATA[<img src="http://lh4.ggpht.com/fG6X2fXec7a98S-R6QDufwAfYtPOI_BTSwY-6QJQCrUGndeT..."><a
Message has been deleted

Niklas Rosencrantz

unread,
Nov 10, 2011, 4:58:19 PM11/10/11
to google-map...@googlegroups.com
Thanks for all the help. I ran my KML as a file through the Galdos KML validator and it appears I'm doing it wrong serverside after all:
  • Line 7
    cvc-id.2: There are multiple occurrences of ID value 'blue'.
  • Line 7
    cvc-attribute.3: The value 'blue' of attribute 'id' on element 'Style' is not valid with respect to its type, 'ID'.
  • Line 13
So I'll use the above info to continue the bugtracking. What's peculiar is that my KML looks like it's loading on my other map served by the same app engine app.
Please let me know if you can add or comment to how I should resolve my problem here.
Regards,
Niklas
list.kml

Rossko

unread,
Nov 10, 2011, 6:00:41 PM11/10/11
to Google Maps JavaScript API v3
> There are multiple occurrences of ID value 'blue'.

That's what Pil told you. Have you seen
http://code.google.com/apis/kml/documentation/kml_tut.html

> Please let me know if you can add or comment to how I should resolve my
> problem here.

While you are making changes to your generated KML, you should be
aware that KmlLayer caches your KML at Google for some hours. What
gets rendered on your map does not necessarily reflect what is
currently in your KML ; to put it another way, don't expect changes or
corrections to show up immediately on your map.
Message has been deleted

Niklas Rosencrantz

unread,
Nov 11, 2011, 4:17:11 AM11/11/11
to google-map...@googlegroups.com
I think I can consider the issue resolved.
My map: http://www.koolbusiness.com/
My KML http://www.koolbusiness.com/list.kml

My other map: http://www.montao.com.br
My other KML: http://www.montao.com.br/montaolist.kml

And I just checked and both look like they render markers so now I'm very happy that I don't have to troubleshoot.

Please tell me if you think I need to know more.

Thanks for all the prompt and great help!
Niklas
brazil.png
india.png
infowindow.png
kool.png
Reply all
Reply to author
Forward
0 new messages