[mapguide-users] Select and zoom to feature in Mapguide+Fusion

Chris Claydon chris.claydon at autodesk.com
Thu Apr 23 12:02:01 EDT 2009


Hi Alba,

Do you get any errors displayed when you run this?

Does the alert popup correctly with your map name?

If you add an alert to display the selectionXml, does it look valid too?

The instructions below refer to the most recent version of Fusion, so I can't guarantee that they're valid for the one you're using...

I don't think the Fusion map object has a SetSelectionXML method. Instead, you would want to call map.setSelection(selectionXml, false). The second parameter controls whether or not you want to zoom to the extents of the selection.

There is also no ZoomToView method in the current version. Instead, you should call var extent = map.getExtentFromPoint(feature.centerX, feature.centerY, scale); and then map.setExtents(extent);

Let me know if this works with your version.

Chris.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of alba
Sent: Thursday, April 23, 2009 9:13 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] Select and zoom to feature in Mapguide+Fusion


hi Traian,

You excuse me for this email, but I see that you have sent many posts, then
maybe you can help

I have the problem to select and to zoom objects on map

I use mgos 2.0.1 with IIS and fusion
I insert the function

<script language="javascript" >

In my procedure I insert

function GetParent()
{
    if(popup) {
        return opener;
    } else {
        return parent.parent;
    }
}


...
function Selezione_oggetto(){

var resultSelect = document.getElementById("resultSelect");
var k=0;
var valoreCercato=dati_ord[resultSelect.value];
while(valoreCercato!=dati[k]){
  k=k+1;
  }
            //alert(k);
            reqParams = "COMMAND=GETSELECTIONXML";
			reqParams += "&SESSION=" + encodeURIComponent(session);
            reqParams += "&MAPNAME=" + encodeURIComponent(mapName);
			reqParams += "&LAYERNAME=" + encodeURIComponent("Catastali");
			reqParams += "&IDLIST=" + results[k].idList.toJSONString();
            if (msie)
                reqHandler = new ActiveXObject("Microsoft.XMLHTTP");
            else
                reqHandler = new XMLHttpRequest();

            reqHandler.open("POST", "querycontroller.php", false);
            reqHandler.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
			reqHandler.send(reqParams);
			selectionXml = reqHandler.responseText;
            alert(mapName);

// ?????????? problem----------------------

//parent.parent.mapFrame.SetSelectionXML(TrimString(selectionXml));// old
for mg 1.2

var map = GetParent().Fusion.getMapByName(mapName);  // ??????????

map.SetSelectionXML(selectionXml);// ??????????
}


function Zoom_oggetto()
{//alert("ZoomToFeature");
var resultSelect = document.getElementById("resultSelect");
var scaleInput = document.getElementById("scaleInput");
scale = scaleInput.value;
scale = (scale == 0) ? 10000 : scale;
scale = scale*1.0;
var k=0;
var valoreCercato=dati_ord[resultSelect.value];
while(valoreCercato!=dati[k]){
    k=k+1;
  }

feature = results[k];

// ?????????? problem----------------------
//parent.parent.mapFrame.ZoomToView(feature.centerX, feature.centerY, scale,
true);// ??????????

var map = GetParent().Fusion.getMapByName(mapName);// ??????????
map.ZoomToView(feature.centerX, feature.centerY, scale, true);// ??????????

}


</script>

all from example ..www\phpviewersample\query

but it does not work!

Can you help me, please?

Thank Alba

-- 
View this message in context: http://n2.nabble.com/Changing-current-selection-colour-tp1805368p2683842.html
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