Skip to content

Commit

Permalink
[Fixes #3591] [Map Client - GeoExplorer] Zoom level seems not to be r…
Browse files Browse the repository at this point in the history
…espected the first time (#3595)
  • Loading branch information
Alessio Fabiani authored and capooti committed Feb 10, 2018
1 parent d0d167c commit 5ee4146
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 63 deletions.
16 changes: 9 additions & 7 deletions geonode/layers/templates/layers/layer_geoext_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
53 changes: 27 additions & 26 deletions geonode/maps/templates/maps/map_geoexplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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();
Expand All @@ -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);
}
Expand Down
38 changes: 19 additions & 19 deletions geonode/maps/templates/maps/map_include.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions geonode/static/geonode/js/extjs/GeoNode-GeoExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion geonode/templates/geonode/geo_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}';
Expand Down
12 changes: 5 additions & 7 deletions geonode/templates/geonode/geo_header_debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit 5ee4146

Please sign in to comment.