/** * @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; }