Last change
on this file since 9779 was 9617, checked in by rick, 13 years ago |
Make sure to present the right mime-type.
|
File size:
666 bytes
|
Line | |
---|
1 | from django.http import HttpResponse
|
---|
2 | from gheat.models import Node
|
---|
3 |
|
---|
4 | import json
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 | def nodes_json(request):
|
---|
9 | geojson = []
|
---|
10 | for node in Node.objects.filter(**request.REQUEST):
|
---|
11 | item = {
|
---|
12 | "type": "Feature",
|
---|
13 | "properties": {
|
---|
14 | 'name' : node.name,
|
---|
15 | 'color' : 'rgb(0,255,0)',
|
---|
16 | },
|
---|
17 | "geometry": {
|
---|
18 | "type": "Point",
|
---|
19 | "coordinates": [
|
---|
20 | node.latitude,
|
---|
21 | node.longitude,
|
---|
22 | ]
|
---|
23 | }
|
---|
24 | }
|
---|
25 | geojson.append(item)
|
---|
26 | return HttpResponse(json.dumps({'type' : 'FeatureCollection', 'features' : geojson},indent=2),
|
---|
27 | content_type='application/json; charset=utf8')
|
---|
Note:
See
TracBrowser
for help on using the repository browser.