layer choser for wms feeds

This commit is contained in:
Sanj 2012-08-14 11:10:46 +05:30
parent 0b78f091c4
commit aaeed4456b
4 changed files with 42 additions and 8 deletions

View File

@ -4,7 +4,7 @@ var creds = {
}
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/' + creds.cloudmade + '/997/256/{z}/{x}/{y}.png',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}),
map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 });
map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(19.11577, 72.855211), zoom: 11 });
var drawControl = new L.Control.Draw({
// position: 'topright',
@ -138,9 +138,18 @@ map.addLayer(drawnItems);
// alert("features parsed");
// })
// .addTo(map);
loadGeoJsonFeatures("/geojson/10/");
wmsLayers = {};
wmsLayers['Test Warped Map'] = L.tileLayer.wms("http://mapwarper.net/maps/wms/336", {
'format': 'image/png'
});//.addTo(map);
L.control.layers(null, wmsLayers).addTo(map);
loadGeoJsonFeatures("/geojson/" + CONTENT_TYPE_ID);
function loadGeoJsonFeatures(url, params) {
//alert("hi");
@ -204,4 +213,9 @@ function loadGeoJsonFeatures(url, params) {
}
$(function() {
$('#ctypeList').change(function() {
var ctype_id = $(this).val();
location.href = '/edit/' + ctype_id;
});
});

View File

@ -1,11 +1,21 @@
# Create your views here.
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.contrib.contenttypes.models import ContentType
def index(request):
context = RequestContext(request, {})
return render_to_response("index.html", context)
def edit(request):
context = RequestContext(request, {})
def edit(request, ctype_id):
ctypes = []
content_type_id = int(ctype_id)
for c in ContentType.objects.all():
if hasattr(c.model_class(), 'is_openmumbai_model'):
ctypes.append(c)
context = RequestContext(request, {
'ctypes': ctypes,
'content_type_id': ctype_id
})
return render_to_response("edit.html", context)

View File

@ -36,12 +36,22 @@ html, body {
<script src="/static/leaflet/leaflet.js"></script>
<script src="/static/leaflet/leaflet.draw.js"></script>
<script src="http://code.jquery.com/jquery.js"></script>
<script>
CONTENT_TYPE_ID = {{ content_type_id }};
</script>
</head>
<body>
<div id="map"></div>
<div id="overlayWrapper">
<select id="ctypeList">
{% for c in ctypes %}
<option value="{{ c.id }}" {% ifequal c.id content_type_id %} selected="selected" {% endifequal %}>
{{ c.name }}
</option>
{% endfor %}
</select>
<ul id="itemsList">
</ul>
<div id="itemInfo">

View File

@ -14,8 +14,8 @@ urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^$', 'places.views.index', name='index'),
url(r'^geojson/(?P<ctype_id>[0-9]+)/$', 'base.views.geojson', name='geojson'),
url(r'^edit/$', 'places.views.edit', name='edit'),
url(r'^geojson/(?P<ctype_id>[0-9]+)$', 'base.views.geojson', name='geojson'),
url(r'^edit/(?P<ctype_id>[0-9]+)$', 'places.views.edit', name='edit'),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)