Example #1
0
 /**
  * @param array $marker
  */
 private function createMarker(array $marker)
 {
     if (!array_key_exists('coordinates', $marker)) {
         throw new InvalidArgumentException('Coordinates must be set in every marker');
     }
     $this->addMarker(array_values($marker['coordinates']), isset($marker['animation']) ? $marker['animation'] : false, isset($marker['title']) ? $marker['title'] : null);
     if (array_key_exists('message', $marker)) {
         if (is_array($marker['message'])) {
             $message = array_values($marker['message']);
             $this->setMessage($message[0], $message[1]);
         } else {
             $this->setMessage($marker['message']);
         }
     }
     if (array_key_exists('icon', $marker)) {
         if (is_array($marker['icon'])) {
             $icon = new Marker\Icon($marker['icon']['url']);
             if (array_key_exists('size', $marker['icon'])) {
                 $icon->setSize($marker['icon']['size']);
             }
             if (array_key_exists('anchor', $marker['icon'])) {
                 $icon->setAnchor($marker['icon']['anchor']);
             }
             if (array_key_exists('origin', $marker['icon'])) {
                 $icon->setOrigin($marker['icon']['origin']);
             }
             $this->setIcon($icon);
         } else {
             $this->setIcon($marker['icon']);
         }
     }
     if (array_key_exists('color', $marker)) {
         $this->setColor($marker['color']);
     }
 }
Example #2
0
 /**
  * @param string|Icon $icon
  * @return $this
  * @throws LogicException
  */
 public function setIcon($icon)
 {
     if (!count($this->markers)) {
         throw new LogicException("setIcon must be called after addMarker()");
     }
     end($this->markers);
     // move the internal pointer to the end of the array
     $key = key($this->markers);
     if ($icon instanceof Marker\Icon) {
         $icon->setUrl(is_null($this->iconDefaultPath) ? $icon->getUrl() : $this->iconDefaultPath . $icon->getUrl());
         $this->markers[$key]['icon'] = $icon->getArray();
     } else {
         $this->markers[$key]['icon'] = is_null($this->iconDefaultPath) ? $icon : $this->iconDefaultPath . $icon;
     }
     return $this;
 }