[mapguide-users] Selection Help

Love, Bev (Capita Symonds) Bev.Love at capita.co.uk
Mon Nov 10 10:06:36 EST 2008


Afternoon all,

 

I'm hoping someone can help me out, with getting a selection to appear
on the map.

 

I'm using JavaScript to perform an Ajax call to PHP, which runs the
following code to generate the selection XML:

(Note: $_itkconfig is a global array used to store any site
configuration details, and folder locations).

 

       global $_itkconfig, $session;

        //common file from MapGuide Open Source

        require_once('..\data\common.php');   

         

        //need to include the MapGuide Open Source constants file for
PHP        

 
require_once($_itkconfig['site']['mapObject']['viewerDir'].'constants.ph
p');

         

        try {

            //Initialise the web extensions

 
MgInitializeWebTier($_itkconfig['site']['mapObject']['webConfigFilePath'
]);

            

            //create a variable to hold the MapGuide user details and
then create a MapGuide site object

            $mapGuideUserInfo = new
MgUserInformation($_itkconfig['site']['mapObject']['userName'],
$_itkconfig['site']['mapObject']['password']);

        }

        catch(MgException $e) {

            print "Can not create the MapGuide User.<br />";

            die();

        }

 

        try {

             //create a MapGuide site connection object

             $mapGuideSiteConnection = new MgSiteConnection();

             $mapGuideSiteConnection->Open($mapGuideUserInfo);

             

             //obtain an instance of the MapGuide services

             $mapGuideResourceService =
$mapGuideSiteConnection->CreateService(MgServiceType::ResourceService);

             $mapGuideFeatureService =
$mapGuideSiteConnection->CreateService(MgServiceType::FeatureService);

        }

        catch(MgException $e) {

            print "MapGuide Connection Error<br />\n";

            print "ERROR: ".$e->GetMessage("eng")."\n";

            print $e->GetStackTrace("eng")."\n";

        }

 

        try {

            $mapGuideMap = new MgMap();

            

            $mapGuideResourceId = new
MgResourceIdentifier("Library://IHMS/Maps/Illuminate_Development_Map.Map
Definition");

            $mapGuideMap->Create($mapGuideResourceService,
$mapGuideResourceId, "Illuminate_Development_Map");

            

        }

        catch(MgException $e) {

            print "Can not connect to the Map.<br />\n";

            print "ERROR: ".$e->GetMessage("eng")."\n";

            print $e->GetStackTrace("eng")."\n";

        }

 

        try {

            $layer =
$mapGuideMap->GetLayers()->GetItem("Districts_No_Theme_Lay");

                        

            $featureResId = new
MgResourceIdentifier($layer->GetFeatureSourceID());

            

            $class = $layer->GetFeatureClassName();

                        

            $layerId = $layer->GetObjectId();

            

            $layerQuery = new MgFeatureQueryOptions();

            $layerQuery->SetFilter("ID = 2265");

            

            $featureReader =
$mapGuideFeatureService->SelectFeatures($featureResId, $class,
$layerQuery);

            

            $selection = new MgSelection($mapGuideMap);

            $selection->AddFeatures($layer, $featureReader, 0);

            

            $selectionXml = $selection->ToXml();

            

            return $selectionXml;            

        }

        catch(MgException $e) {

            print "Unable to handle the layer query data.<br />\n";

            print "ERROR: ".$e->GetMessage("eng")."\n";

            print $e->GetStackTrace("eng")."\n";

        }

 

 

The selection XML is then passed back to my JavaScript function which
calls:

parent.parent.SetSelectionXML('selection XML');

parent.parent.Refresh();

(Note: this code is called from the task frame).

 

I have to put the XML within quotes within SetSelectionXML otherwise
Firebug throws an error!!

 

This is where the fun starts. When I run the code nothing on the map is
selected, but the map's status bar tells me that one feature has been
selected, and the Properties pane changes from saying "None Selected" to
having the Name and Value column headings appear but no data underneath
them. So it is like something has been selected but is just not
appearing on the map.

 

At first I thought it was because the layer I am trying to select on is
contained within a folder in the map. So I stripped the map back down,
so it just contained the one layer, but I still get the same thing.

 

I then did a bit of a test. If I select the feature I am trying to
select, and get the XML for it and compare that XML to the XML being
generated by my PHP code - I've discovered that the layer ID's do not
match:

Layer ID when I select the feature off the map
<Layer id="1c1db7be-0000-1000-8003-0017a4ce58b0">

Layer ID from generated XML from my PHP code                <Layer
id="42ea8db8-0000-1000-8001-0017a4ce58b0">

 

They're almost identical aside from the first 8 characters, and four
further characters in the second to last block.

 

Has anyone come across this before, and know of a fix. Or is the error
occurring because of an error in my PHP code??

 

Thanks in advance J

 

Bev

 

 


This email and any attachment are intended solely for the addressee, are strictly confidential and may be legally privileged. If you are not the intended recipient any reading, dissemination, copying or any other use or reliance is prohibited. If you have received this email in error please notify the sender immediately by email and then permanently delete the email. Copyright reserved.

All communications, incoming and outgoing, may be recorded and are monitored for legitimate business purposes. 

The security and reliability of email transmission cannot be guaranteed. It is the recipient’s responsibility to scan this e-mail and any attachment for the presence of viruses. 

The Capita Group plc and its subsidiaries ("Capita") exclude all liability for any loss or damage whatsoever arising or resulting from the receipt, use or transmission of this email. 

Any views or opinions expressed in this email are those of the author only.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20081110/1c93ac50/attachment.html


More information about the mapguide-users mailing list