Beispiel #1
0
 /**
  * Set max bounds option.
  *
  * @param LatLngBounds|array $bounds Max bounds.
  *
  * @return $this
  * @see    http://leafletjs.com/reference.html#map-maxbounds
  *
  * @throws InvalidArgumentException If invalid bounds given.
  */
 public function setMaxBounds($bounds)
 {
     if (is_array($bounds)) {
         $bounds = LatLngBounds::fromArray($bounds);
     }
     Assertion::isInstanceOf($bounds, 'Netzmacht/LeafletPHP/Type/LatLngBounds');
     return $this->setOption('maxBounds', $bounds);
 }
Beispiel #2
0
 /**
  * Create latlng from a string reprensentation.
  *
  * @param string $latLng Comma separated list of latlng values.
  *
  * @return LatLng
  * @throws InvalidArgumentException If LatLng could not be created.
  */
 public static function fromString($latLng)
 {
     list($latitude, $longitude, $altitude) = explode(',', $latLng);
     Assertion::numeric($latitude);
     Assertion::numeric($longitude);
     Assertion::nullOrNumeric($altitude);
     return new static($latitude, $longitude, $altitude);
 }
Beispiel #3
0
 /**
  * Add a latitude longitude position.
  *
  * This method differs from the Leaflet JS API! Instead of passing the shape as second argument you can define
  * the index of the ring.
  *
  * @param LatLng|array|string $latLng    LatLng coordinate.
  * @param int                 $ringIndex The index of the ring.
  *
  * @return $this
  */
 public function addLatLng($latLng, $ringIndex = 0)
 {
     if (is_scalar($latLng)) {
         $latLng = LatLng::fromNative($latLng);
     }
     Assertion::isInstanceOf($latLng, 'Netzmacht\\LeafletPHP\\Value\\LatLng');
     $ringIndex = (int) $ringIndex;
     $this->latLngs[$ringIndex][] = $latLng;
     return $this;
 }