setTemplate('search/map', 'listings'); $this->listView = ListFactory::MAP; } public function onSubmitAction() { $countOnly = $this->filter->countOnly; $this->loadList($countOnly); if (! $countOnly) { $this->respond('items', $this->prepareItemsToMap()); $this->respond('list', $this->getList()); $this->respond('pages', $this->pages); } $this->respond('total', $this->total); return $this->getActionResponse(); } public function data() { $data = parent::data(); if (! is_array($data)) { return $data; } $data['itemsToMap'] = $this->prepareItemsToMap(); return $data; } public function loadList($countOnly = false) { parent::loadList($countOnly); if (! $countOnly) { $list = $this->getList(); $list->start = ($this->filter->page <= 1 ? 1 : (($this->filter->page - 1) * $this->pageSize) + 1); $list->showBanners(false); } } public function prepareItemsToMap(): array { $items = []; # todo reduce size foreach ($this->items as $item) { $items[$item['id']] = $item; } if ($this->filter->fixedListActive) { foreach ($this->getFixed()->loadFixedItems() as $item) { $items[$item['id']] = $item; } } return $items; } /** * List block * @return MapList|mixed */ public function getList() { return parent::getList(); } public function prepareSearchQuery(): array { $query = parent::prepareSearchQuery(); # только с корректно указанными координатами $query['filter']['addr_lat'] = ['!=', 0]; return $query; } }