[mapguide-users] Re: Select features on map load
benjanmin
erictsn at gmail.com
Tue May 17 05:17:28 EDT 2011
I may elaborate what is my setting ...
Firstly I renamed the fusion/index.html to index.php and put the following
code to the index.php
<?php
$layer = $_GET['layer'];
$objectid = $_GET['objectid'];
?>
and then created a file selectbyparameters.php to the folder /fusion/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>load map</title>
</head>
<?php
$layer = $_GET['layer'];
$objectid = $_GET['objectid'];
$sessionId = $_GET['SESSION'];
$mapName = $_GET['MAPNAME'];
$webconfigFilePath = "c:\\Program
Files\\Autodesk\\MapGuideEnterprise2010\\Server\\Bin\\serverconfig.ini";
MgInitializeWebTier ($webconfigFilePath);
$userInfo = new MgUserInformation($sessionId);
$siteConnection = new MgSiteConnection();
$siteConnection->Open($userInfo);
$map = new MgMap($siteConnection);
$map->Open($mapName);
$selection = new MgSelection($map);
$layer = $map->GetLayers()->GetItem($layerName);
//Turn on Layer and GroupLayer if they're off
$grouplayer = $layer->GetGroup();
$queryOptions = new MgFeatureQueryOptions();
if($layer->IsVisible() == false)
{ $layer->setVisible(true);
$layer->ForceRefresh();
$map->Save($resourceService);
}
if($grouplayer->IsVisible() == false)
{ $grouplayer->setVisible(true);
$map->Save($resourceService);
}
$filter = "objectid = $objectid";
$queryOptions->SetFilter("$filter");
$featureReader = $layer->SelectFeatures($queryOptions);
$selection->AddFeatures($layer, $featureReader, 0);
$selectionXml = $selection->ToXml();
$featureReader->Close();
?>
</body>
</html>
Finally I modified the ApplicationDefinition.xml to initial the
selectbyparameters.php
<Widget xsi:type="WidgetType">
<Name>TaskPane</Name>
<Type>TaskPane</Type>
<StatusItem/>
<Extension>
<MenuContainer>TaskContextMenu</MenuContainer>
<InitialTask>selectbyparameters.php</InitialTask>
</Extension>
</Widget>
Who can tell me? Is it correct? Thanks.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Select-features-on-map-load-tp3174763p6372324.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list