public static function getBoundsOfCoordinates($coords, $margin = 0.0)
    {
        $minLat = 1000;
        $maxLat = -1000;
        $minLng = 1000;
        $maxLng = -1000;
        foreach ($coords as $coord) {
            if (!($coord instanceof LatLng)) {
                throw new InvalidParamException('$coords must be an array of "' . LatLng::className() . '" objects');
            }
            /* @var $coord LatLng */
            $minLat = min($minLat, $coord->getLat());
            $maxLat = max($maxLat, $coord->getLat());
            $minLng = min($minLng, $coord->getLng());
            $maxLng = max($maxLng, $coord->getLng());
        }

        if ($margin > 0) {
            $minLat = $minLat - $margin * ($maxLat - $minLat);
            $minLng = $minLng - $margin * ($maxLng - $minLng);
            $maxLat = $maxLat + $margin * ($maxLat - $minLat);
            $maxLng = $maxLng + $margin * ($maxLng - $minLng);
        }
        return new self([
            'southWest' => new LatLng(['lat' => $minLat, 'lng' => $minLng]),
            'northEast' => new LatLng(['lat' => $maxLat, 'lng' => $maxLng])
        ]);
    }
public static function getBoundsOfCoordinates($coords, $margin = 0.0)
    {
        $minLat = 1000;
        $maxLat = -1000;
        $minLng = 1000;
        $maxLng = -1000;
        foreach ($coords as $coord) {
            if (!($coord instanceof LatLng)) {
                throw new InvalidParamException('$coords must be an array of "' . LatLng::className() . '" objects');
            }
            /* @var $coord LatLng */
            $minLat = min($minLat, $coord->getLat());
            $maxLat = max($maxLat, $coord->getLat());
            $minLng = min($minLng, $coord->getLng());
            $maxLng = max($maxLng, $coord->getLng());
        }

        if ($margin > 0) {
            $minLat = $minLat - $margin * ($maxLat - $minLat);
            $minLng = $minLng - $margin * ($maxLng - $minLng);
            $maxLat = $maxLat + $margin * ($maxLat - $minLat);
            $maxLng = $maxLng + $margin * ($maxLng - $minLng);
        }
        return new self([
            'southWest' => new LatLng(['lat' => $minLat, 'lng' => $minLng]),
            'northEast' => new LatLng(['lat' => $maxLat, 'lng' => $maxLng])
        ]);
    }
public static function getBoundsOfCoordinates ( $ coords , $ margin = 0.0 ) { $ minLat = 1000 ; $ maxLat = - 1000 ; $ minLng = 1000 ; $ maxLng = - 1000 ; foreach ( $ coords as $ coord ) { if ( ! ( $ coord instanceof LatLng ) ) { throw new InvalidParamException ( '$coords must be an array of "' . LatLng :: className ( ) . '" objects' ) ; } /* @var $coord LatLng */ $ minLat = min ( $ minLat , $ coord -> getLat ( ) ) ; $ maxLat = max ( $ maxLat , $ coord -> getLat ( ) ) ; $ minLng = min ( $ minLng , $ coord -> getLng ( ) ) ; $ maxLng = max ( $ maxLng , $ coord -> getLng ( ) ) ; } if ( $ margin > 0 ) { $ minLat = $ minLat - $ margin * ( $ maxLat - $ minLat ) ; $ minLng = $ minLng - $ margin * ( $ maxLng - $ minLng ) ; $ maxLat = $ maxLat + $ margin * ( $ maxLat - $ minLat ) ; $ maxLng = $ maxLng + $ margin * ( $ maxLng - $ minLng ) ; } return new self ( [ 'southWest' => new LatLng ( [ 'lat' => $ minLat , 'lng' => $ minLng ] ) , 'northEast' => new LatLng ( [ 'lat' => $ maxLat , 'lng' => $ maxLng ] ) ] ) ; }
Returns the boundaries of an array of LatLng objects
@param LatLng[] $coords
@param float $margin
@throws \yii\base\InvalidParamException
@return LatLngBounds
Returns the boundaries of an array of LatLng objects