Hi
I generate KML with python via datastore as follows

        from django.template import defaultfilters
        start=datetime.datetime.now()-timedelta(days=150)#vary,get or store
        url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST')
else os.environ['SERVER_NAME']
        a= Ad.all().filter("modified >", start).filter("published =",
True).order("-modified").fetch(20)
        self.response.out.write('<?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:
                if ad.matched_images.get():
                    imageid=ad.matched_images.get().key().id()
                    kml =
('<Placemark><name></name><description><![CDATA[<img
src="http://%s/images/%d.%s";> %s
]]></description><Style><IconStyle><Icon><href>http://www.google.com/intl/en_us/mapfiles/ms/icons/green-dot.png</href></Icon></IconStyle></Style><Point><coordinates>%d,%d</coordinates></Point></Placemark>'
           ) 
%(url,ad.matched_images.get().key().id(),ad.matched_images.get().full_ext,'<a
href="http://'+url+'/'+str(ad.key().id())+'">'+ad.title+'</a><br/>'+defaultfilters.urlize(
 defaultfilters.truncatewords(  ad.text , 20 )
),ad.geopt.lon,ad.geopt.lat)
                else:
                    kml =
('<Placemark><name></name><description><![CDATA[%s]]></description><Style><IconStyle><Icon><href>http://www.google.com/intl/en_us/mapfiles/ms/icons/green-dot.png</href></Icon></IconStyle></Style>
<Point><coordinates>%d,%d</coordinates></Point></Placemark>'
           ) %('<a
href="http://'+url+'/'+str(ad.key().id())+'">'+ad.title+'</a><br/>'+defaultfilters.urlize(
 defaultfilters.truncatewords( defaultfilters.striptags(  ad.text ) ,
20 )  ),ad.geopt.lon,ad.geopt.lat)
                self.response.out.write(kml)
        self.response.out.write( '</Document></kml>')

(www.koolbusiness.com/output.kml)

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to