diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-02-04 11:29:45 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-24 19:38:56 +0200 | 
| commit | 27e715213b84eea8b92667b0d01c1a35a40858f9 (patch) | |
| tree | 075b06bb8b0153ea87aadb1707cf4b72408b466d /ishtar_common/static/js | |
| parent | aec0e1a20f4f57c6977f45932a178c2011d3d70c (diff) | |
| download | Ishtar-27e715213b84eea8b92667b0d01c1a35a40858f9.tar.bz2 Ishtar-27e715213b84eea8b92667b0d01c1a35a40858f9.zip  | |
Map JS: fix projections for display
Diffstat (limited to 'ishtar_common/static/js')
| -rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 21 | 
1 files changed, 15 insertions, 6 deletions
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index f1fbca3e1..a8e1a4fa5 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -2,6 +2,8 @@  var default_pointer = "../media/images/default-pointer.png"; +var view_projection = 'EPSG:3857'; +  var source_osm = function(options){      return new ol.layer.Tile({          source: new ol.source.OSM() @@ -63,24 +65,31 @@ var get_style = function(feature){  /* display map */ +var vector_source; +var vector_layer; +var map_layers; +var map; +var geojson_format = new ol.format.GeoJSON( +    {dataProjection:'EPSG:4326', featureProjection: view_projection}); +  var display_map = function(map_id, points, layers){ -    console.log((new ol.format.GeoJSON()).readFeatures(points)); -    var vector_source = new ol.source.Vector({ -        features: (new ol.format.GeoJSON()).readFeatures(points) +    vector_source = new ol.source.Vector({ +        features: geojson_format.readFeatures(points)      }); -    var vector_layer = new ol.layer.Vector({ +    vector_layer = new ol.layer.Vector({          source: vector_source,          style: get_style      }); -    var map_layers = get_layers(layers); +    map_layers = get_layers(layers);      map_layers.push(vector_layer); -    var map = new ol.Map({ +    map = new ol.Map({          target: map_id,          layers: map_layers,          view: new ol.View({ +            projection: view_projection,              center: ol.proj.fromLonLat([37.41, 8.82]),              zoom: 4          })  | 
