--- a/mouchak/static/css/mouchak.css +++ b/mouchak/static/css/mouchak.css @@ -4,4 +4,11 @@ padding: 3px; font-size: 1.5em; } + +#map{ +width: 1000px; +height: 500px; +margin-top: 30px; +position: relative; +} --- a/mouchak/static/js/editor.js +++ b/mouchak/static/js/editor.js @@ -310,6 +310,12 @@ //$('#specific-content.preview').html(); view.render('.preview');*/ } + else if(type === "map"){ + var template = _.template($('#map-template').html()); + $('#specific-content').html(template({ + tileLayer: this.model.get('tileLayer') + })); + } }, typeChanged: function(event) { var type = this.$select.val(); --- a/mouchak/static/js/models.js +++ b/mouchak/static/js/models.js @@ -58,6 +58,16 @@ } }); + // Map model + var Map = BaseType.extend({ + defaults: _.extend(BaseType.prototype.defaults, { + tileLayer: "" + }), + initialize: function(){ + BaseType.prototype.initialize.call(this, arguments); + } + }); + // Plugin model can be used to load dynamic components // to the website by loading external JS files. // Also the website can be styled by using external CSS files, @@ -134,12 +144,13 @@ 'rss': RSS, 'table': Table, 'plugin': Plugin, + 'map': Map, 'Page': Page, 'Pages': Pages }; //content types to render in content menu - M.contentTypes = ['text', 'image', 'video', 'table', 'plugin']; + M.contentTypes = ['text', 'image', 'video', 'table', 'plugin', 'map']; })(M); --- a/mouchak/static/js/views.js +++ b/mouchak/static/js/views.js @@ -110,6 +110,22 @@ } }); + var MapView = Backbone.View.extend({ + initialize: function(){ + _.bindAll(this); + _.bind(this.render, this); + }, + render: function(el){ + var template = _.template($("#map-template").html()); + $(el).append(template); + var southWest = new L.LatLng(47.20, 4.04); //Logic to calculate the bounds for "world view". + var northEast = new L.LatLng(55.10, 16.67); + var restrictBounds = new L.LatLngBounds(southWest, northEast); + M.map = new L.Map('map',{mapBounds: restrictBounds, zoom: 2, worldCopyJump: true, center:[14.604847155053898, 2.8125] }); + L.tileLayer(this.model.get("tileLayer")).addTo(M.map); + } + }); + var PageView = Backbone.View.extend({ tagName: 'div', className: 'pageview', @@ -158,6 +174,7 @@ 'rss': RSSView, 'table': TableView, 'plugin': PluginView, + 'map': MapView, 'PageView': PageView }; })(M); --- a/mouchak/templates/editor.html +++ b/mouchak/templates/editor.html @@ -204,6 +204,20 @@ + + +
@@ -107,6 +113,14 @@ + + + + +