diff --git a/VIPSWeb/static/js/frontpageMap.js b/VIPSWeb/static/js/frontpageMap.js index 8e5dbb75adfc962f088825665590bb0fec505b8c..64dfe9f907380964ab5ffdd5b05b4176817ecffe 100755 --- a/VIPSWeb/static/js/frontpageMap.js +++ b/VIPSWeb/static/js/frontpageMap.js @@ -126,17 +126,14 @@ function initFrontpageMap(lonLat, zoomLevel, mapAttribution) target: 'map', layers: [backgroundLayer, forecastLayer, observationLayer], overlays: [popOverlay], - renderer: 'canvas' + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat(lonLat, 'EPSG:3857'), + zoom:zoomLevel, + maxZoom: getSelectedMapLayer() == FORECAST_LAYER ? maxMapZoomForForecasts : maxMapZoomForObservations + }) }); - // Setting zoom and center for the map (need to do this after creating map. so that we can transform our - // center to correct map projection) - var view = new ol.View({ - center: ol.proj.transform(lonLat, 'EPSG:4326', map.getView().getProjection().getCode()), - zoom:zoomLevel, - maxZoom: getSelectedMapLayer() == FORECAST_LAYER ? maxMapZoomForForecasts : maxMapZoomForObservations - }); - // Getting data and rendering the selected layer selectMapLayer(getSelectedMapLayer()); /*if(getSelectedMapLayer() == FORECAST_LAYER) @@ -148,8 +145,6 @@ function initFrontpageMap(lonLat, zoomLevel, mapAttribution) initObservationLayer(); }*/ - map.setView(view); - // Attempting to adjust map to small screen if(map.getSize()[0] < 500) { diff --git a/VIPSWeb/static/js/weatherStationSelectorMap.js b/VIPSWeb/static/js/weatherStationSelectorMap.js index 609b81b3a5ee6bf713c9fc941a61699c1319a6e8..6afbda4b865a5796108b98c2e98328e2be9d7350 100755 --- a/VIPSWeb/static/js/weatherStationSelectorMap.js +++ b/VIPSWeb/static/js/weatherStationSelectorMap.js @@ -70,24 +70,16 @@ function initMap(center, zoomLevel, attribution, organizationId, weatherStationF target: 'weatherStationSelectionMap', layers: [backgroundLayer,weatherStationLayer], overlays: [popOverlay], - renderer: 'canvas' - }); - - var centerPosition = ol.proj.transform(center, 'EPSG:4326', map.getView().getProjection().getCode()); - - // Setting zoom and center for the map (need to do this after creating map. so that we kan transform our - // center to correct map projection) - var view = new ol.View({ - center: centerPosition, - zoom:zoomLevel + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat(center, 'EPSG:3857'), + zoom: zoomLevel + }) }); - map.setView(view); // Using Bootstrap's popover plugin. See http://getbootstrap.com/javascript/#popovers var poiDetails = $("#popover"); - - - + // Displays popup with forecasts for a given station // (if there is a station where the click event is fired) var displayFeatureDetails = function(pixel, coordinate) { diff --git a/applefruitmoth/static/applefruitmoth/js/map.js b/applefruitmoth/static/applefruitmoth/js/map.js index 5496de3cda65bd130b6dc261a2ac8c6769c009ff..9602b07c683f426909b5f8512fdd006d8c25a399 100755 --- a/applefruitmoth/static/applefruitmoth/js/map.js +++ b/applefruitmoth/static/applefruitmoth/js/map.js @@ -49,17 +49,13 @@ var initMap = function(container, mapAttribution) target: container, layers: [backgroundLayer, forecastLayer], overlays: [popOverlay], - renderer: 'canvas' + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat([9,61], 'EPSG:3857'), + zoom: 6 + }) }); - - // Setting zoom and center for the map (need to do this after creating map. so that we can transform our - // center to correct map projection) - var view = new ol.View({ - center: ol.proj.transform([9,61], 'EPSG:4326', map.getView().getProjection().getCode()), - zoom: 6 - }); - map.setView(view); - + // Using Bootstrap's popover plugin. See http://getbootstrap.com/javascript/#popovers var poiDetails = $("#popover"); diff --git a/ipmd/static/ipmd/js/ipmdlib.js b/ipmd/static/ipmd/js/ipmdlib.js index def866f696f77ea0946e6c8d4154864621a0a276..7f45505aaad502acb692352abf09c47f3735d3f3 100644 --- a/ipmd/static/ipmd/js/ipmdlib.js +++ b/ipmd/static/ipmd/js/ipmdlib.js @@ -670,21 +670,16 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList, featureC map = new ol.Map({ target: containerId, layers: [backgroundLayer], - renderer: 'canvas' + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat([10,65], 'EPSG:3857'), + zoom: 7 + }) }); - // Adding it to list of maps, for bookkeeping maps[containerId] = map; - // Setting zoom and center for the map (need to do this after creating map. so that we can transform our - // center to correct map projection) - var view = new ol.View({ - center: ol.proj.transform([10,65], 'EPSG:4326', map.getView().getProjection().getCode()), - zoom: 7 - }); - map.setView(view); - // Read the datasource's geoJson features let drawnFeatures = undefined; let features = new ol.Collection(); diff --git a/observations/static/observations/js/observationList.js b/observations/static/observations/js/observationList.js index 31b65b8b83b5774eb93637813f514662dff36a0f..987e4786f9b802e7c3818018d70ca1e7d9ee2cc1 100644 --- a/observations/static/observations/js/observationList.js +++ b/observations/static/observations/js/observationList.js @@ -101,7 +101,12 @@ var initMap = function( target: 'observationMap', layers: [backgroundLayer, observationLayer], overlays: [popOverlay], - renderer: 'canvas' + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat(center, 'EPSG:3857'), + zoom:zoomLevel, + maxZoom:7 + }) }); // For some reason, we have to wait with selecting the layer until after the map has @@ -110,16 +115,6 @@ var initMap = function( // Using Bootstrap's popover plugin. See http://getbootstrap.com/javascript/#popovers poiDetails = $("#popover"); - // Setting zoom and center for the map (need to do this after creating map. so that we kan transform our - // center to correct map projection) - var centerPosition = ol.proj.transform(center, 'EPSG:4326', map.getView().getProjection().getCode()); - var view = new ol.View({ - center: centerPosition, - zoom:zoomLevel, - maxZoom:7 - }); - map.setView(view); - // Need to build the query string var params = []; diff --git a/observations/static/observations/js/observationViewMap.js b/observations/static/observations/js/observationViewMap.js index a37cf9b12a76d6623cc66eb15cc98fda0cc35a47..7414e30b2514b12da73ed3c9b874a870f72b6feb 100755 --- a/observations/static/observations/js/observationViewMap.js +++ b/observations/static/observations/js/observationViewMap.js @@ -39,22 +39,16 @@ var initMap = function(geoJSON, poi, container, mapAttribution) map = new ol.Map({ target: container, layers: [backgroundLayer], - renderer: 'canvas' + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat([10,65], 'EPSG:3857'), + zoom: 7, + maxZoom: 7 + }) }); - // Setting zoom and center for the map (need to do this after creating map. so that we can transform our - // center to correct map projection) - var view = new ol.View({ - center: ol.proj.transform([10,65], 'EPSG:4326', map.getView().getProjection().getCode()), - zoom: 7, - maxZoom: 7 - }); - map.setView(view); - var features = new ol.Collection(); - - - + if(geoJSON != null) { var featureOverlay = new ol.layer.Vector({ diff --git a/spatial/static/spatial/js/gridmap.js b/spatial/static/spatial/js/gridmap.js index 4f9937e99ca1142253091eec1b3f60d853d3272d..ee181beb1831c2398443699ffefc5dcf0a06fce7 100644 --- a/spatial/static/spatial/js/gridmap.js +++ b/spatial/static/spatial/js/gridmap.js @@ -327,19 +327,11 @@ async function initGridMap(inputModelId, wmsURL, mapAttribution) { map = new ol.Map({ target: "mapContainer", layers: [backgroundLayer].concat(layers), - renderer: 'canvas' + renderer: 'canvas', + view: new ol.View({ + }) }); - - // Setting zoom and center for the map (need to do this after creating map. so that we can transform our - // center to correct map projection) - var view = new ol.View({ - //center: ol.proj.transform(lonLat, 'EPSG:4326', map.getView().getProjection().getCode()), - //zoom: 5, - //maxMapZoom: 10, - }); - map.setView(view); - // If today is outside of the date range, use the most recent timestamp if(wmsServiceSuccess && isDataReturned) { diff --git a/spatial/static/spatial/js/spatialMap.js b/spatial/static/spatial/js/spatialMap.js index b2d8c711dc70ba256657648becdae1d2d9d44945..a57ba0b849f54be8f21423760a168610b18090d8 100644 --- a/spatial/static/spatial/js/spatialMap.js +++ b/spatial/static/spatial/js/spatialMap.js @@ -86,18 +86,13 @@ function initSpatialMap(lonLat, zoomLevel, mapAttribution, mapId) { map = new ol.Map({ target: mapId, layers: [backgroundLayer, carrotLayer], - renderer: 'canvas' - }); - - - // Setting zoom and center for the map (need to do this after creating map. so that we can transform our - // center to correct map projection) - var view = new ol.View({ - center: ol.proj.transform(lonLat, 'EPSG:4326', map.getView().getProjection().getCode()), - zoom: zoomLevel, - maxMapZoom: maxMapZoom, + renderer: 'canvas', + view: new ol.View({ + center: ol.proj.fromLonLat(lonLat, 'EPSG:3857'), + zoom: zoomLevel, + maxZoom: maxMapZoom, + }) }); - map.setView(view); map.on('singleclick', (evt) => { const coordinate = proj4('EPSG:3857', 'EPSG:25833', evt.coordinate)