Infrastructure Map Server Developer

Infrastructure Map Server Developer

New Member
Posts: 1
Registered: ‎04-21-2011
Message 1 of 6 (1,501 Views)

Zoom to selection

1501 Views, 5 Replies
04-21-2011 01:47 AM

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


     function SetSelectionXML(selectionXml) {
          var 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?



Valued Mentor
Posts: 426
Registered: ‎10-10-2003
Message 2 of 6 (1,471 Views)

Re: Zoom to selection

05-01-2011 09:08 AM 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.




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

 mapWidget.setSelection(myXMLReturnedFromServer, true);


the "true" actually zooms to the selected featue.





ADN Support Specialist
Posts: 276
Registered: ‎12-23-2008
Message 3 of 6 (1,372 Views)

Re: Zoom to selection

08-10-2011 03:52 AM in reply to: 007dolenc

This blog may be helpful for you.


To Implement ZoomToSelection in Fusion Viewer MapGuide Enterprise 2011

Daniel Du
Developer Technical Services
Autodesk Developer Network

Valued Contributor
Posts: 87
Registered: ‎04-12-2012
Message 4 of 6 (943 Views)

Re: Zoom to selection

04-01-2013 10:28 AM 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?

Valued Mentor
Posts: 426
Registered: ‎10-10-2003
Message 5 of 6 (868 Views)

Re: Zoom to selection

04-23-2013 07:03 PM in reply to: 007dolenc

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






but you should use AJAX (try jQuery -


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)




Active Member
Posts: 9
Registered: ‎08-29-2005
Message 6 of 6 (587 Views)

Re: Zoom to selection

09-06-2013 09:57 AM 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.





Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.