[mapguide-users] MGOS 4 Final Release and GetLayers
David Bowen
dbowenrci at gmail.com
Thu May 28 08:27:35 PDT 2026
Hello Gordon,
Let me know if the following is what you're looking for. The script calls
the class Mg_initialize,, with the relevant sections below.
init gets called when the class SelectionTools first gets initiated. the
function getMap gets called in the line you called out.
function init( $MapName, $SessionId ) {
$webconfig_ini ="PATH/OSGeo/MapGuide/Web/www/webconfig.ini";
$mgMapID = $MapName;
$mgSessionId = $SessionId;
try {
MgInitializeWebTier( $webconfig_ini );
$userInfo = new MgUserInformation( $mgSessionId );
$this->siteConnection = new MgSiteConnection();
$this->siteConnection->Open( $userInfo );
$this->resourceService = $this->siteConnection->CreateService(
MgServiceType::ResourceService );
$this->featureService = $this->siteConnection->CreateService(
MgServiceType::FeatureService );
$this->map = new MgMap( $this->siteConnection );
$this->map->Open( $mgMapID );
} catch ( MgException $e ) {
echo $e->GetMessage();
echo $e->GetDetails();
exit();
}
}
function getMap() {
return $this->map;
}
On Thu, May 28, 2026 at 9:15 AM Gordon Luckett <
gordon.luckett at arrowgeomatics.com> wrote:
> I would be curious about the line:
>
> $this->MapGuideObject->getMap();
>
> Share this definition?
>
> On Mon, May 25, 2026 at 1:35 PM David Bowen via mapguide-users <
> mapguide-users at lists.osgeo.org> wrote:
>
>> We're updating our application from using an MVC framework to being a PHP
>> only application. We're getting an unexpected error when running a spatial
>> query that looks for corresponding data, from a specified layer, that falls
>> within a set distance of the geocoded coordinates. This function worked as
>> expected in the MVC framework and the only code change, for this section of
>> code, is how the MG_initialize library is loaded.
>>
>> Going through the function step-by-step, it appears that it's failing
>> when it attempts to retrieve the layers from MapGuide. Instead of returning
>> something, it's returning NULL. This triggers a Fusion error, where 1 of 2
>> different error messages are displayed.
>>
>> The first error message is:
>> Failed to retrieve message for "MgFileNotFoundException". Failed to
>> retrieve message for "MgFileIoErrNo". - MgInitializeWebTier line 155 file
>> C:\Workspace\mg-4.0\MgDev\Web\src\WebSupport\InitializeWebTier.cpp -
>> MgInitializeWebTierInternal line 116 file
>> C:\Workspace\mg-4.0\MgDev\Web\src\WebSupport\InitializeWebTier.cpp -
>> MgResources.LoadResources line 388 file
>> C:\Workspace\mg-4.0\MgDev\Common\Foundation\System\Resources.cpp -
>> MgResources.ParseFile line 632 file
>> C:\Workspace\mg-4.0\MgDev\Common\Foundation\System\Resources.cpp -
>> ByteSourceFileImpl.LoadFile line 127 file
>> C:\Workspace\mg-4.0\MgDev\Common\Foundation\System\ByteSourceFileImpl.cpp
>>
>> The second error message is:
>> Fatal error: Uncaught TypeError: extract(): Argument #1 ($array) must be
>> of type array, string given in PATH\map\view\page.php:116 Stack trace: #0
>> PATH\map\view\page.php(116): extract() #1
>> PATH\maptools\sel_action.php(154): require_once('...') #2
>> PATH\maptools\sel_action.php(56): Sel_Action->selectionReport_ql() #3
>> PATH\maptools\sel_action.php(290): Sel_Action->__construct() #4 {main}
>> thrown in PATH\map\view\page.php on line 116
>>
>> The script is:
>> function __construct( $config ) {
>> $mapName = $config[ 'mapname' ];
>> $mgSessionID = $config[ 'mapsession' ];
>> $this->mgMapID = $mapName;
>> $this->mgSessionId = $mgSessionID;
>> //Initialize a MapGuide object instance
>> require_once('../library/mapguide/Mg_initialize.php');
>> $this->MapGuideObject = new Mg_initialize();
>> $this->MapGuideObject->init( $this->mgMapID, $this->mgSessionId );
>> }
>>
>> function getSelection() {
>> $myMap = $this->MapGuideObject->getMap();
>> $session = $this->mgSessionId;
>> $mapName = $this->mgMapID;
>> $objkeys = '';
>> $errorMsg = null;
>> $siteConnection = $this->MapGuideObject->getSiteConnection();
>> // Get an instance of the Resource and Mapping Services and use
>> them to open the map and initialize a selection object.
>> $resourceSrvc = $this->MapGuideObject->getResourceService();
>> $featureSrvc = $this->MapGuideObject->getFeatureService();
>> //Get selected map layers.
>> $sel = new MgSelection( $myMap );
>> $sel->Open( $resourceSrvc, $mapName );
>> $this->originalSel = $sel->ToXml();
>> // this is where it appears to fail
>> $selLayers = $sel->GetLayers();
>>
>> //script continues but likely not relevant
>> }
>>
>> Any input would be greatly appreciated.
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapguide-users/attachments/20260528/a74e50ac/attachment.htm>
More information about the mapguide-users
mailing list