public function testRenderWithBound()
 {
     $coordinate1 = new Coordinate(-1.1, -2.1, false);
     $coordinate1->setJavascriptVariable('foo');
     $coordinate2 = new Coordinate(1.1, 2.1, true);
     $coordinate2->setJavascriptVariable('bar');
     $bound = new Bound($coordinate1, $coordinate2);
     $bound->setJavascriptVariable('baz');
     $this->assertSame('baz = new google.maps.LatLngBounds(foo, bar);' . PHP_EOL, $this->boundHelper->render($bound));
 }
 /**
  * Add a coordinate to the polyline.
  *
  * Available prototypes:
  *  - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate)
  *  - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true)
  *
  * @throws \Ivory\GoogleMap\Exception\OverlayException If the coordinate is not valid.
  */
 public function addCoordinate()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof Coordinate) {
         $this->coordinates[] = $args[0];
     } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) {
         $coordinate = new Coordinate($args[0], $args[1]);
         if (isset($args[2]) && is_bool($args[2])) {
             $coordinate->setNoWrap($args[2]);
         }
         $this->coordinates[] = $coordinate;
     } else {
         throw OverlayException::invalidPolylineCoordinate();
     }
 }
Beispiel #3
0
 /**
  * Sets the circle center.
  *
  * Available prototypes:
  *  - function setCenter(Ivory\GoogleMap\Base\Coordinate $center)
  *  - function setCenter(double $latitude, double $longitude, boolean $noWrap = true)
  *
  * @throws \Ivory\GoogleMap\Exception\OverlayException If the center is not valid (prototypes).
  */
 public function setCenter()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof Coordinate) {
         $this->center = $args[0];
     } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) {
         $this->center->setLatitude($args[0]);
         $this->center->setLongitude($args[1]);
         if (isset($args[2]) && is_bool($args[2])) {
             $this->center->setNoWrap($args[2]);
         }
     } else {
         throw OverlayException::invalidCircleCenter();
     }
 }
Beispiel #4
0
 /**
  * Sets the marker position.
  *
  * Available prototypes:
  * - function setPosition(Ivory\GoogleMap\Base\Coordinate $position = null)
  * - function setPosition(double $latitude, double $longitude, boolean $noWrap = true)
  *
  * @throws \Ivory\GoogleMap\Exception\OverlayException If the position is not valid.
  */
 public function setPosition()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof Coordinate) {
         $this->position = $args[0];
     } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) {
         $this->position->setLatitude($args[0]);
         $this->position->setLongitude($args[1]);
         if (isset($args[2]) && is_bool($args[2])) {
             $this->position->setNoWrap($args[2]);
         }
     } elseif (!isset($args[0])) {
         $this->position = null;
     } else {
         throw OverlayException::invalidMarkerPosition();
     }
 }
Beispiel #5
0
 /**
  * Sets the north east coordinate.
  *
  * Available prototypes:
  *  - function setNorthEast(Ivory\GoogleMap\Base\Coordinate $northEast = null)
  *  - function setNorthEast(double $latitude, double $longitude, boolean $noWrap = true)
  *
  * @throws \Ivory\GoogleMap\Exception\BaseException If the north east coordinate is not valid (prototypes).
  */
 public function setNorthEast()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof Coordinate) {
         $this->northEast = $args[0];
     } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) {
         if ($this->northEast === null) {
             $this->northEast = new Coordinate();
         }
         $this->northEast->setLatitude($args[0]);
         $this->northEast->setLongitude($args[1]);
         if (isset($args[2]) && is_bool($args[2])) {
             $this->northEast->setNoWrap($args[2]);
         }
     } elseif (!isset($args[0])) {
         $this->northEast = null;
     } else {
         throw BaseException::invalidBoundNorthEast();
     }
 }
 /**
  * Sets the geocoder request coordinate
  *
  * Available prototypes:
  *  - function setCoordinate(\Ivory\GoogleMap\Base\Coordinate $coordinate = null)
  *  - function setCoordinate(double $latitude, double $longitude, boolean $noWrap = true)
  *
  * @throws \Ivory\GoogleMap\Exception\GeocodingException If the coordinate is not valid (prototypes).
  */
 public function setCoordinate()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof Coordinate) {
         $this->coordinate = $args[0];
     } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) {
         if (!$this->hasCoordinate()) {
             $this->coordinate = new Coordinate();
         }
         $this->coordinate->setLatitude($args[0]);
         $this->coordinate->setLongitude($args[1]);
         if (isset($args[2]) && is_bool($args[2])) {
             $this->coordinate->setNoWrap($args[2]);
         }
     } elseif (!isset($args[0])) {
         $this->coordinate = null;
     } else {
         throw GeocodingException::invalidGeocoderRequestCoordinate();
     }
     return $this;
 }
 public function testRender()
 {
     $coordinate = new Coordinate(1.1, 2.1, true);
     $coordinate->setJavascriptVariable('foo');
     $this->assertSame('foo = new google.maps.LatLng(1.1, 2.1, true);' . PHP_EOL, $this->coordinateHelper->render($coordinate));
 }
 /**
  * Adds an origin to the request.
  *
  * Available prototypes:
  * - function addOrigin(string $destination)
  * - function addOrigin(Ivory\GoogleMap\Base\Coordinate $destination)
  * - function addOrigin(double $latitude, double $longitude, boolean $noWrap)
  *
  * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the origin is not valid (prototypes).
  */
 public function addOrigin()
 {
     $args = func_get_args();
     if (isset($args[0]) && is_string($args[0])) {
         $this->origins[] = $args[0];
     } elseif (isset($args[0]) && $args[0] instanceof Coordinate) {
         $this->origins[] = $args[0];
     } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) {
         $origin = new Coordinate();
         $origin->setLatitude($args[0]);
         $origin->setLongitude($args[1]);
         if (isset($args[2]) && is_bool($args[2])) {
             $origin->setNoWrap($args[2]);
         }
         $this->origins[] = $origin;
     } else {
         throw DistanceMatrixException::invalidDistanceMatrixRequestOrigin();
     }
 }
 /**
  * @expectedException \Ivory\GoogleMap\Exception\BaseException
  * @expectedExceptionMessage The no wrap coordinate property must be a boolean value.
  */
 public function testNoWrapWithInvalidNoWrap()
 {
     $this->coordinate->setNoWrap('foo');
 }
 /**
  * Renders a coordinate.
  *
  * @param \Ivory\GoogleMap\Base\Coordinate $coordinate The coordinate.
  *
  * @return string The JS output.
  */
 public function render(Coordinate $coordinate)
 {
     return sprintf('%s = new google.maps.LatLng(%s, %s, %s);' . PHP_EOL, $coordinate->getJavascriptVariable(), $coordinate->getLatitude(), $coordinate->getLongitude(), json_encode($coordinate->isNoWrap()));
 }