/** * Calculates the center of an array of coordiantes * * @param GMapCoord[] $coords * @return GMapCoord * @author fabriceb * @since 2009-05-02 */ public static function getCenterCoord($coords) { $bounds = GMapBounds::getBoundsContainingCoords($coords); return $bounds->getCenterCoord(); }
/** * * @param GMapMarker[] $markers array of MArkers * @param float $margin margin factor for the bounds * @return GMapBounds * @author fabriceb * @since 2009-05-02 * **/ public static function getBoundsContainingMarkers($markers, $margin = 0) { $coords = array(); foreach($markers as $marker) { array_push($coords, $marker->getGMapCoord()); } return GMapBounds::getBoundsContainingCoords($coords, $margin); }
$bounds_twice_france = $bounds_france->getZoomOut(1); $t->is($bounds_twice_france->__toString(),'((37.9006227258, -11.42578125), (55.8621662593, 14.94140625))','France zoomed out once works'); $t->diag('->getBoundsContainingAllBounds Test'); $bounds = GMapBounds::createFromString('((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))'); $big_bounds = GMapBounds::getBoundsContainingAllBounds(array($bounds)); $t->is($big_bounds->__toString(),$bounds->__toString(),'le bounds qui englobe un bounds cest le meme'); $big_bounds = GMapBounds::getBoundsContainingAllBounds(array($bounds,$bounds_france)); $t->is($big_bounds->__toString(),$bounds_france->__toString(),'le bounds qui contient paris et la france cest la france'); $t->diag('->getBoundsContainingCoords Test'); $coord_1 = new GMapCoord(48.7887996681, 2.23631017383); $coord_2 = new GMapCoord(48.9243326339, 2.44230382617); $coord_3 = new GMapCoord(48.8, 2.4); $bounds_12 = GMapBounds::getBoundsContainingCoords(array($coord_1,$coord_2)); $bounds_123 = GMapBounds::getBoundsContainingCoords(array($coord_1,$coord_2,$coord_3)); $t->is($bounds_12->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the coords is the rectangle containing the two coords'); $t->is($bounds_123->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the coords is the rectangle containing the three coords'); $t->diag('->getBoundsContainingMarkers Test'); $marker_1 = new GMapMarker(48.7887996681, 2.23631017383); $marker_2 = new GMapMarker(48.9243326339, 2.44230382617); $marker_3 = new GMapMarker(48.8, 2.4); $bounds_12 = GMapBounds::getBoundsContainingMarkers(array($marker_1,$marker_2)); $bounds_123 = GMapBounds::getBoundsContainingMarkers(array($marker_1,$marker_2,$marker_3)); $t->is($bounds_12->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the markers is the rectangle containing the two markers'); $t->is($bounds_123->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the markers is the rectangle containing the three markers'); $t->diag('->getBoundsFromCenter Test');