[Mapbender-commits] r4076 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jun 23 04:09:58 EDT 2009
Author: verenadiewald
Date: 2009-06-23 04:09:57 -0400 (Tue, 23 Jun 2009)
New Revision: 4076
Modified:
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/mod_zoomFull.php
Log:
Mapbender API
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2009-06-22 18:39:42 UTC (rev 4075)
+++ trunk/mapbender/http/javascripts/map_obj.js 2009-06-23 08:09:57 UTC (rev 4076)
@@ -1,7 +1,7 @@
-/*
+/*
* $Id: map_obj.js 2517 2008-06-19 16:40:00Z christoph $
* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
*/
var mb_mapObj = [];
@@ -13,11 +13,11 @@
this.setExtent = function(minx, miny, maxx, maxy){
this.extent = String(minx) + "," + String(miny) + "," + String(maxx) + "," + String(maxy);
};
-
+
this.restrictedExtent = function (extent) {
this.restrictedExtent = extent;
};
-
+
/**
* get the width of the mapObj
*
@@ -28,7 +28,7 @@
this.getWidth = function(){
return parseInt(this.width, 10);
};
-
+
/**
* set the width of the mapObj
*
@@ -44,7 +44,7 @@
var domElement = this.getDomElement();
domElement.style.width = this.width;
};
-
+
/**
* get the height of the mapObj
*
@@ -55,14 +55,14 @@
this.getHeight = function(){
return parseInt(this.height, 10);
};
-
+
this.getDomElement = function(){
if(this.frameName){
return window.frames[this.frameName].document.getElementById(this.elementName);
}
return document.getElementById(this.elementName);
}
-
+
/**
* set the height of the mapObj
*
@@ -77,7 +77,7 @@
var domElement = this.getDomElement();
domElement.style.height = this.height;
};
-
+
this.getMousePosition = function (e) {
var clickX, clickY;
@@ -100,24 +100,24 @@
if (this.type == "DIV") {
var mapDomElement = this.getDomElement();
currentPos = new Point(
- clickX - parseInt(mapDomElement.style.left),
+ clickX - parseInt(mapDomElement.style.left),
clickY - parseInt(mapDomElement.style.top)
);
// if the mouse position is not on top of the map, return null
- if (currentPos.x < 0 || currentPos.x > this.width ||
+ if (currentPos.x < 0 || currentPos.x > this.width ||
currentPos.y < 0 || currentPos.y > this.height) {
return null;
}
}
else {
currentPos = new Point(
- clickX,
+ clickX,
clickY
);
}
return currentPos;
}
-
+
/**
* converts the extent of the mapobject so that the maximum extent will be displayed
*/
@@ -133,13 +133,13 @@
ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
}
-
+
// Check if ext is within restricted extent
// If not, calculate a new extent according
// to restricted extent.
/*
if ( this.restrictedExtent ) {
- if ( ext.minx < this.restrictedExtent.minx ) {
+ if ( ext.minx < this.restrictedExtent.minx ) {
ext.minx = this.restrictedExtent.minx;
ext.maxx = ext.minx + (relation_px_x * ext.extenty);
}
@@ -160,8 +160,8 @@
this.setExtent(ext.minx, ext.miny, ext.maxx, ext.maxy);
return ext;
};
-
-
+
+
this.width = width;
this.height = height;
this.frameName = frameName;
@@ -173,10 +173,10 @@
this.geom = "";
this.gml = "";
this.wms = [];
-
- //
+
+ //
// Add pointers to WMS objects which are in this map.
- // If wms_index is set (=map is overview), only this
+ // If wms_index is set (=map is overview), only this
// WMS is being pointed to.
//
var index = 0;
@@ -188,9 +188,9 @@
index++;
}
}
-
+
//
- // set list of visible layers, active querylayers
+ // set list of visible layers, active querylayers
// and styles for each WMS in this map
//
var cnt_layers;
@@ -204,7 +204,7 @@
styles = "";
layers = "";
querylayers = "";
-
+
for (var ii = 0; ii < this.wms[i].objLayer.length; ii++) {
// layer is visible and not root layer
if (this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii > 0) {
@@ -229,10 +229,10 @@
this.styles[i] = styles;
this.querylayers[i] = querylayers;
}
-
+
this.epsg = wms[0].gui_wms_epsg;
var bbox_minx, bbox_miny, bbox_maxx, bbox_maxy;
-
+
for (var i = 0; i < wms[0].gui_epsg.length; i++) {
if (this.epsg == wms[0].gui_epsg[i]) {
bbox_minx = parseFloat(wms[0].gui_minx[i]);
@@ -242,16 +242,16 @@
}
}
var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
-
+
this.calculateExtent(wmsExtent);
this.mapURL = [];
var domElement = this.getDomElement();
domElement.style.width = this.width;
- domElement.style.height = this.height;
-
+ domElement.style.height = this.height;
+
this.afterMapRequest = new MapbenderEvent();
-
+
/**
* get the extent of the mapObj
*
@@ -262,7 +262,7 @@
this.getExtent = function(){
return this.extent;
};
-
+
/**
* get the extent as minx, maxx, miny, maxy
*
@@ -274,7 +274,7 @@
var ext = new Extent(c[0], c[1], c[2], c[3]);
return ext;
};
-
+
/**
* Sets the list of layers, styles and querylayers for a specified WMS
*/
@@ -313,9 +313,9 @@
}
// this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
};
-
+
/**
- *
+ *
* @param {Object} direction
*/
this.pan = function (direction) {
@@ -327,79 +327,83 @@
var xtentx = maxx - minx;
var xtenty = maxy - miny;
var factor = 0.5;
-
+
switch (direction) {
case "NW" :
- minx -= (xtentx * factor);
- maxx -= (xtentx * factor);
- miny += (xtenty * factor);
+ minx -= (xtentx * factor);
+ maxx -= (xtentx * factor);
+ miny += (xtenty * factor);
maxy += (xtenty * factor);
break;
case "N" :
- miny += (xtenty * factor);
+ miny += (xtenty * factor);
maxy += (xtenty * factor);
break;
case "NE" :
- minx += (xtentx * factor);
- maxx += (xtentx * factor);
- miny += (xtenty * factor);
+ minx += (xtentx * factor);
+ maxx += (xtentx * factor);
+ miny += (xtenty * factor);
maxy += (xtenty * factor);
break;
case "E" :
- minx += (xtentx * factor);
+ minx += (xtentx * factor);
maxx += (xtentx * factor);
break;
case "SE" :
- minx += (xtentx * factor);
- maxx += (xtentx * factor);
- miny -= (xtenty * factor);
- maxy -= (xtenty * factor);
+ minx += (xtentx * factor);
+ maxx += (xtentx * factor);
+ miny -= (xtenty * factor);
+ maxy -= (xtenty * factor);
break;
case "S" :
- miny -= (xtenty * factor);
+ miny -= (xtenty * factor);
maxy -= (xtenty * factor);
break;
case "SW" :
- minx -= (xtentx * factor);
- maxx -= (xtentx * factor);
- miny -= (xtenty * factor);
+ minx -= (xtentx * factor);
+ maxx -= (xtentx * factor);
+ miny -= (xtenty * factor);
maxy -= (xtenty * factor);
break;
case "W" :
- minx -= (xtentx * factor);
+ minx -= (xtentx * factor);
maxx -= (xtentx * factor);
break;
}
this.extent = minx + "," + miny + "," + maxx + "," + maxy;
-
+
this.restrictedExtent;
this.setMapRequest();
-
+
};
-
+
this.zoomFull = function () {
-
+
+
+/*
+** not in use until now and commented out because of error in zoomFull module (Bolsena 23.6.09)
if (this.restrictedExtent) {
var newExtent = this.calculateExtent(this.restrictedExtent);
this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
}
else {
+*/
for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
if (this.epsg == this.wms[0].gui_epsg[i]) {
var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
-
+
var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
var newExtent = this.calculateExtent(wmsExtent);
this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
break;
}
}
- }
+// }
};
-
+
/**
* zoom the map with a zoomfactor and optional to x,y coords
*
@@ -413,11 +417,11 @@
if (!in_) {
factor = 1 / factor;
}
-
+
var extent = this.getExtentInfos();
var distx = extent.maxx - extent.minx;
var disty = extent.maxy - extent.miny;
-
+
if (x && y) {
var centerx = parseFloat(x);
var centery = parseFloat(y);
@@ -426,7 +430,7 @@
var centerx = extent.minx + distx / 2;
var centery = extent.miny + disty / 2;
}
-
+
var new_distx = distx / factor;
var new_disty = disty / factor;
var minx = centerx - new_distx / 2;
@@ -440,7 +444,7 @@
var relation_px_x = this.getWidth() / this.getHeight();
var relation_px_y = this.getHeight() / this.getWidth();
if ( this.restrictedExtent ) {
- if ( minx < this.restrictedExtent.minx ) {
+ if ( minx < this.restrictedExtent.minx ) {
minx = this.restrictedExtent.minx;
maxx = minx + (relation_px_x * new_disty);
}
@@ -458,12 +462,12 @@
}
}
*/
-
+
this.setExtent(minx, miny, maxx, maxy);
this.setMapRequest();
};
-
+
var performUnknownCalculation = function (value) {
return Math.pow(10,(
Math.round(
@@ -472,7 +476,7 @@
)
));
};
-
+
this.convertPixelToReal = function (aPoint) {
var arrayBBox = this.extent.split(",");
var minX = parseFloat(arrayBBox[0]);
@@ -496,14 +500,14 @@
}
else{
roundy = performUnknownCalculation(deltaY);
- }
+ }
var posX = parseFloat(minX + (aPoint.x / this.width) * xtentx);
var posY = parseFloat(maxY - (aPoint.y / this.height) * xtenty);
posX = Math.round(posX * roundx) / roundx;
posY = Math.round(posY * roundy) / roundy;
return new Point(posX, posY);
};
-
+
/**
* Convert real world coordinates to pixel coordinates
*/
@@ -514,11 +518,11 @@
var maxX = parseFloat(arrayBBox[2]);
var maxY = parseFloat(arrayBBox[3]);
return new Point(
- Math.round((aPoint.x - minX) * this.width /(maxX - minX)),
+ Math.round((aPoint.x - minX) * this.width /(maxX - minX)),
Math.round((maxY - aPoint.y) * this.height/(maxY - minY))
);
};
-
+
/**
* get the srs of the mapObj
*
@@ -528,7 +532,7 @@
this.getSRS = function(){
return this.epsg;
};
-
+
/**
* get all mapRequests
*
@@ -549,7 +553,7 @@
}
return false;
};
-
+
/**
* Return the map URL of the WMS at index i
* @param {Object} currentWmsIndex
@@ -561,17 +565,17 @@
return false;
}
var layerNames = validLayers.join(",");
-
+
url = currentWms.wms_getmap;
url += mb_getConjunctionCharacter(currentWms.wms_getmap);
-
+
if (currentWms.wms_version == "1.0.0") {
url += "WMTVER=" + currentWms.wms_version + "&REQUEST=map&";
}
else {
url += "VERSION=" + currentWms.wms_version + "&REQUEST=GetMap&SERVICE=WMS&";
}
-
+
url += "LAYERS=" + layerNames + "&";
url += "STYLES=";
var layer = layerNames.split(",");
@@ -590,14 +594,14 @@
url += "HEIGHT=" + this.height + "&";
url += "FORMAT=" + currentWms.gui_wms_mapformat + "&";
url += "BGCOLOR=0xffffff&";
-
+
if (currentWms.gui_wms_mapformat.search(/gif/i) > -1 ||
currentWms.gui_wms_mapformat.search(/png/i) > -1) {
url += "TRANSPARENT=TRUE&";
}
-
+
url += "EXCEPTIONS=" + currentWms.gui_wms_exceptionformat + "&";
-
+
// add vendor-specific
for (var v = 0; v < mb_vendorSpecific.length; v++) {
var functionName = 'setMapRequest';
@@ -605,7 +609,7 @@
// if eval doesn't evaluate a function, the result is undefined.
// Sometimes it is necessary not to evaluate a function, for
// example if you want to change a variable from the current
- // scope (see mod_addSLD.php)
+ // scope (see mod_addSLD.php)
if (typeof(vendorSpecificString) != "undefined") {
url += vendorSpecificString + "&";
}
@@ -620,7 +624,7 @@
}
return url;
}
-
+
/**
* get all featureInfoRequests
*
@@ -655,7 +659,7 @@
}
return false;
};
-
+
/**
* calculation of the mapscale
*
@@ -683,7 +687,7 @@
}
return parseInt(Math.round(scale));
};
-
+
/**
*
*/
@@ -695,10 +699,10 @@
for (var i = 0; i < this.wms[wmsIndex].objLayer.length; i++) {
var currentLayer = this.wms[wmsIndex].objLayer[i];
var myLayername = currentLayer.layer_name;
-
+
var myMinscale = currentLayer.gui_layer_minscale;
var myMaxscale = currentLayer.gui_layer_maxscale;
-
+
for (var ii = 0; ii < thisLayer.length; ii++) {
if (thisLayer[ii] == myLayername && !currentLayer.has_childs) {
if (myMinscale !== 0 && thisScale < myMinscale) {
@@ -718,9 +722,9 @@
var str_layerstyles = [];
str_layerstyles[0] = str_layer;
return str_layerstyles;
-
+
};
-
+
this.repaintScale = function(x, y, scale){
if (x === null && y === null) {
var arrayBBox = this.extent.split(",");
@@ -737,18 +741,18 @@
var maxy = parseFloat(y) + (this.height / (mb_resolution * 100 * 2) * scale);
this.repaint(new Point(minx, miny), new Point(maxx, maxy));
};
-
+
this.repaint = function(min, max){
this.extent = min.x + "," + min.y + "," + max.x + "," + max.y;
this.setMapRequest();
};
-
+
this.setSingleMapRequest = function (wms_id) {
eventBeforeMapRequest.trigger({map:this});
-
- var ts = mb_timestamp();
-
- for (var ii = 0; ii < this.wms.length; ii++){
+
+ var ts = mb_timestamp();
+
+ for (var ii = 0; ii < this.wms.length; ii++){
var currentWms = this.wms[ii];
if (currentWms.wms_id != wms_id) {
continue;
@@ -758,16 +762,16 @@
if (mb_log) {
var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
}
- var myDivId = this.elementName + "_div_" + ii;
+ var myDivId = this.elementName + "_div_" + ii;
writeTag(this.frameName, myDivId, newMapRequest);
var myMapId = this.elementName + "_map_" + ii;
eventAfterMapRequest.trigger({"map":this, "myMapId":myMapId});
return true;
- }
- return false;
-
+ }
+ return false;
+
};
-
+
this.mb_setFutureObj = function(mod_back_cnt){
var cnt = this.mb_MapFutureObj.length;
this.mb_MapFutureObj[cnt] = {};
@@ -777,7 +781,7 @@
this.mb_MapFutureObj[cnt].epsg = this.epsg;
this.mb_MapFutureObj[cnt].extent = this.extent;
this.mb_MapFutureObj[cnt].layers = [];
-
+
for(var i=0; i<this.layers.length;i++){
this.mb_MapFutureObj[cnt].layers[i] = this.layers[i];
}
@@ -794,7 +798,7 @@
this.mb_MapFutureObj[cnt].querylayers[i] = this.querylayers[i];
}
}
-
+
this.setMapRequest = function(){
var ret = eventBeforeMapRequest.trigger({
map: this
@@ -804,19 +808,19 @@
}
var ts = mb_timestamp();
var myMapId = [];
-
+
var newMapRequest = "";
-
+
for (var ii = 0; ii < this.wms.length; ii++) {
var currentWms = this.wms[ii];
-
+
if (!(currentWms.gui_wms_visible > 0)) {
continue;
}
myMapId.push(this.elementName + "_map_" + ii);
-
+
newMapRequest += getLayerHtmlCode(ii);
-
+
}
writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
@@ -831,21 +835,21 @@
var getLayerHtmlCode = function (ii) {
var currentWms = that.wms[ii];
-
- var myDivId = that.elementName + "_div_" + ii;
+
+ var myDivId = that.elementName + "_div_" + ii;
var myMapId = that.elementName + "_map_" + ii;
//disable Layer which are out of scale
var validLayers = that.checkScale(ii);
var layerNames = validLayers.toString();
-
+
var newMapURL = false;
var opacityString = "";
-
+
if (that.layers[ii] !== "" && layerNames !== ''){
// get map URL
newMapURL = that.getMapUrl(ii);
-
+
var currentOpacity = currentWms.gui_wms_mapopacity;
if (currentOpacity != 1) {
opacityString += "opacity:" + currentOpacity + "; ";
@@ -854,32 +858,32 @@
opacityString += "-khtml-opacity:" + currentOpacity;
}
}
-
+
var imageString = "";
if (newMapURL) {
imageString = "<img id='"+myMapId+"' name='mapimage' ";
imageString += "src='" + newMapURL + "' ";
imageString += "width='"+that.width+"' ";
imageString += "height='"+that.height+"' ";
- imageString += "border='0'>";
+ imageString += "border='0'>";
}
-
+
var newMapRequest = "<div id='"+myDivId+"' ";
newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
newMapRequest += imageString;
- newMapRequest += "</div>";
-
- that.mapURL[ii]= newMapURL;
+ newMapRequest += "</div>";
+
+ that.mapURL[ii]= newMapURL;
currentWms.mapURL = newMapURL;
-
+
if (mb_log && currentWms.mapURL) {
var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
}
-
+
return newMapRequest;
}
-
+
this.getWmsIdByTitle = function (title) {
for (var i=0; i < this.wms.length; i++) {
if (this.wms[i].wms_title == title) {
@@ -906,7 +910,7 @@
var new_querylayerarray = [];
var new_stylesarray = [];
var new_mapURLarray = [];
-
+
for (i = 0; i < this.wms.length; i++) {
if (i != wmsIndex) {
new_wmsarray.push(this.wms[i]);
@@ -919,24 +923,24 @@
wms_ID = this.wms[i].wms_id;
}
}
- this.wms = new_wmsarray;
- this.layers = new_layerarray;
- this.querylayers = new_querylayerarray;
- this.styles = new_stylesarray;
+ this.wms = new_wmsarray;
+ this.layers = new_layerarray;
+ this.querylayers = new_querylayerarray;
+ this.styles = new_stylesarray;
this.mapURL = new_mapURLarray;
-
+
var another_new_wmsarray = [];
for (i = 0; i < window.wms.length; i++) {
if (window.wms[i].wms_id != wms_ID) {
- another_new_wmsarray.push(window.wms[i]);
+ another_new_wmsarray.push(window.wms[i]);
}
}
- window.wms = another_new_wmsarray;
+ window.wms = another_new_wmsarray;
};
-
+
/**
- * move a wms or layer
+ * move a wms or layer
*
* @param int wms_id id of wms to move
* @param int layer_id id of layer to move
@@ -950,18 +954,18 @@
break;
}
}
-
+
//check if only one wms is affected?
if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
return this.wms[i].moveLayer(layer_id, moveUp);
}
-
+
//else swap wms
j = i + (moveUp?-1:1);
if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
return false;
}
-
+
upper = this.wms[i];
this.wms[i] = this.wms[j];
this.wms[j] = upper;
@@ -974,10 +978,10 @@
this.layers[j] = upperLayers;
this.styles[j] = upperStyles;
this.querylayers[j] = upperQuerylayers;
-
+
return true;
};
-
+
this.getMousePos = function(e){
if(ie){
if(this.frameName){
@@ -993,11 +997,11 @@
clickX = e.pageX;
clickY = e.pageY;
}
-
+
//remove divtag offset
clickX -= parseInt(this.getDomElement().style.left);
clickY -= parseInt(this.getDomElement().style.top);
-
+
return new Point(clickX, clickY);
}
@@ -1007,7 +1011,7 @@
mb_mapObj_const.prototype.getWfsConfIds = function (wfs_config) {
var db_wfs_conf_id = [];
var js_wfs_conf_id = [];
-
+
//search configurations that are selected (and in scale)
for (var i=0; i < this.wms.length; i++){
for(var ii=0; ii < this.wms[i].objLayer.length; ii++){
@@ -1025,6 +1029,6 @@
break;
}
}
- }
+ }
return js_wfs_conf_id;
};
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/mod_zoomFull.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_zoomFull.php 2009-06-22 18:39:42 UTC (rev 4075)
+++ trunk/mapbender/http/javascripts/mod_zoomFull.php 2009-06-23 08:09:57 UTC (rev 4076)
@@ -1,31 +1,21 @@
<?php
#$Id$
#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_zoomFull.php,v 1.8 2005/09/13 18:16:42 bjoern_heuser Exp $
-require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
?>
- var mod_zoomFull_img = new Image();
- mod_zoomFull_img.src = "<?php echo $e_src; ?>";
- var mod_zoomFull_img_over = new Image();
- mod_zoomFull_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
-
-function mod_zoomFull(){
- var frameName = "<?php echo $e_target[0]; ?>"
- var ind = this.getMapObjIndexByName(frameName);
-
- mb_mapObj[ind].zoomFull();
-}
-
-function mod_zoomFull_init(obj){
- document.getElementById("zoomFull").src = mod_zoomFull_img_over.src;
- obj.onmouseover = new Function("mod_zoomFull_over()");
- obj.onmouseout = new Function("mod_zoomFull_out()");
-}
-function mod_zoomFull_over(){
- document.getElementById("zoomFull").src = mod_zoomFull_img_over.src;
-}
-function mod_zoomFull_out(){
- document.getElementById("zoomFull").src = mod_zoomFull_img.src;
-}
-
-
-
+$(this).click(function () {
+ if (!options.target) {
+ return;
+ }
+ if (!Mapbender.Modules[options.target]) {
+ return;
+ }
+ Mapbender.Modules[options.target].zoomFull();
+}).mouseover(function () {
+ if (options.src) {
+ this.src = options.src.replace(/_off/, "_over");
+ }
+}).mouseout(function () {
+ if (options.src) {
+ this.src = options.src;
+ }
+});
\ No newline at end of file
More information about the Mapbender_commits
mailing list