Infrastructure Map Server Developer

Reply
Active Member
janossycs
Posts: 9
Registered: ‎06-20-2012
Message 1 of 5 (1,025 Views)
Accepted Solution

zoomToScale after Search

1025 Views, 4 Replies
02-13-2013 03:04 AM

Hello,

 

When I use the search widget [Map Server 2012 (v 2.3.0.4202)], the selected item will be in the map window with zooming into its size.

The widget uses the following function for it (in the fusion/widgets/search/search.templ file):

function CellClicked(sel)
{
    var map = GetParent().Fusion.getMapByName(mapName);
    map.setSelection(sel, true);
}

 Tath's fine, but after it, I'd like to zoom the map scale to e.g. 1300, like this way:

function CellClicked(sel)
{
    var map = GetParent().Fusion.getMapByName(mapName);
    map.setSelection(sel, true);
    map.zoomToScale(1300);
}

But this is not good, because the setSelection is calling AJAX requsets. When does The existing zoomToScale() function need to run, when the response is ready or when the map status is ready? Or need another function instead of the setSelection() function? To modify the core (fusionSF-compressed.js) is a little bit difficult for me.

Any suggestion?

 

best regards,

Csaba

 

Active Member
janossycs
Posts: 9
Registered: ‎06-20-2012
Message 2 of 5 (977 Views)

Re: zoomToScale after Search

02-25-2013 01:40 AM in reply to: janossycs

Hello,

 

I’ve found a solution for my problem. Originaly, my target was not just see the selected item,

but the environment. So I modified the GetSelectionProperties.php and the SaveSelection.php.

Because the extent of the object is calculating in this scripts, so I increased the extent.

 

best regards,

Csaba 

Valued Contributor
pg002a
Posts: 58
Registered: ‎08-03-2010
Message 3 of 5 (660 Views)

Re: zoomToScale after Search

04-18-2013 11:00 PM in reply to: janossycs

Can you describe what you exactly chnaged in those files?

Active Member
janossycs
Posts: 9
Registered: ‎06-20-2012
Message 4 of 5 (653 Views)

Re: zoomToScale after Search

04-19-2013 12:41 AM in reply to: pg002a

I have modified the extent properties of the result object (lower left and upper right coordinates). If the search result is a small object, the map will be in the minimum scale factor is 1, then you will see nothing in the map and need to zooming manually. It is not so comfortable.

In the \fusion\layers\MapGuide\php\SaveSelection.php you can find this part (before):

$result->hasSelection = true;
$result->extents = NULL;
if($getExtents)
   {
     $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
     $oExtents = $selection->GetExtents($featureService);
     if ($oExtents)
      {
         $oMin = $oExtents->GetLowerLeftCoordinate();
         $oMax = $oExtents->GetUpperRightCoordinate();
         $result->extents->minx = $oMin->GetX();
         $result->extents->miny = $oMin->GetY();
         $result->extents->maxx = $oMax->GetX();
         $result->extents->maxy = $oMax->GetY();
      }
   }

 After (in my case, the minimum width is 70 then the scale factor will be approximately 1000):

$result->hasSelection = true;
$result->extents = NULL;
if($getExtents)  {
  $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
  $oExtents = $selection->GetExtents($featureService);
                
  if ($oExtents) {
     $oMin = $oExtents->GetLowerLeftCoordinate();
     $oMax = $oExtents->GetUpperRightCoordinate();
                      
     $oWidth =  (($oMax->GetX())-($oMin->GetX()));
     $oHeight = (($oMax->GetY())-($oMin->GetY()));
                                           
     if ($oWidth < 70) {
        If ($oWidth > $oHeight) {
           $oWidth = 70;
           $oHeight = 50;
        }
        else {
           $oWidth = 70;
           $oHeight = 70;
        }
     }

     $result->extents->minx = ($oMin->GetX())-2*$oWidth;
     $result->extents->miny = ($oMin->GetY())-1.5*$oHeight;
     $result->extents->maxx = ($oMax->GetX())+2*$oWidth;
     $result->extents->maxy = ($oMax->GetY())+1.5*$oHeight;
  }                              
}
Valued Contributor
pg002a
Posts: 58
Registered: ‎08-03-2010
Message 5 of 5 (645 Views)

Re: zoomToScale after Search

04-19-2013 02:07 AM in reply to: janossycs

Thanks, really works!

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
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

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

Ask the Community