示例#1
0
 /**
  * Sets the marker icon.
  *
  * Available prototypes:
  *  - function setIcon(Ivory\GoogleMap\Overlays\MarkerImage $markerImage = null)
  *  - function setIcon(string $url = null)
  *
  * @throws \Ivory\GoogleMap\Exception\OverlayException If the icon is not valid.
  */
 public function setIcon()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof MarkerImage) {
         if ($args[0]->getUrl() === null) {
             throw OverlayException::invalidMarkerIconUrl();
         }
         $this->icon = $args[0];
     } elseif (isset($args[0]) && is_string($args[0])) {
         if ($this->icon === null) {
             $this->icon = new MarkerImage();
         }
         $this->icon->setUrl($args[0]);
     } elseif (!isset($args[0])) {
         $this->icon = null;
     } else {
         throw OverlayException::invalidMarkerIcon();
     }
 }