summaryrefslogtreecommitdiff
path: root/ishtar_common/static
diff options
context:
space:
mode:
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
commiteec732392dde94dd0cfc4a35e8a2f96e9e5ecdeb (patch)
tree075b06bb8b0153ea87aadb1707cf4b72408b466d /ishtar_common/static
parent7d987d9729dd8e116d9bc04cf034054e2b685960 (diff)
downloadIshtar-eec732392dde94dd0cfc4a35e8a2f96e9e5ecdeb.tar.bz2
Ishtar-eec732392dde94dd0cfc4a35e8a2f96e9e5ecdeb.zip
Map JS: fix projections for display
Diffstat (limited to 'ishtar_common/static')
-rw-r--r--ishtar_common/static/js/ishtar-map.js21
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
})