[mapguide-users] MGOS 4 Final Release and GetLayers

David Bowen dbowenrci at gmail.com
Mon May 25 10:34:58 PDT 2026


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapguide-users/attachments/20260525/8bfab82f/attachment.htm>


More information about the mapguide-users mailing list