[Mapbender-commits] r7773 - in trunk/mapbender/http: javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Apr 14 05:48:28 EDT 2011
Author: verenadiewald
Date: 2011-04-14 02:48:28 -0700 (Thu, 14 Apr 2011)
New Revision: 7773
Modified:
trunk/mapbender/http/javascripts/mod_usemap.php
trunk/mapbender/http/php/mod_usemap.php
Log:
merged with branch 2.7 revision 7772 (http://trac.osgeo.org/mapbender/ticket/807)
Modified: trunk/mapbender/http/javascripts/mod_usemap.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_usemap.php 2011-04-14 09:42:09 UTC (rev 7772)
+++ trunk/mapbender/http/javascripts/mod_usemap.php 2011-04-14 09:48:28 UTC (rev 7773)
@@ -20,41 +20,63 @@
var mod_usemap_target = 'mapframe1';
var mod_usemap_wfs = "<url>";
var mod_usemap_px = 10;
-var um_title;
-var um_draw;
-mb_registerSubFunctions('mod_usemap_init()');
-mb_registerInitFunctions("um_init()");
+eventAfterMapRequest.register(function () {
+ mod_usemap_init();
+});
+Mapbender.events.init.register(function () {
+ um_init();
+});
+
function mod_usemap_init(){
var ind = getMapObjIndexByName(mod_usemap_target);
var extent = mb_mapObj[ind].extent.toString();
- var url = "../php/mod_usemap.php?url="
- url += escape(mod_usemap_wfs + "&BBOX=" + extent);
+ //var url = "../php/mod_usemap.php?url="
+ var url = mod_usemap_wfs + "&BBOX=" + extent;
url += "&extent=" + extent;
url += "&width=" + mb_mapObj[ind].width;
url += "&height=" + mb_mapObj[ind].height;
url += "&gui_id=<?php echo $gui_id;?>";
url += "&e_id=<?php echo $e_id;?>";
- document.getElementById('usemap').src = url;
- var myImg = document.getElementById("um_img").style;
- myImg.zIndex = "10000";
- myImg.width = mb_mapObj[ind].width;
- myImg.height = mb_mapObj[ind].height;
+
+
+ $("#um_img").css({
+ position:'absolute',
+ width:mb_mapObj[ind].width,
+ height:mb_mapObj[ind].height,
+ zIndex:100
+ });
+
+ var req = new Mapbender.Ajax.Request({
+ url: "../php/mod_usemap.php",
+ method: "createUsemap",
+ parameters: {
+ url: url
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ return;
+ }
+ mod_usemap_set(obj.um_title,obj.um_x,obj.um_y);
+ }
+ });
+ req.send();
}
+
function mod_usemap_set(title,x,y){
var str = "";
for(var i=0; i<title.length; i++){
var pos = makeRealWorld2mapPos(mod_usemap_target,x[i],y[i]);
- str += "<AREA onmouseover='parent.over(event, \"" + title[i] + "\", this)' ";
- str += "onmouseout=parent.out(this) shape='circle' coords='";
+ str += "<AREA onmouseover='over(event, \"" + title[i] + "\", this)' ";
+ str += "onmouseout=out(this) shape='circle' coords='";
str += Math.round(pos[0]) + "," + Math.round(pos[1]) + "," + mod_usemap_px + "'";
str += " href='#'>";
}
writeTag('', 'um', str);
}
-/* Opacity for hilighting */
+/* Opacity for highlighting */
cw_opacity = 0.5;
/* Color for polygon boundary */
cw_bndcolor = "#ff0000";
@@ -87,6 +109,7 @@
if ((objid.shape.toUpperCase() == 'POLY') || (objid.shape.toUpperCase() == 'POLYGON')){
var Xcoords = polyXcoords(coords);
var Ycoords = polyYcoords(coords);
+
var pgx = Xcoords.split(',');
var pgy = Ycoords.split(',');
for (var i=0 ; i<pgx.length ; i++ ){
@@ -102,11 +125,15 @@
}
if ((objid.shape.toUpperCase() == 'CIRCLE')){
var c = coords;
+
+ c[0] = parseInt(c[0]);
+ c[1] = parseInt(c[1]);
+
canvas.setColor(cw_fillcolor);
- canvas.fillEllipse(parseInt(c[0])-mod_usemap_px/2,parseInt(c[1])-mod_usemap_px/2,parseInt(c[2]),parseInt(c[2]));
+ canvas.fillEllipse(c[0]-mod_usemap_px/2,c[1]-mod_usemap_px/2,parseInt(c[2]),parseInt(c[2]));
canvas.paint();
canvas.setColor(cw_bndcolor);
- canvas.drawEllipse(parseInt(c[0])-mod_usemap_px/2,parseInt(c[1])-mod_usemap_px/2,parseInt(c[2]),parseInt(c[2]));
+ canvas.drawEllipse(c[0]-mod_usemap_px/2,c[1]-mod_usemap_px/2,parseInt(c[2]),parseInt(c[2]));
canvas.paint();
}
canvasHasDrawing = true;
@@ -123,26 +150,47 @@
var coords = area.coords.split(',');
area.setAttribute('title', "");
if (!isOver){
- um_title.innerHTML = id;
- um_title.style.display = "block";
+ $("#um_title").html(id).css("display", "block");
isOver = area;
setFocus(area);
}
- mb_arrangeElement('', 'um_title', parseInt(coords[0])+mod_usemap_px, parseInt(coords[1])+mod_usemap_px);
+ $("#um_title").css({
+ position: "absolute",
+ top: parseInt(coords[1])+mod_usemap_px + "px",
+ left: parseInt(coords[0])+mod_usemap_px + "px"
+ });
canvasHasDrawing = true;
}
function out(area){
- um_title.innerHTML = "";
- um_title.style.display = "none";
+ $("#um_title").html("").css("display", "none");
clearFocus(area);
isOver = false;
canvasHasDrawing = false;
}
-function um_init(){
- um_title = document.getElementById("um_title"); /* tooltip */
- um_draw = document.getElementById("um_draw"); /* tooltip */
+function um_init() {
+ $("#mapframe1").append("<img src='../img/transparent.gif' usemap='#um' name='um_img' id='um_img' />");
+ $("#mapframe1").append("<div id='um_draw'></div>");
+ $("#um_draw").css({
+ left:0,
+ overflow:'visible',
+ position:'absolute',
+ top:0,
+ zIndex:99
+ });
+ $("#mapframe1").append("<div name='um_title' id='um_title'></div>");
+ $("#um_title").css({
+ 'font-family': 'Arial, Helvetica, sans-serif',
+ display:'none',
+ overflow:'visible',
+ position:'absolute',
+ background:'#BEC1C4',
+ border:'1px solid black',
+ zIndex:98
+ });
+ $("#mapframe1").append("<map id='um' name='um'></map>");
+
var mapObjInd = getMapObjIndexByName(mod_usemap_target);
canvas = new jsGraphics('um_draw', mb_mapObj[mapObjInd].getDomElement().frameName ? window.frames[mapframe] : window);
canvas.setStroke(2);
Modified: trunk/mapbender/http/php/mod_usemap.php
===================================================================
--- trunk/mapbender/http/php/mod_usemap.php 2011-04-14 09:42:09 UTC (rev 7772)
+++ trunk/mapbender/http/php/mod_usemap.php 2011-04-14 09:48:28 UTC (rev 7773)
@@ -1,5 +1,3 @@
-<html>
-<head>
<?php
# $Id$
# http://www.mapbender.org/index.php/UseMap
@@ -19,35 +17,39 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once dirname(__FILE__) . "/../../core/globalSettings.php";
require_once(dirname(__FILE__)."/../classes/class_gml2.php");
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
-?>
-<title>image map generator</title>
-</head>
-<?php
+require_once(dirname(__FILE__)."/../classes/class_json.php");
-$url = urldecode($_REQUEST["url"]);
+$ajaxResponse = new AjaxResponse($_POST);
+if($ajaxResponse->getMethod() != "createUsemap") {
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage("method invalid");
+ $ajaxResponse->send();
+ exit;
+}
+
+$url = $ajaxResponse->getParameter('url'); //urldecode($_REQUEST["url"]);
+
$g = new gml2();
$g->parsegml($url);
-echo "<script language='JavaScript'>";
-echo "var um_title = new Array();";
-echo "var um_x = new Array();";
-echo "var um_y = new Array();";
- for($ii=0; $ii<$g->getMemberCount();$ii++){
- echo "um_title[um_title.length] = '".$g->getValueBySeparatedKey($ii,"name")."';";
- echo "um_x[um_x.length] = ".$g->getXfromMemberAsString($ii,0).";";
- echo "um_y[um_y.length] = ".$g->getYfromMemberAsString($ii,0).";";
- }
-echo "</script>"
-?>
-<script language="JavaScript" type="text/javascript">
-function init(){
- parent.mod_usemap_set(um_title,um_x,um_y);
+$um_title = array();
+$um_x = array();
+$um_y = array();
+for($i=0; $i<$g->getMemberCount();$i++) {
+ $um_title[] = utf8_decode($g->getValueBySeparatedKey($i,"name"));
+ $um_x[] = $g->getXfromMemberAsString($i,0);
+ $um_y[] = $g->getYfromMemberAsString($i,0);
}
-</script>
-<body onload='init()'>
-</body>
-</html>
\ No newline at end of file
+
+$resultObj = array();
+$resultObj['um_title'] = $um_title;
+$resultObj['um_x'] = $um_x;
+$resultObj['um_y'] = $um_y;
+
+$ajaxResponse->setSuccess(true);
+$ajaxResponse->setResult($resultObj);
+$ajaxResponse->send();
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list