Problems with oMapNavigator and oMap commands

Javier Mart ín javiermartin at NETSYSTEMSI.COM
Mon Nov 8 00:47:28 PST 2004


Hi all,
  I am trying to add a search feature into the application
generated by maplab. The problem is the main map doesn't make zoomin to
object looked for, but not show any error. Only change the scalebar,
nothing more. The code seems works well, find the point looked for, but
it doesn't make zoomin. The Code:

if ($http_form_vars["nombre"])
{
  $nombre = $http_form_vars["nombre"];
  echo $nombre;
  $oldextent = $oMapSession->oMap->extent;
  $capa = $oMapSession->oMap->getLayerByname("puntos");
  $capa->queryByAttributes("NOMCALLE",$nombre,MS_SINGLE);
  if ($capa->getNumResults() > 0)
  {
      echo "Ha encontrado";
      $oresult = $capa->getResult(0);
      $capa->open();
      $oshape = $capa->getShape($oresult->tileindex,$oresult->shapeindex);
      $oextent = $oshape->bounds;
      //echo " ".$oextent->minx." ".$oextent->miny." ";
      //echo $oextent->maxx." ".$oextent->maxy." ";

      $oextent->set("minx",$oextent->minx - 10);
      $oextent->set("miny",$oextent->miny - 10);
      $oextent->set("maxx",$oextent->maxx + 10);
      $oextent->set("maxy",$oextent->maxy + 10);

      $oshape->free();
      $capa->close();

      $sessWidth = $oMapSession->oMap->width;
      $sessHeight = $oMapSession->oMap->height;


$px1=$sessWidth/($oldextent->maxx-$oldextent->minx)*($oextent->minx-$oldextent->minx);


$px2=$sessWidth/($oldextent->maxx-$oldextent->minx)*($oextent->maxx-$oldextent->minx);


$py1=$sessHeight/($oldextent->maxy-$oldextent->miny)*($oldextent->maxy-$oextent->maxy);


$py2=$sessHeight/($oldextent->maxy-$oldextent->miny)*($oldextent->maxy-$oextent->miny);



      $pxX=($px1 + $px2)/2;
      $pyY=($py1 + $py2)/2;
      echo " pxX: ".$pxX." pyY: ".$pyY." ";
      echo " Exe MapNavigator ";
      $oMapNavigator->zoomPoint(8, $pxX, $pyY); // I have tried with
                                                // this, with the same result
      $img = $oMapSession->oMap->draw();
      $img->saveWebImage(); // The image saved by this command
                            // is the image produced by
                            // "$oMapNavigator->zoomPoint(8, $pxX, $pyY);",
                            // but why don't change map image,
                            // and only change the scale bar????
      // And this, with the same result:
             //$point = ms_newPointObj();
             //$point->setXY($pxX,$pyY);
             //$oMapSession->oMap->zoompoint(8,$point,400,300,$oldextent);
}
}

Why map image never change with oMapNavigator or oMap command? . Maybe i
need something more?.

My System:
   PHP 4.3.7
   MapLab 2.2
   MapServer/PHPMapScript 4.2.5



More information about the MapServer-users mailing list