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: 

Zoom to selection

5 REPLIES 5
Reply
Message 1 of 6
007dolenc
2221 Views, 5 Replies

Zoom to selection

In codebehinde or js I need to select object and zoom to selected object. I use in JS:

 

     function SetSelectionXML(selectionXml) {
          var Fusion = window.top.Fusion;
          var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
          if (mapWidget && mapWidget.isMapLoaded() && selectionXml.length > 170)  {
              mapWidget.setSelection(selectionXml, true);
              
          }
      }

But I have problem with zoom to selection object, because is zoomig to different place.

 

In loadMap.php have I also change code to:

$minScale = "5000";
$maxScale = 'infinity';  // as MDF's VectorScaleRange::MAX_MAP_SCALE
if($minElt->length > 0 && $minElt->length > 1)
        $minScale = $minElt->item(0)->nodeValue;

 

Can you please help me?

 

Tenx!

5 REPLIES 5
Message 2 of 6
gluckett
in reply to: 007dolenc

If you are using .NET you need to call a server side page sending the MAPNAME, SESSION, LAYER, and "where clause" to receive the XML of the selected features.  

 

You then use Javascript to take that XML to select the features and zoom to it.

 

Javascript:

 

var mapWidget = Fusion.getWidgetById('Map');

 mapWidget.setSelection(myXMLReturnedFromServer, true);

 

the "true" actually zooms to the selected featue.

 

regards

gordon

 

Message 3 of 6
Daniel.Du
in reply to: 007dolenc

This blog may be helpful for you.

 

To Implement ZoomToSelection in Fusion Viewer MapGuide Enterprise 2011

http://www.cnblogs.com/junqilian/archive/2010/06/04/1751679.html



Daniel Du
Developer Technical Services
Autodesk Developer Network

Message 4 of 6
swimming123
in reply to: 007dolenc

In some of case, we want to "zoom to selection"; this "selection" is not by mouse click; it's by "enter an attribute value" or "by the calculation result which match some specific attribute column value". In this case we need an example how to use "setSelection: function(selText, ZoomTo) function, what is the input parameters?

Message 5 of 6
gluckett
in reply to: 007dolenc

You need the manually select the features programatically.  For example you want the road with an ID of 20

 

You pass the SESSIONID, MAPNAME, KEY (20), KEYNAME (ID), LAYER (ROADS)'

 

to: http://forums.autodesk.com/autodesk/attachments/autodesk/88/3201/1/GETSELECTIONXML.php.txt

 

but you should use AJAX (try jQuery - http://api.jquery.com/jQuery.ajax/)

 

once the XML is returned from the page, you can call the javascript call

 

 mapWidget.setSelection(selectionXml, true);

 

The "TRUE" will zoom to selected (unless it is a point - AIMS 2013 and AIMS 2014 changed so it just pans to points now and doesn't zoom)

 

 

 

Message 6 of 6
francisco.rojas
in reply to: gluckett

Also this post helps a lot, I tried it and it did works fine, this code is oriented to invoke a ZoomToSelection given by an external request from an External System, this post includes source code for either the Widget and Server Sive API like the example Gordon posted.

 

http://autodesk.typepad.com/beyondthebox/2012/09/application-integration-with-autodesk-infrastructur...

 

Regards.

 

 

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

Post to forums  

Autodesk Design & Make Report