function map($x, $y) { $user_request_model = M('User_request'); $user_request_row = $user_request_model->where(array('token' => $this->_get('token'), 'msgtype' => 'text', 'uid' => $this->data['FromUserName']))->find(); if (!(strpos($user_request_row['keyword'], '附近') === FALSE)) { $user = M('Nearby_user')->where(array('token' => $this->_get('token'), 'uid' => $this->data['FromUserName']))->find(); $keyword = $user['keyword']; $radius = 2000; $str = file_get_contents(C('site_url') . '/map.php?keyword=' . urlencode($keyword) . '&x=' . $x . '&y=' . $y); $array = json_decode($str); $map = array(); foreach ($array as $key => $vo) { $map[] = array($vo->title, $key, rtrim(C('site_url'), '/') . '/tpl/static/images/home.jpg', $vo->url); } return array($map, 'news'); } else { import("Home.Action.MapAction"); $mapAction = new MapAction(); if (!(strpos($user_request_row['keyword'], '开车去') === FALSE) || !(strpos($user_request_row['keyword'], '坐公交') === FALSE) || !(strpos($user_request_row['keyword'], '步行去') === FALSE)) { if (!(strpos($user_request_row['keyword'], '步行去') === FALSE)) { $companyid = str_replace('步行去', '', $user_request_row['keyword']); if (!$companyid) { $companyid = 1; } return $mapAction->walk($x, $y, $companyid); } if (!(strpos($user_request_row['keyword'], '开车去') === FALSE)) { $companyid = str_replace('开车去', '', $user_request_row['keyword']); if (!$companyid) { $companyid = 1; } return $mapAction->drive($x, $y, $companyid); } if (!(strpos($user_request_row['keyword'], '坐公交') === FALSE)) { $companyid = str_replace('坐公交', '', $user_request_row['keyword']); if (!$companyid) { $companyid = 1; } return $mapAction->bus($x, $y, $companyid); } } else { switch ($user_request_row['keyword']) { case '最近的': return $mapAction->nearest($x, $y); break; } } } }
public function map($x, $y) { $transUrl = 'http://api.map.baidu.com/ag/coord/convert?from=2&to=4&x=' . $x . '&y=' . $y; $json = Http::fsockopenDownload($transUrl); if ($json == false) { $json = file_get_contents($transUrl); } $arr = json_decode($json, true); $x = base64_decode($arr['x']); $y = base64_decode($arr['y']); $user_request_model = M('User_request'); $urWhere = array('token' => $this->_get('token'), 'msgtype' => 'text', 'uid' => $this->data['FromUserName']); $urWhere['time'] = array('gt', time() - 5 * 60); $user_request_row = $user_request_model->where($urWhere)->find(); if (!(strpos($user_request_row['keyword'], '附近') === FALSE)) { $user = M('Nearby_user')->where(array('token' => $this->_get('token'), 'uid' => $this->data['FromUserName']))->find(); $keyword = $user['keyword']; $radius = 2000; $map = new baiduMap($keyword, $x, $y); $str = $map->echoJson(); $array = json_decode($str); $map = array(); foreach ($array as $key => $vo) { $map[] = array($vo->title, $key, rtrim($this->siteUrl, '/') . '/tpl/static/images/home.jpg', $vo->url); } if ($map) { return array($map, 'news'); } else { $str = file_get_contents($this->siteUrl . '/map.php?keyword=' . urlencode($keyword) . '&x=' . $x . '&y=' . $y); $array = json_decode($str); $map = array(); foreach ($array as $key => $vo) { $map[] = array($vo->title, $key, rtrim($this->siteUrl, '/') . '/tpl/static/images/home.jpg', $vo->url); } if ($map) { return array($map, 'news'); } else { return array('附近信息无法调出,请稍候再试一下(关键词' . $keyword . ',坐标:' . $x . '-' . $y . ')', 'text'); } } } else { if (!(strpos($this->fun, 'lbsNews') === FALSE)) { $lbsImgClass = new lbsImgNews($this->token, $this->data['FromUserName'], $this->siteUrl); return $lbsImgClass->news($x, $y); } import("Home.Action.MapAction"); $mapAction = new MapAction(); if (!(strpos($user_request_row['keyword'], '开车去') === FALSE) || !(strpos($user_request_row['keyword'], '坐公交') === FALSE) || !(strpos($user_request_row['keyword'], '步行去') === FALSE)) { if (!(strpos($user_request_row['keyword'], '步行去') === FALSE)) { $companyid = str_replace('步行去', '', $user_request_row['keyword']); if (!$companyid) { $companyid = 1; } return $mapAction->walk($x, $y, $companyid); } if (!(strpos($user_request_row['keyword'], '开车去') === FALSE)) { $companyid = str_replace('开车去', '', $user_request_row['keyword']); if (!$companyid) { $companyid = 1; } return $mapAction->drive($x, $y, $companyid); } if (!(strpos($user_request_row['keyword'], '坐公交') === FALSE)) { $companyid = str_replace('坐公交', '', $user_request_row['keyword']); if (!$companyid) { $companyid = 1; } return $mapAction->bus($x, $y, $companyid); } } else { switch ($user_request_row['keyword']) { default: return $this->companyMap(); break; case '最近的': return $mapAction->nearest($x, $y); break; } } } }