Zoom to Multiple Search Results
From Geomoose
In your query.php file replace the
for($rx = 0; $rx < $numResults; $rx++) { }
loop with:
for($rx = 0; $rx < $numResults; $rx++) {
$res = $queryLayer->getResult($rx);
$aRes = $queryLayer->getFeature($res->shapeindex);
$abounds = $aRes->bounds;
if($rx == 0){
$theMinX = $abounds->minx;
$theMaxX = $abounds->maxx;
$theMinY = $abounds->miny;
$theMaxY = $abounds->maxy;
}
if($theMinX > $abounds->minx){
$theMinX = $abounds->minx;
}
if($theMaxX < $abounds->maxx){
$theMaxX = $abounds->maxx;
}
if($theMinY > $abounds->miny){
$theMinY = $abounds->miny;
}
if($theMaxY < $abounds->maxy){
$theMaxY = $abounds->maxy;
}
array_push($resultFeatures, $aRes);
}
then replace
if(($totalResults == 1 and $firstResult != false) or ($totalResults >= 1 and $zoomToFirst == true)) {
$bounds = $firstResult->bounds;
printf('GeoMOOSE.zoomToExtent(%f,%f,%f,%f);', $bounds->minx, $bounds->miny, $bounds->maxx, $bounds->maxy);
}
with
if($totalResults > 0){
printf('GeoMOOSE.zoomToExtent(%f,%f,%f,%f);', $theMinX, $theMinY, $theMaxX, $theMaxY);
}
Finally, place these lines
$theMinX = null; $theMaxX = null; $theMinY = null; $theMaxY = null;
just above the line
for($la = 0; $la < sizeof($query_layers); $la++) {
This should allow the zoom to be adjusted to the maximum bounds of your search results. Best of luck! Feel free to ask any questions on the mailing list.