[mapguide-users] RE: DWF viewer get attributes
Mbonnet
mbonnet at adelior.gfi.fr
Thu Mar 29 03:35:16 EDT 2007
I'll try to be clear.
So first of all, i haved haded 2 vars in dwfmappane.templ :
myX and myY
in this same file, under : "<script language=javascript for="DWFViewer"
event="OnMouseMove(buttons, x, y, handled)">" i had :
var latlon = IsLatLongDisplayUnits();
var pt = ScreenToMapUnits(x, y);
if(latlon)
pt = MapUnitsToLatLon(pt.X, pt.Y);
myx = pt.X.toFixed(6);
myy = pt.Y.toFixed(6);
in order to have the geom of the selected object
then i had some functions in dwfmappane.tml :
function MakeWktPolygon(x1,y1,x2,y2) {
return "POLYGON((" + x1 + " " + y1 + ", " + x2 + " " + y1 + ", " + x2 +
" " + y2 + ", " + x1 + " " + y2 + ", " + x1 + " " + y1 + "))";
}
function GetVisSelLayers() {
var visSelLayers = "";
var lyrs = GetLayers(true, true);
for(var i=0; i < lyrs.length; i++)
{
if(i > 0)
visSelLayers += ",";
visSelLayers += lyrs[i].name;
}
return visSelLayers;
}
function CreateRequestHandler() {
if(msie)
return new ActiveXObject("Microsoft.XMLHTTP");
else
return new XMLHttpRequest();
}
function Property(name, value) {
this.name = name;
this.value = value;
}
function ficheAlphaClient(xmlIn)
{
var maxfeatures = 0;
var url = "http://vmmgos:8008/mapguide/mapagent/mapagent.fcgi";
var req = url +
"?OPERATION=QUERYMAPFEATURES&VERSION=1.0.0&PERSIST=1&MAPNAME=" +
encodeURIComponent(GetMapName()) + "&SESSION=" + GetSessionId() + "&SEQ=" +
Math.random();
req += "&LAYERNAMES=" + encodeURIComponent(GetVisSelLayers()) +
"&GEOMETRY=" + MakeWktPolygon(myx,myy + 1,myx,myy + 1) +
"&SELECTIONVARIANT=INTERSECTS";
//prompt('Posez ici votre question',req);
if(maxfeatures != 0)
req += "&MAXFEATURES=" + maxfeatures;
var selRequest = CreateRequestHandler();
selRequest.open("GET", req, false);
selRequest.send(null);
if(selRequest.responseXML)
{
var xmlIn = selRequest.responseXML.documentElement;
}
else
{
RequestFailed("No response");
}
var properties = new Array();
var props = xmlIn.getElementsByTagName("Property");
var sourceLayer = xmlIn.getElementsByTagName("Class");
var typeSource = sourceLayer[0].getAttribute("id");
var paramValues = "";
if(props != null)
{
for(var i=0; i < props.length; i++)
{
var name = props[i].getAttribute("name");
var value = props[i].getAttribute("value");
properties.push(new Property(name, value));
}
}
}
and finally i had :
parent.ficheAlphaClient();
in the OnSelectedChanged() of the emaprelayer.html page
i hope i haven't forgot something.
--
View this message in context: http://www.nabble.com/DWF-viewer-get-attributes-tf3468102s16610.html#a9728374
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list