Infrastructure Map Server Developer

Infrastructure Map Server Developer

Reply
Member
4 Posts
1 Kudo
Registered: ‎08-20-2010
Post 1 of 3

Highlight Object API

691 Views, 2 Replies
08-27-2010 04:05 PM

Hello,

 

I want to create a function that when I click the item ID on the right pane, which is a website created by PHP, the object on the map will hightlight.

 

Could someone know what's the procedure of operating APIs. Which API function I can use to create a hightlight effect.

 

Thanks

Valued Mentor
284 Posts
24 Kudos
Registered: ‎10-06-2008
Post 2 of 3

Re: Highlight Object API

08-29-2010 05:54 PM in reply to: FMSUSC

Create a MgSelection, build your query whose filter matches your item ID. Call MgFeatureService.SelectFeatures with this query. Feed the MgFeatureReader to your MgSelection (using AddFeatures() method).

 

Then call ToXml() on your MgSelection to get the XML selection string, and write that out as the parameter to your client-side javascript SetSelectionXML() viewer API call.

 

- Jackie

Member
4 Posts
1 Kudo
Registered: ‎08-20-2010
Post 3 of 3

Re: Highlight Object API

09-01-2010 02:45 PM in reply to: FMSUSC

Thank you.

 

I tried according to your procedure but still have some problem. However, according to my code, the Javascript show a error message "syntax error /../../mapviewernet/setselection.aspx There must be exactly one feature in the set", and the map not hight light the item. I attached here if some one can figure out the problem will be a great help.

 

------------- my code ---------------------------------------------------

<?php
 try
 {
      // Initialize
     MgInitializeWebTier('C:\Program Files\Autodesk\MapGuideEnterprise2010\WebServerExtensions\www\webconfig.ini');
     // Establish a connection with a MapGuide site.
     $user = new MgUserInformation('Administrator', 'admin');
     $siteConnection = new MgSiteConnection();
     $siteConnection->Open($user);
     // Create a session repository
     $site = $siteConnection->GetSite();
     $sessionID = $site->CreateSession();
     $user->SetMgSessionId($sessionID);
     // Get an instance of the required services.
     $featureService=$siteConnection->CreateService(2);

     // Get a runtime map from a map definition

     $map = new MgMap();
     $query=new MgFeatureQueryOptions();
     $query->SetFilter("KEY='P9092'");

     $DataResId= new MgResourceIdentifier('Library://admin/Data/alldonorplaquesshp.FeatureSource');
     $FeatureReader=$featureService->SelectFeatures($DataResId, "alldonorplaquesshp",$query);
     $layer=$map->GetLayers()->GetItem('Donor Plaques');
     $selection=new Mgselection($map);
     $selection->AddFeatures($layer,$FeatureReader,0);
     $selectionXml=$selection->ToXml();
     echo "<p id='Xml'>$selectionXml</p>";
 }
 catch (MgException $e)
 {
     echo "ERROR: " . $e->GetMessage() . "n";
     echo $e->GetDetails() . "n";
     echo $e->GetStackTrace() . "n";
 }
?>

 

<script language="javascript" type="text/javascript">
  var getXml=document.getElementById('Xml').innerHTML;
  document.write(getXml);
  opener.parent.parent.mapFrame.SetSelectionXML(getXml);
</script>

------------------ end -------------------------

I can get a string of $selectionXml, something like "9QEAAA==", is the xml correct?

 

Thank you all.

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!