Example #1
0
 /**
  * Returns the center coordinates of the boundaries of an array of Markers
  *
  * @param Marker[] $markers
  *
  * @return LatLng
  */
 public static function getCenterCoordinates($markers)
 {
     $bounds = LatLngBounds::getBoundsOfMarkers($markers);
     return $bounds->getCenterCoordinates();
 }
Example #2
0
 /**
  * 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;
 }
 /**
  * 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);
 }
Example #4
0
 /**
  * @return LatLngBounds
  */
 public function getBoundsFromCenterAndZoom()
 {
     return LatLngBounds::getBoundsFromCenterAndZoom($this->center, $this->zoom, $this->width, $this->height);
 }
Example #5
0
 /**
  * Returns the center of bounds
  * @return \dosamigos\google\maps\LatLng
  */
 public function getCenterOfBounds()
 {
     return LatLngBounds::getBoundsOfPolygons([$this])->getCenterCoordinates();
 }
Example #6
0
 /**
  * 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();
 }