[mapguide-users] RE: DWF viewer get attributes
Ivan Miličević
ivan at ineo.hr
Thu Mar 29 03:42:59 EDT 2007
Thanx a lot man!
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Mbonnet
Sent: Thursday, March 29, 2007 9:35 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] RE: DWF viewer get attributes
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#a972837
4
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
More information about the mapguide-users
mailing list