Infrastructure Map Server Developer

Reply
Member
FMSUSC
Posts: 4
Registered: ‎08-20-2010
Message 1 of 3 (654 Views)

Highlight Object API

654 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
Posts: 269
Registered: ‎10-06-2008
Message 2 of 3 (644 Views)

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
FMSUSC
Posts: 4
Registered: ‎08-20-2010
Message 3 of 3 (626 Views)

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.

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community