diff options
Diffstat (limited to 'ishtar_common/static/js')
| -rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 135 | 
1 files changed, 34 insertions, 101 deletions
| diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index aa7263f7f..4403c7b62 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -146,9 +146,9 @@ var TrackPositionControl = (function (Control) {      if ( Control ) TrackPositionControl.__proto__ = Control;      TrackPositionControl.prototype = Object.create( Control && Control.prototype ); -    TrackPositionControl.prototype.varructor = TrackPositionControl; +    TrackPositionControl.prototype.constructor = TrackPositionControl; -    TrackPositionControl.prototype.handvarrackPosition = function handvarrackPosition () { +    TrackPositionControl.prototype.handleTrackPosition = function handleTrackPosition () {          if (!geolocation[this.map_id]){              set_geoloc_source(this.map_id);          } else { @@ -452,7 +452,7 @@ var open_map_window = function(map_id){      };  }; -var complete_list_label = "compvare list..."; +var complete_list_label = "complete list...";  var _display_items = function(map_id, features, offset_x, offset_y){      // console.log("display_items"); @@ -550,11 +550,12 @@ var vector_source = {};  var vector_layer = {};  var vector_features = {}; -// for test -var geo_items_features = null; -var current_test = false; +/* for test */ + +let geo_items_features = null; +let current_test = false;  var initialize_test_map = function (slug_pk) { -    var id = "http-geo-items-ready-" + slug_pk; +    const id = "http-geo-items-ready-" + slug_pk;      geo_items_features = {};      current_test = true;      if ($("#"+id).length === 0) { @@ -663,7 +664,7 @@ var display_lines_and_polys = function(map_id, lines_and_polys){  var display_geo_items = function(map_id, base_url, slug, pk,                                disp_cr, disp_bf, get_poly) { -    var url = base_url; +    let url = base_url;      if (slug === "operation") {          url += "?operation_pk=";      } @@ -677,9 +678,7 @@ var display_geo_items = function(map_id, base_url, slug, pk,      httpRequest.onreadystatechange = function() {          if (httpRequest.readyState === XMLHttpRequest.DONE) {              if (httpRequest.status === 200) { -                geo_items = to_geo_items(JSON.parse(httpRequest.responseText), slug, disp_cr, disp_bf) -                console.log('geoitems') -                console.log(geo_items) +                const geo_items = to_geo_items(JSON.parse(httpRequest.responseText), slug, disp_cr, disp_bf)                  if (current_test) {                      geo_items_features[map_id] = [];                  } @@ -710,7 +709,7 @@ var to_geo_items = function (obj, slug, disp_cr, disp_bf) {      if (slug === "operation") {          const crs = obj['properties']['context-records'];          for (const cr of crs['features']) { -            if (disp_bf) {console.log(cr); +            if (disp_bf) {                  for (const bf of cr['properties']['base-finds']['features']) {                      objects['base-finds']['features'].push(bf)                  } @@ -730,14 +729,14 @@ var to_geo_items = function (obj, slug, disp_cr, disp_bf) {  }  var display_associated_polys = function (map_id, polys, slug) { -    _vector_features = geojson_format.readFeatures(polys); -    _vector_source = new ol.source.Vector(); +    const _vector_features = geojson_format.readFeatures(polys); +    const _vector_source = new ol.source.Vector();      _vector_source.addFeatures(_vector_features); -    style = get_associated_base_find_style; +    let style = get_associated_base_find_style;      if (slug === 'contextrecord') {          style = get_associated_context_record_style;      } -    _vector_layer = new ol.layer.Vector({ +    const _vector_layer = new ol.layer.Vector({          source: _vector_source,          style: style      }); @@ -771,20 +770,15 @@ var get_associated_context_record_style = function (feature) {  };  var display_associated_points = function (map_id, points, slug) { -    console.log('geo items points') -    console.log(points); -    _point_features = geojson_format.readFeatures(points); -    _cluster_source = new ol.source.Cluster({ +    const _point_features = geojson_format.readFeatures(points); +    const _cluster_source = new ol.source.Cluster({          distance: 40,          source: new ol.source.Vector()      });      _cluster_source.getSource().addFeatures(_point_features);      // TODO: create own style -    style = cluster_get_style; -    if (slug === 'contextrecord') { -        style = style; -    } -    _cluster_layer = new ol.layer.Vector({ +    const style = cluster_get_style; +    const _cluster_layer = new ol.layer.Vector({          name: 'Cluster',          source: _cluster_source,          style: style @@ -793,86 +787,16 @@ var display_associated_points = function (map_id, points, slug) {      return _point_features;  } -// for test purpose -// to insert in sheet_simple_map.html when working with maps -// wait_for_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"); -var wait_for_map = function(map_id) { -    map[map_id].on('rendercomplete', function(event) { -        console.log("map fully loaded"); -    }) -    if (map_id in cluster_layer) { -        console.log('cluster layer'); -        cluster_layer[map_id].on('change', function(event) { -            if (cluster_layer.getState === "ready") { -                console.log("cluster fully loaded"); -            } -        }) -    } -    if (map_id in vector_layer) { -        console.log('vector layer'); -        vector_layer[map_id].on('change', function(event) { -            if (vector_layer.getState === "ready") { -                console.log("vector fully loaded"); -            } -        }) -    } -    if (map_id in cluster_source) { -        console.log('cluster source'); -        cluster_source[map_id].on('change', function(event) { -            if (cluster_source.getState === "ready") { -                console.log("cluster source fully loaded"); -            } -        }) -    } -    if (map_id in vector_source) { -        console.log('vector source'); -        vector_source[map_id].on('change', function(event) { -            if (vector_source.getState === "ready") { -                console.log("vector source fully loaded"); -            } -        }) -    } -} - -var get_map_by_id_test = function (id) { -// problem here: async function because map and layers are not fully loaded directly -    map[id].getLayers().getArray()[0].getSource().on( -        'change', function (evt) { -            console.log('change') -            var source = evt.target; -            if (source.getState() === "ready") { -                console.log('ready'); -                console.log(map_layers[id][0].getSource().getKeys()) -            } -        } -    ) -    map[id].on( -        'change', function (evt) { -            console.log('change') -            var map = evt.target; -            if (map.getState() === "ready") { -                console.log('ready'); -                console.log(map_layers[id][0].getSource().getKeys()) -            } -        } -    ) -    console.log("vector_features") -    console.log(vector_features[id]) -    console.log("layers") -    console.log(map_layers[id]) -    console.log("source") -    console.log(map_layers[id][0].getSource()) -} -  var get_features_by_id = function (id) { +    let base_features = null      if (vector_features[id] == null) { -        var base_features = geojson_format.writeFeaturesObject(point_features[id], {decimals: 5}); +        base_features = geojson_format.writeFeaturesObject(point_features[id], {decimals: 5});      } else { -        var base_features = geojson_format.writeFeaturesObject(vector_features[id], {decimals: 5}); +        base_features = geojson_format.writeFeaturesObject(vector_features[id], {decimals: 5});      } -    var geo_items_feats = []; +    const geo_items_feats = [];      if (geo_items_features && id in geo_items_features) { -        for (var features of geo_items_features[id]) { +        for (const features of geo_items_features[id]) {              geo_items_feats.push(geojson_format.writeFeaturesObject(features, {decimals: 5}));          }      } @@ -880,5 +804,14 @@ var get_features_by_id = function (id) {  }  var base_features_type = function (id) { -    return "vector " + typeof vector_features[id] + ", cluster " + typeof point_features[id] ; +    if (vector_features[id] == null) { +        if (point_features[id] == null) { +            return 'both null'; +        } +        else { return 'Point'; } +    } +    if (point_features[id] == null) { +        return 'MultiPolygon'; +    } +    else { return 'Point and MultiPolygon' }  } | 
