From 3acc28f00c3624b8ec0619a05d3963f4753e9e5b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 23 Jan 2019 14:55:47 +0100 Subject: Map: basic management of map tab --- ishtar_common/static/js/ishtar-map.js | 59 ++++++++++++++++++---- ishtar_common/static/js/ishtar.js | 95 +++++++++++++++++++++++++++++------ 2 files changed, 127 insertions(+), 27 deletions(-) (limited to 'ishtar_common/static/js') diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index 3a0b4bd35..8fb01f06c 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -1,13 +1,50 @@ +/* layers */ +var source_osm = function(options){ + return new ol.layer.Tile({ + source: new ol.source.OSM() + }); +}; + + +var map_layers = { + 'osm': source_osm +}; + +var get_layers = function(layers){ + if (!layers){ + layers = [{'type': 'osm', 'options': null}]; + } + console.log(layers); + var ol_layers = []; + for (idx in layers){ + var layer_attr = layers[idx]; + ol_layers.push( + map_layers[layer_attr['type']](layer_attr['options']) + ); + } + return ol_layers; +}; + +/* get markers */ + +var get_markers = function(points){ +}; + + +/* display map */ + +var display_map = function(map_id, points, layers){ + var map = new ol.Map({ + target: map_id, + layers: get_layers(layers), + view: new ol.View({ + center: ol.proj.fromLonLat([37.41, 8.82]), + zoom: 4 + }) + }); + get_markers(points); + + +} -var map = new ol.Map({ - target: 'map', - layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() - })], - view: new ol.View({ - center: ol.proj.fromLonLat([37.41, 8.82]), - zoom: 4 - }) -}); diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 19bec49e3..f450fef49 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -23,6 +23,12 @@ beforeSend: function(xhr, settings) { } }}); +if (typeof String.prototype.endsWith !== 'function') { + String.prototype.endsWith = function(suffix) { + return this.indexOf(suffix, this.length - suffix.length) !== -1; + }; +} + function manage_async_link(event){ event.preventDefault(); var url = $(this).attr('href'); @@ -1048,10 +1054,10 @@ var number_with_commas = function(number) { return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } -var render_gallery = function(data_table, table_name, nb_select, gallery_id){ - var html = '