Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param string|PositionAbstract $southwest Southwest point of the rectangle
  * @param string|PositionAbstract $northeast Northeast point of the rectangle
  * @param array $options Array of rectangle options {@link http://code.google.com/apis/maps/documentation/javascript/reference.html#RectangleOptions}
  * @return Rectangle
  */
 public function __construct($southwest, $northeast, array $options = null)
 {
     if ($southwest instanceof \PHPGoogleMaps\Core\PositionAbstract) {
         $this->southwest = $southwest->getLatLng();
     } else {
         $geocode_result = \PHPGoogleMaps\Service\Geocoder::geocode($southwest, true);
         if ($geocode_result instanceof \PHPGoogleMaps\Core\PositionAbstract) {
             $this->southwest = $geocode_result;
         } else {
             throw new \PHPGoogleMaps\Core\GeocodeException($geocode_result);
         }
     }
     if ($northeast instanceof \PHPGoogleMaps\Core\PositionAbstract) {
         $this->northeast = $northeast->getLatLng();
     } else {
         $geocode_result = \PHPGoogleMaps\Service\Geocoder::geocode($northeast, true);
         if ($geocode_result instanceof \PHPGoogleMaps\Core\PositionAbstract) {
             $this->northeast = $geocode_result;
         } else {
             throw new \PHPGoogleMaps\Service\GeocodeException($geocode_result);
         }
     }
     if ($options) {
         unset($options['map'], $options['bounds']);
         $this->options = $options;
     }
 }
Exemplo n.º 2
0
 /**
  * Add a waypoint
  *
  * @param string|PositionAbstract $waypoint The waypoint
  * @param boolean $stopover
  */
 public function addWaypoint($waypoint, $stopover = true)
 {
     if ($waypoint instanceof \PHPGoogleMaps\Core\PositionAbstract) {
         $this->request_options['waypoints'][] = array('location' => $waypoint->getLatLng());
     } else {
         if (($geocode_result = \PHPGoogleMaps\Service\Geocoder::geocode($waypoint, true)) instanceof \PHPGoogleMaps\Core\PositionAbstract) {
             $this->request_options['waypoints'][] = array('location' => $geocode_result->getLatLng());
         } else {
             throw new \PHPGoogleMaps\Service\GeocodeException($geocode_result);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Set map center
  *
  * @param string|PositionAbstract $center Location of the center. Can be a
  *                                location or an object that extends PositionAbstract.
  * @return boolean
  */
 public function setCenter($center)
 {
     if ($center instanceof \PHPGoogleMaps\Core\PositionAbstract) {
         $this->center = $center->getLatLng();
         return true;
     }
     $geocode_result = \PHPGoogleMaps\Service\Geocoder::geocode((string) $center);
     if ($geocode_result instanceof \PHPGoogleMaps\Service\GeocodeResult) {
         $this->center = $geocode_result->getLatLng();
         return true;
     }
     return false;
 }