From 5ee414684e55e48a831f66cba83ac6bd484cb7e8 Mon Sep 17 00:00:00 2001 From: Alessio Fabiani Date: Sat, 10 Feb 2018 15:58:38 +0100 Subject: [PATCH] [Fixes #3591] [Map Client - GeoExplorer] Zoom level seems not to be respected the first time (#3595) --- .../templates/layers/layer_geoext_map.html | 16 +++--- .../maps/templates/maps/map_geoexplorer.js | 53 ++++++++++--------- geonode/maps/templates/maps/map_include.html | 38 ++++++------- .../geonode/js/extjs/GeoNode-GeoExplorer.js | 6 +-- geonode/templates/geonode/geo_header.html | 2 +- .../templates/geonode/geo_header_debug.html | 12 ++--- 6 files changed, 64 insertions(+), 63 deletions(-) diff --git a/geonode/layers/templates/layers/layer_geoext_map.html b/geonode/layers/templates/layers/layer_geoext_map.html index ec1e5f0e6b0..9c24bc93ac7 100644 --- a/geonode/layers/templates/layers/layer_geoext_map.html +++ b/geonode/layers/templates/layers/layer_geoext_map.html @@ -62,13 +62,15 @@ {% if 'access_token' in request.session %} try { - l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); - - if((!l.url.match(/\baccess_token/gi))) { - l.url += "access_token={{request.session.access_token}}"; - } else { - l.url = - l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + if(l.url != undefined && (typeof l.url) == "string") { + l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); + + if((!l.url.match(/\baccess_token/gi))) { + l.url += "access_token={{request.session.access_token}}"; + } else { + l.url = + l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + } } } catch(err) { console.log(err); diff --git a/geonode/maps/templates/maps/map_geoexplorer.js b/geonode/maps/templates/maps/map_geoexplorer.js index b9acb97b1f9..fd843ae27ae 100644 --- a/geonode/maps/templates/maps/map_geoexplorer.js +++ b/geonode/maps/templates/maps/map_geoexplorer.js @@ -42,25 +42,27 @@ Ext.onReady(function() { tools: [{ptype: "gxp_getfeedfeatureinfo"}], listeners: { "ready": function() { - app.mapPanel.map.getMaxExtent = function() { - return new OpenLayers.Bounds(-80150033.36/2,-80150033.36/2,80150033.36/2,80150033.36/2); - } - app.mapPanel.map.getMaxResolution = function() { - return 626172.135625/2; - } l = app.selectedLayer.getLayer(); l.addOptions({wrapDateLine:true, displayOutsideMaxExtent: true}); - l.addOptions({maxExtent:app.mapPanel.map.getMaxExtent(), restrictedExtent:app.mapPanel.map.getMaxExtent()}); - + if(app.selectedLayer.data.queryable) { + app.mapPanel.map.getMaxExtent = function() { + return new OpenLayers.Bounds(-80150033.36/2,-80150033.36/2,80150033.36/2,80150033.36/2); + } + app.mapPanel.map.getMaxResolution = function() { + return 626172.135625/2; + } + l.addOptions({maxExtent:app.mapPanel.map.getMaxExtent(), restrictedExtent:app.mapPanel.map.getMaxExtent()}); + } {% if 'access_token' in request.session %} try { - l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); - - if((!l.url.match(/\baccess_token/gi))) { - l.url += "access_token={{request.session.access_token}}"; - } else { - l.url = - l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + if(l.url != undefined && (typeof l.url) == "string") { + l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); + if((!l.url.match(/\baccess_token/gi))) { + l.url += "access_token={{request.session.access_token}}"; + } else { + l.url = + l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + } } } catch(err) { console.log(err); @@ -69,19 +71,18 @@ Ext.onReady(function() { for (var ll in app.mapPanel.map.layers) { l = app.mapPanel.map.layers[ll]; - if (l.url && l.url.indexOf('{{GEOSERVER_BASE_URL}}') !== -1) { + if (l.url != undefined && (typeof l.url) == "string" && l.url.indexOf('{{GEOSERVER_BASE_URL}}') !== -1) { l.addOptions({wrapDateLine:true, displayOutsideMaxExtent: true}); l.addOptions({maxExtent:app.mapPanel.map.getMaxExtent(), restrictedExtent:app.mapPanel.map.getMaxExtent()}); {% if 'access_token' in request.session %} try { - l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); - - if((!l.url.match(/\baccess_token/gi))) { - l.url += "access_token={{request.session.access_token}}"; - } else { - l.url = - l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); - } + l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); + if((!l.url.match(/\baccess_token/gi))) { + l.url += "access_token={{request.session.access_token}}"; + } else { + l.url = + l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + } } catch(err) { console.log(err); } @@ -96,7 +97,7 @@ Ext.onReady(function() { if (bbox != undefined) { if (!Array.isArray(bbox) && Object.keys(layer.srs) in bbox) { - bbox = bbox[Object.keys(layer.srs)].bbox; + bbox = bbox[Object.keys(layer.srs)].bbox; } var extent = new OpenLayers.Bounds(); @@ -121,7 +122,7 @@ Ext.onReady(function() { app.mapPanel.zoom = map.zoom; map.events.unregister('changebaselayer', null, zoomToData); }; - map.events.register('changebaselayer',null,zoomToData); + map.events.register('changebaselayer',null, zoomToData); if(map.baseLayer){ map.zoomToExtent(extent, false); } diff --git a/geonode/maps/templates/maps/map_include.html b/geonode/maps/templates/maps/map_include.html index 8e23d0982e7..7a5e08391a9 100644 --- a/geonode/maps/templates/maps/map_include.html +++ b/geonode/maps/templates/maps/map_include.html @@ -46,25 +46,26 @@ listeners: { "ready": function() { - app.mapPanel.map.getMaxExtent = function() { + /*app.mapPanel.map.*/ var getMaxExtent = function() { return new OpenLayers.Bounds(-80150033.36/2,-80150033.36/2,80150033.36/2,80150033.36/2); } - app.mapPanel.map.getMaxResolution = function() { + /* app.mapPanel.map.*/ var getMaxResolution = function() { return 626172.135625/2; } l = app.selectedLayer.getLayer(); l.addOptions({wrapDateLine:true, displayOutsideMaxExtent: true}); - l.addOptions({maxExtent:app.mapPanel.map.getMaxExtent(), restrictedExtent:app.mapPanel.map.getMaxExtent()}); + l.addOptions({maxExtent:/*app.mapPanel.map.*/ getMaxExtent(), restrictedExtent:/*app.mapPanel.map.*/ getMaxExtent()}); {% if 'access_token' in request.session %} try { - l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); - - if((!l.url.match(/\baccess_token/gi))) { - l.url += "access_token={{request.session.access_token}}"; - } else { - l.url = - l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + if(l.url != undefined && (typeof l.url) == "string") { + l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); + if((!l.url.match(/\baccess_token/gi))) { + l.url += "access_token={{request.session.access_token}}"; + } else { + l.url = + l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + } } } catch(err) { console.log(err); @@ -73,19 +74,18 @@ for (var ll in app.mapPanel.map.layers) { l = app.mapPanel.map.layers[ll]; - if (l.url && l.url.indexOf('{{GEOSERVER_BASE_URL}}') !== -1) { + if (l.url != undefined && (typeof l.url) == "string" && l.url.indexOf('{{GEOSERVER_BASE_URL}}') !== -1) { l.addOptions({wrapDateLine:true, displayOutsideMaxExtent: true}); l.addOptions({maxExtent:app.mapPanel.map.getMaxExtent(), restrictedExtent:app.mapPanel.map.getMaxExtent()}); {% if 'access_token' in request.session %} try { - l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); - - if((!l.url.match(/\baccess_token/gi))) { - l.url += "access_token={{request.session.access_token}}"; - } else { - l.url = - l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); - } + l.url += ( !l.url.match(/\b\?/gi) || l.url.match(/\b\?/gi).length == 0 ? '?' : '&'); + if((!l.url.match(/\baccess_token/gi))) { + l.url += "access_token={{request.session.access_token}}"; + } else { + l.url = + l.url.replace(/(access_token)(.+?)(?=\&)/, "$1={{request.session.access_token}}"); + } } catch(err) { console.log(err); } diff --git a/geonode/static/geonode/js/extjs/GeoNode-GeoExplorer.js b/geonode/static/geonode/js/extjs/GeoNode-GeoExplorer.js index ee16b4d764f..e88e9f8bca6 100644 --- a/geonode/static/geonode/js/extjs/GeoNode-GeoExplorer.js +++ b/geonode/static/geonode/js/extjs/GeoNode-GeoExplorer.js @@ -814,7 +814,7 @@ GeoNode.plugins.Print = Ext.extend(gxp.plugins.Tool, { zoomBoxEnabled: false }), new OpenLayers.Control.PanPanel(), - new OpenLayers.Control.ZoomPanel(), + // new OpenLayers.Control.ZoomPanel(), new OpenLayers.Control.Attribution() ], eventListeners: { @@ -823,12 +823,12 @@ GeoNode.plugins.Print = Ext.extend(gxp.plugins.Tool, { } } }, mapPanel.initialConfig.map), - items: [{ + items: [/*{ xtype: "gx_zoomslider", vertical: true, height: 100, aggressive: true - }], + }*/], listeners: { afterlayout: function(evt) { printWindow.setWidth(Math.max(360, this.getWidth() + 24)); diff --git a/geonode/templates/geonode/geo_header.html b/geonode/templates/geonode/geo_header.html index 06c843edcca..c9d0a9a0f66 100644 --- a/geonode/templates/geonode/geo_header.html +++ b/geonode/templates/geonode/geo_header.html @@ -66,7 +66,7 @@ GeoExplorer.Viewer.superclass.loadConfig.call(this, config); }; -//remove the 3D Viewer from GeoExplorer +// remove the 3D Viewer from GeoExplorer GeoExplorer.Composer.prototype.loadConfig = function(config) { // remove the 3D Viewer if no Google API Key is availbale var google_api_key = '{% google_api_key %}'; diff --git a/geonode/templates/geonode/geo_header_debug.html b/geonode/templates/geonode/geo_header_debug.html index e33e1525d48..b9fdf1ec84d 100644 --- a/geonode/templates/geonode/geo_header_debug.html +++ b/geonode/templates/geonode/geo_header_debug.html @@ -354,13 +354,11 @@ checked: true }); - /* - TEMPORARLY DISABLED GXPLORER PLAYBACK - - config.viewerTools.push({ - ptype: "gxp_playback", - checked: true, - outputTarget: "paneltbar" - }); - */ + config.viewerTools.push({ + ptype: "gxp_playback", + checked: true, + outputTarget: "paneltbar" + }); // Do not include the layer styler on the map-detail view. {% if not map %}