[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
index.html 

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

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

var link =
"http://10.10.200.104/mapserver2014/fusion/widgets/FeatureInspector/GetSelectionXML2.php?SESSION="
+ sessionid + "&MAPNAME=" + mapname;

//alert(link);

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;
//alert(selectionXml);
}
}
if (mapWidget && mapWidget.isMapLoaded()) {
xmlhttp.open("GET","http://10.10.200.104/mapserver2014/fusion/widgets/FeatureInspector/GetSelectionXML2.php?SESSION="
+ sessionid + "&MAPNAME=" + mapname, true);
xmlhttp.send();
}
            
}



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...

 <?php
  include('../../layers/MapGuide/php/Common.php');
 
  $args = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST : $_GET;
  $sessionId = $args['SESSION'];
  $mapName = $args['MAPNAME'];
 
  try
  {
 
    // Initialize the Web Extensions and connect to the Server 
    // using the Web Extensions session identifier
 
    MgInitializeWebTier ($webconfigFilePath);
 
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
 
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
 
    // 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);
    $featureReader->ReadNext();
    $parcelGeometryData = $featureReader->GetGeometry('Data');
 
    // Convert the AGF binary data to MgGeometry.
 
    $agfReaderWriter = new MgAgfReaderWriter();
    $parcelGeometry = 
      $agfReaderWriter->Read($parcelGeometryData);
 
    // 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,
MgFeatureSpatialOperations::Inside);
 
    // 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.

Sincerely,

Reno




--
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