Django

Code

Show
Ignore:
Timestamp:
09/12/07 08:04:33 (1 year ago)
Author:
jbronn
Message:

gis: added the beginnings of a maps module, for generating mapping framework JavaScript?; cleaned up the sitemaps module and KML templates; added shortcuts module.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/sitemaps.py

    r5751 r6108  
    22from django.contrib.sitemaps import Sitemap 
    33from django.contrib.gis.db.models.fields import GeometryField 
     4from django.contrib.gis.shortcuts import render_to_kml 
    45from django.db.models import get_model, get_models 
    5 from django.template.loader import get_template 
    6 from django.template import Context 
    76from django.http import HttpResponse 
    8  
    9 kml_files = [('gis.school', 'location'), 
    10              ('gis.district', 'boundary')] 
    11  
    127 
    138class KMLSitemap(Sitemap): 
    149    """ 
    15     A minimal hook to  
     10    A minimal hook to produce KML sitemaps. 
    1611    """ 
    1712    def __init__(self, locations=None): 
     
    2823                                    kwargs={'label':obj[0], 
    2924                                            'field_name':obj[1]}) 
    30  
    3125 
    3226def _build_kml_sources(): 
     
    4640    pass 
    4741 
    48  
    4942def kml(request, label, field_name): 
    5043    placemarks = [] 
     
    5245    if not klass: 
    5346        raise KMLNotFound("You must supply a valid app.model label.  Got %s" % label) 
     47 
    5448    #FIXME: GMaps apparently has a limit on size of displayed kml files 
    5549    #  check if paginating w/ external refs (i.e. linked list) helps. 
    5650    placemarks.extend(list(klass._default_manager.kml(field_name)[:100])) 
     51 
    5752    #FIXME: other KML features? 
    58     t = get_template('gis/kml.xml'
    59     c = Context({'places':placemarks}) 
     53    return render_to_kml('gis/kml/placemarks.kml', {'places' : placemarks}
     54 
    6055     
    61     return HttpResponse(t.render(c), mimetype='application/vnd.google-earth.kml+xml') 
    62