[mapguide-users] Hyperlink in Selection panel
Mauricio Villablanca
mgvillablanca at yahoo.com
Thu Aug 2 18:29:26 PDT 2012
I modified the viewer file ajaxmappane.templ to merge the control-click and
tooltip functionality into one so that neither gets broken when used
separately with standard values.
The main functions to modify are DisplayHyperlinkTip and ExecuteHyperlink
function ExecuteHyperlink(url)
{
//don't allow clicks for data feeds
var pound = url.search(/#/); // MV
var dataFeedArray = url.split("#");//MV
var beginURL;
var dataFeedURL;
var feedScale;
var ctrlClickURL;
if (dataFeedArray.length == 2) {
beginURL = dataFeedArray[0].substr(0, 8); //e.g. dataFeed
dataFeedURL = dataFeedArray[0].substr(9, dataFeedArray[0].length-9);
//URL to be used in the AJAX request
feedScale = dataFeedArray[1]; //scale for which the AJAX request will
be made
//alert("URL: " + dataFeedURL + "\nScale: " + feedScale);//ok
} else if (dataFeedArray.length == 3) {
beginURL = dataFeedArray[0].substr(0, 8); //e.g. dataFeed
dataFeedURL = dataFeedArray[0].substr(9, dataFeedArray[0].length-9);
//URL to be used in the AJAX request
feedScale = dataFeedArray[1]; //scale for which the AJAX request will
be made
ctrlClickURL = dataFeedArray[2]; //URL for ctrl click
//alert("URL: " + dataFeedURL + "\nScale: " + feedScale +"\nControl
click URL: " + ctrlClickURL);//ok
}
if (pound == -1) {
//no tooltip, regular URL
targetFrame = "";
if(hlTgt == 1) targetFrame = "taskPaneFrame";
else if(hlTgt == 3) targetFrame = hlTgtName;
winRef = null;
if(targetFrame != "")
winRef = parent.GetFrame(targetFrame);
if (winRef != null)
{
winRef.location.href = url;
return winRef;
}
else
{
//the code can be modified here, if necessary, to control the size
and appearance of the
//new window. e.g. window.open(url, targetFrame,
"toolbar=no,width=500,height=500,resizable,scrollbars");
window.open(url, targetFrame);
}
} else {
//scripted tool tip + URL
if (ctrlClickURL != undefined) {
//add map name and session
ctrlClickURL += "&MAPNAME=" + mapName + "&SESSION=" + sessionId;
//alert(ctrlClickURL);
targetFrame = "";
if(hlTgt == 1) targetFrame = "taskPaneFrame";
else if(hlTgt == 3) targetFrame = hlTgtName;
winRef = null;
if(targetFrame != "")
winRef = parent.GetFrame(targetFrame);
if (winRef != null)
{
winRef.location.href = ctrlClickURL;
return winRef;
}
else
{
window.open(ctrlClickURL, targetFrame);
}
} else {
//alert("Control click URL is not defined");//ok
}
}
}
function DisplayHyperlinkTip(x,y)
{
var dataFeedArray = hlData.url.split("#");//MV
var beginURL;
var dataFeedURL;
var feedScale;
//alert(dataFeedArray.length);
if (dataFeedArray.length == 2) {
beginURL = dataFeedArray[0].substr(0, 8); //e.g. dataFeed
dataFeedURL = dataFeedArray[0].substr(9, dataFeedArray[0].length-9);
//URL to be used in the AJAX request
feedScale = dataFeedArray[1]; //scale for which the AJAX request will
be made
//alert("URL: " + dataFeedURL + "\nScale: " + feedScale);//ok
} else if (dataFeedArray.length == 3) {
beginURL = dataFeedArray[0].substr(0, 8); //e.g. dataFeed
dataFeedURL = dataFeedArray[0].substr(9, dataFeedArray[0].length-9);
//URL to be used in the AJAX request
feedScale = dataFeedArray[1]; //scale for which the AJAX request will
be made
ctrlClickURL = dataFeedArray[2]; //URL for ctrl click
//alert("URL: " + dataFeedURL + "\nScale: " + feedScale +"\nControl
click URL: " + ctrlClickURL);//ok
}
if (feedScale == undefined) {//set scale for URLs not related to data
feeds
feedScale = -1;
}
if(hlData.ttip != "")
{
ttinfo = " " + hlData.ttip + " ";
ttinfo = ttinfo.replace(/\\n/g, "<br> ");
if(hlData.url != "")
ttinfo += "<br>";
}
else {
ttinfo = "";
}
if ((beginURL == "dataFeed" && GetScale() <= feedScale) || (hlData.url
!= "" && beginURL != "dataFeed")) { //MV
//urlinfo = " " + openHlinkText + " (" + hlData.url +
") "; //don't include the link
urlinfo = " " + openHlinkText + " ";
} else {
urlinfo = "";
}
if (beginURL == "dataFeed" && GetScale() <= feedScale) { //MV enable
data feed at lower scales only
if (msie) {//IE
//retrieve data associated to these coordinates //MV
var scriptURLArray = dataFeedURL.split("?");
var scriptURL = dataFeedURL;
var scriptPars = "";
if (scriptURLArray.length > 0) {
//the script has parameters
scriptURL = scriptURLArray[0];
scriptPars = scriptURLArray[1];
var reqHandler = CreateRequestHandler();
reqHandler.open("POST", scriptURL + "?MAPNAME=" + mapName +
"&SESSION=" + sessionId + "&X=" + GetCursorPosition().X + "&Y=" +
GetCursorPosition().Y + "&" + scriptPars, false);
reqHandler.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
reqHandler.onreadystatechange = function() {
if(reqHandler.readyState == 4) {
var response = reqHandler.responseText;
document.getElementById("hlph").innerHTML = '<div style="visibility:
hidden;" id="hlTip">' + response + '</div>'; //MV
reqHandler = null;
}
}
reqHandler.send(null);
} else {
var reqHandler = CreateRequestHandler();
reqHandler.open("POST", dataFeedURL + "?MAPNAME=" + mapName +
"&SESSION=" + sessionId + "&X=" + GetCursorPosition().X + "&Y=" +
GetCursorPosition().Y, false);
reqHandler.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
reqHandler.onreadystatechange = function() {
if(reqHandler.readyState == 4) {
var response = reqHandler.responseText;
document.getElementById("hlph").innerHTML = '<div style="visibility:
hidden;" id="hlTip">' + response + '</div>'; //MV
reqHandler = null;
}
}
reqHandler.send(null);
}
} else {//Firefox
document.getElementById("hlph").innerHTML = '<div style="visibility:
visible;" id="hlTip"></div>'; //MV
//retrieve data associated to these coordinates //MV
var scriptURLArray = dataFeedURL.split("?");
var scriptURL = dataFeedURL;
var scriptPars = "";
if (scriptURLArray.length > 0) {
//the script has parameters
scriptURL = scriptURLArray[0];
scriptPars = scriptURLArray[1];
var reqHandler = CreateRequestHandler();
reqHandler.open("POST", scriptURL + "?MAPNAME=" + mapName +
"&SESSION=" + sessionId + "&X=" + GetCursorPosition().X + "&Y=" +
GetCursorPosition().Y + "&" + scriptPars, true);
reqHandler.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
reqHandler.onreadystatechange = function() {
if(reqHandler.readyState == 4) {
var response = reqHandler.responseText;
document.getElementById("hlTip").innerHTML = response; //MV
reqHandler = null;
}
}
reqHandler.send(null);
} else {
var reqHandler = CreateRequestHandler();
reqHandler.open("POST", scriptURL + "?MAPNAME=" + mapName +
"&SESSION=" + sessionId + "&X=" + GetCursorPosition().X + "&Y=" +
GetCursorPosition().Y, true);
reqHandler.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
reqHandler.onreadystatechange = function() {
if(reqHandler.readyState == 4) {
var response = reqHandler.responseText;
document.getElementById("hlTip").innerHTML = response; //MV
reqHandler = null;
}
}
reqHandler.send(null);
}
}
} else {
document.getElementById("hlph").innerHTML = '<div style="visibility:
hidden;" id="hlTip">' + ttinfo + urlinfo + '</div>';
}
tip = document.getElementById("hlTip");
if (tip != null) {//IE
y += 20;
w = tip.offsetWidth;
h = tip.offsetHeight;
if(hlData.url != "")
w /= 2;
if(x + w >= mapPosX + mapDevW)
x = (mapPosX + mapDevW) - w - 1;
if(y + h >= mapDevH)
y = mapDevH - h - 1;
if ((beginURL == "dataFeed" && GetScale() <= feedScale) || (hlData.url
!= "" && beginURL != "dataFeed") || hlData.url == "") {//MV
tip.style.visibility = "visible";
tip.style.top = y;
tip.style.left = x;
}
} else {
//show error in the status bar
parent.sbFrame.SetCursorPositionMsg("The hlTip div does not exist.");
}
}
Then in Mapguide Studio I set the URL activated string to:
concat('dataFeed:../map_tools/testing/exif/exif_www/exiftool/tooltip/metadata_tooltip.php?SITELAYER=structure_site&FEATID=',concat("FeatId",concat('&IMGTIME=',concat("img_time",concat('&FILEPATH=',concat("filenpath",concat('&DATEPHOTO=',concat("date_photo",concat('#6000#../map_tools/testing/exif/exif_www/exiftool/tooltip/metadata_taskpane_redirect.php?METADATALAYER=LASC_METADATA&SITELAYER=structure_site&FEATID=',concat("FeatId",concat('&FILEPATH=',concat("filenpath",concat('&DATEPHOTO=',concat("date_photo",concat('&X=',concat("coord_x",concat('&Y=',concat("coord_y",concat('&IMGTIME=',"img_time")))))))))))))))))))
The string follows this format:
dataFeed:URLForTooltip#ScaleAtWhichTooltipIsActive#URLForControlClick
The result is a dynamic tooltip when hovering using one server-sided script
and the taskpane running a different script when control-clicking.
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Hyperlink-in-Selection-panel-tp4984293p4992813.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list