<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Kristen ITC";
        panose-1:3 5 5 2 4 2 2 3 2 2;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Kristen ITC";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Kristen ITC";
        color:windowtext;}
span.objectbox
        {mso-style-name:objectbox;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-GB link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>Afternoon
all,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>I’m
hoping someone can help me out, with getting a selection to appear on the map.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>I’m
using JavaScript to perform an Ajax call to PHP, which runs the following code
to generate the selection XML:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>(Note:
$_itkconfig is a global array used to store any site configuration details, and
folder locations).<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
global $_itkconfig, $session;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
//common file from MapGuide Open Source<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
require_once('..\data\common.php'); <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
//need to include the MapGuide Open Source constants file for
PHP <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
require_once($_itkconfig['site']['mapObject']['viewerDir'].'constants.php');<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
try {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
//Initialise the web extensions<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
MgInitializeWebTier($_itkconfig['site']['mapObject']['webConfigFilePath']);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
//create a variable to hold the MapGuide user details and then create a
MapGuide site object<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideUserInfo = new
MgUserInformation($_itkconfig['site']['mapObject']['userName'],
$_itkconfig['site']['mapObject']['password']);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
catch(MgException $e) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "Can not create the MapGuide User.<br />";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
die();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
try {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
//create a MapGuide site connection object<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideSiteConnection = new MgSiteConnection();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideSiteConnection->Open($mapGuideUserInfo);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
//obtain an instance of the MapGuide services<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideResourceService =
$mapGuideSiteConnection->CreateService(MgServiceType::ResourceService);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideFeatureService =
$mapGuideSiteConnection->CreateService(MgServiceType::FeatureService);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
catch(MgException $e) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "MapGuide Connection Error<br />\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "ERROR: ".$e->GetMessage("eng")."\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print $e->GetStackTrace("eng")."\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
try {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideMap = new MgMap();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideResourceId = new MgResourceIdentifier("Library://IHMS/Maps/Illuminate_Development_Map.MapDefinition");<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$mapGuideMap->Create($mapGuideResourceService, $mapGuideResourceId,
"Illuminate_Development_Map");<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
catch(MgException $e) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "Can not connect to the Map.<br />\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "ERROR: ".$e->GetMessage("eng")."\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print $e->GetStackTrace("eng")."\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
try {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$layer =
$mapGuideMap->GetLayers()->GetItem("Districts_No_Theme_Lay");<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$featureResId = new MgResourceIdentifier($layer->GetFeatureSourceID());<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$class = $layer->GetFeatureClassName();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$layerId = $layer->GetObjectId();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$layerQuery = new MgFeatureQueryOptions();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$layerQuery->SetFilter("ID = 2265");<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$featureReader = $mapGuideFeatureService->SelectFeatures($featureResId,
$class, $layerQuery);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$selection = new MgSelection($mapGuideMap);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$selection->AddFeatures($layer, $featureReader, 0);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
$selectionXml = $selection->ToXml();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
return $selectionXml;
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
catch(MgException $e) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "Unable to handle the layer query data.<br />\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print "ERROR: ".$e->GetMessage("eng")."\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
print $e->GetStackTrace("eng")."\n";<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>The
selection XML is then passed back to my JavaScript function which calls:<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>parent.parent.SetSelectionXML('selection
XML’);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>parent.parent.Refresh();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>(Note:
this code is called from the task frame).<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>I
have to put the XML within quotes within SetSelectionXML otherwise Firebug
throws an error!!<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>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.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>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.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>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:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'>Layer
ID when I select the feature off the map <span
class=objectbox><Layer
id="1c1db7be-0000-1000-8003-0017a4ce58b0"><o:p></o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>Layer ID from generated XML from my PHP
code <Layer
id="42ea8db8-0000-1000-8001-0017a4ce58b0"><o:p></o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'><o:p> </o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>They’re almost identical aside from
the first 8 characters, and four further characters in the second to last
block.<o:p></o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'><o:p> </o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>Has anyone come across this before, and
know of a fix. Or is the error occurring because of an error in my PHP code??<o:p></o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'><o:p> </o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>Thanks in advance </span></span><span
class=objectbox><span style='font-size:12.0pt;font-family:Wingdings'>J</span></span><span
class=objectbox><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p></o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'><o:p> </o:p></span></span></p>
<p class=MsoNormal><span class=objectbox><span style='font-size:12.0pt;
font-family:"Calibri","sans-serif"'>Bev</span></span><span style='font-size:
12.0pt;font-family:"Calibri","sans-serif"'><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p>
</div>
<BR>
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.<BR>
<BR>
All communications, incoming and outgoing, may be recorded and are monitored for legitimate business purposes. <BR>
<BR>
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. <BR>
<BR>
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. <BR>
<BR>
Any views or opinions expressed in this email are those of the author only.<BR>
</body>
</html>