[mapguide-users] Select specific layer and feature by passing value to flexible layout (AIMS2014)

RenoSun renolionheart at gmail.com
Wed Jun 5 10:10:11 PDT 2013

Hello GordonL,

I added following codes in the my fusionInitialized() function in fusion

var fusionInitialized = function () {
            $('AppContainer').resize({ forceResize: true });
            var mapWidget = Fusion.getMapById('Map');

var sessionid = getMapGuideSessionID(mapWidget);
var mapname = getMapGuideMapName(mapWidget);

var link =
+ sessionid + "&MAPNAME=" + mapname;


if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var selectionXml = xmlhttp.responseText;
if (mapWidget && mapWidget.isMapLoaded()) {
+ sessionid + "&MAPNAME=" + mapname, true);

Also, I added a new php in C:\Program Files\Autodesk\Autodesk Infrastructure
Web Server Extension 2014\www\fusion\widgets\FeatureInspector folder, and
the content is from the website you mentioned. 
The content of php is following...

  $args = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST : $_GET;
  $sessionId = $args['SESSION'];
  $mapName = $args['MAPNAME'];
    // Initialize the Web Extensions and connect to the Server 
    // using the Web Extensions session identifier
    MgInitializeWebTier ($webconfigFilePath);
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $map = new MgMap($siteConnection);
    // Get the geometry for the parcel of FeatId equal to 2665
    $parcelQuery = new MgFeatureQueryOptions();
    $parcelQuery->SetFilter("FeatId = 2665");
    $layer = $map->GetLayers()->GetItem('QBParcels');
    $featureReader = $layer->SelectFeatures($parcelQuery);
    $parcelGeometryData = $featureReader->GetGeometry('Data');
    // Convert the AGF binary data to MgGeometry.
    $agfReaderWriter = new MgAgfReaderWriter();
    $parcelGeometry = 
    // Create a filter to select the desired features. Combine
    // a basic filter and a spatial filter.
    $queryOptions = new MgFeatureQueryOptions();
    $queryOptions->SetFilter("FeatId = 2665");
    $queryOptions->SetSpatialFilter('Geometry', $parcelGeometry,
    // Get the features from the feature source,
    // turn it into a selection, then save the selection as XML.
    $layer = $map->GetLayers()->GetItem('QBParcels');
    $featureReader = $layer->SelectFeatures($queryOptions);
    $layer = $map->GetLayers()->GetItem('QBParcels');
    $selection = new MgSelection($map);
    $selection->AddFeatures($layer, $featureReader, 0);
    $selectionXml = $selection->ToXml();
    echo $selectionXml;
  catch (MgException $e)
    echo $e->GetMessage();
    echo $e->GetDetails();

However, I can get the sessionid, but I cannot get the mapname. You
mentioned about that I should call the php until the map is loaded. Would
you please tell me where should I put my code?

Also, did you know what the 'Data' is in the php code? Is it also geometry
field name?

Thank you very much.



View this message in context: http://osgeo-org.1560.x6.nabble.com/Select-specific-layer-and-feature-by-passing-value-to-flexible-layout-AIMS2014-tp5055669p5058197.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

More information about the mapguide-users mailing list