/** * 「自己」模式地图数据 * * @return array */ private function getPersonalMapData() { // check login status if (!User::isLogin()) { return ['status' => 'Not login']; } // get here list $list = Here::usered(User::getInfo()->id)->orderBy('date')->get()->toArray(); $coord = $address = $date = $data = []; for ($i = 0, $n = count($list); $i < $n; $i++) { $coord[$list[$i]['location']] = [$list[$i]['lng'], $list[$i]['lat']]; $address[$list[$i]['location']] = sprintf('%s %s', $list[$i]['province'], $list[$i]['location']); $date[$list[$i]['location']] = $list[$i]['date']; $data[$i] = [$list[$i]['location'], [[['name' => $list[$i - 1]['location'] ?? []], ['name' => $list[$i]['location']]]]]; } $map = map_mode(); for ($i = 0, $n = count($list); $i < $n; $i++) { $map = map_mode($list[$i]['country']); if ('world' === $map) { break; } } // return data return compact('map', 'coord', 'address', 'date', 'data'); }