• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Autodesk MapGuide Developer

    Reply
    Active Member
    janossycs
    Posts: 9
    Registered: ‎06-20-2012
    Accepted Solution

    zoomToScale after Search

    518 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

     

    Please use plain text.
    Active Member
    janossycs
    Posts: 9
    Registered: ‎06-20-2012

    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 

    Please use plain text.
    Valued Contributor
    pg002a
    Posts: 55
    Registered: ‎08-03-2010

    Re: zoomToScale after Search

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

    Can you describe what you exactly chnaged in those files?

    Please use plain text.
    Active Member
    janossycs
    Posts: 9
    Registered: ‎06-20-2012

    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;
      }                              
    }
    Please use plain text.
    Valued Contributor
    pg002a
    Posts: 55
    Registered: ‎08-03-2010

    Re: zoomToScale after Search

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

    Thanks, really works!

    Please use plain text.