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: 

zoomToScale after Search

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
janossycs
1657 Views, 4 Replies

zoomToScale after Search

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

 

4 REPLIES 4
Message 2 of 5
janossycs
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 

Message 3 of 5
pg002a
in reply to: janossycs

Can you describe what you exactly chnaged in those files?

Message 4 of 5
janossycs
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;
  }                              
}
Message 5 of 5
pg002a
in reply to: janossycs

Thanks, really works!

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

Post to forums  

Autodesk Design & Make Report