From aaeed4456b43c760ad261606afd4a57626a7f578 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 14 Aug 2012 11:10:46 +0530 Subject: [PATCH] layer choser for wms feeds --- openmumbai/places/static/js/edit.js | 22 ++++++++++++++++++---- openmumbai/places/views.py | 14 ++++++++++++-- openmumbai/templates/edit.html | 10 ++++++++++ openmumbai/urls.py | 4 ++-- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/openmumbai/places/static/js/edit.js b/openmumbai/places/static/js/edit.js index 7d05053..360c58f 100644 --- a/openmumbai/places/static/js/edit.js +++ b/openmumbai/places/static/js/edit.js @@ -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; + }); +}); diff --git a/openmumbai/places/views.py b/openmumbai/places/views.py index 2908ceb..df5bf0c 100644 --- a/openmumbai/places/views.py +++ b/openmumbai/places/views.py @@ -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) diff --git a/openmumbai/templates/edit.html b/openmumbai/templates/edit.html index 37c6c1a..54abffc 100644 --- a/openmumbai/templates/edit.html +++ b/openmumbai/templates/edit.html @@ -36,12 +36,22 @@ html, body { +
+
diff --git a/openmumbai/urls.py b/openmumbai/urls.py index 20ce2b7..1f35d43 100644 --- a/openmumbai/urls.py +++ b/openmumbai/urls.py @@ -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[0-9]+)/$', 'base.views.geojson', name='geojson'), - url(r'^edit/$', 'places.views.edit', name='edit'), + url(r'^geojson/(?P[0-9]+)$', 'base.views.geojson', name='geojson'), + url(r'^edit/(?P[0-9]+)$', 'places.views.edit', name='edit'), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), )