コード例 #1
0
 /**
  * Returns the boundaries of an array of Polygon objects
  * @param Polygon[] $polygons array of Polygons
  * @param float $margin margin factor for the bounds
  * @return LatLngBounds
  * @throws \yii\base\InvalidParamException
  */
 public static function getBoundsOfPolygons($polygons, $margin = 0.0)
 {
     $coords = [];
     /** @var Polygon $polygon */
     foreach ($polygons as $polygon) {
         if (!$polygon instanceof Polygon) {
             throw new InvalidParamException('"$polygons" must be an array of "' . Polygon::className() . '" objects');
         }
         // merge LatLng arrays
         $coords = ArrayHelper::merge($coords, $polygon->paths);
     }
     return LatLngBounds::getBoundsOfCoordinates($coords, $margin);
 }
コード例 #2
0
ファイル: Polyline.php プロジェクト: bmwx591/yii2-google-maps
 /**
  * Returns the center of bounds of the
  * @return \dosamigos\google\maps\LatLng
  */
 public function getCenterOfBounds()
 {
     $path = ArrayHelper::getValue($this->options, 'path');
     return is_array($path) && !empty($path) ? LatLngBounds::getBoundsOfCoordinates($path)->getCenterCoordinates() : null;
 }
コード例 #3
0
ファイル: LatLng.php プロジェクト: bmwx591/yii2-google-maps
 /**
  * Calculates the center of an array of coordinates according to its bounds
  *
  * @param LatLng[] $coords
  *
  * @return LatLng
  */
 public static function getCenterOfBounds($coords)
 {
     $bounds = LatLngBounds::getBoundsOfCoordinates($coords);
     return $bounds->getCenterCoordinates();
 }