Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Highlight Object API

2 REPLIES 2
Reply
Message 1 of 3
FMSUSC
927 Views, 2 Replies

Highlight Object API

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

2 REPLIES 2
Message 2 of 3
jackie.ng
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

Message 3 of 3
FMSUSC
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.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report