微信获取地理位置 微信 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 location 关键字TYPE =location 就可以 微信 事件分成 文本 位置 时间 图片神马的! 看下各个事件的关键字就好了。!!也可以用CASE 'location' switch($type) { case "event"; if($customevent == "subscribe") {$contentStr = "感谢关注"} break; case "image" $contentStr ="图片很棒"; break; case "location"; $contentStr ="{$latitude},{longitude}"; break; case "text"; switch($keyword) {case "1" $contentStr="1" break; case "2" $contentStr ="2" break; default; $contentStr= "hi";} break; } $msgType = "text"; $resultStr = sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$contentStr); echo $resultStr; }else { http://mp.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E5%9C%B0%E7%90%86%E4%BD%8D%E7%BD%AE 现在是用微信借口已经得到传过来的信息了private function locationPro(){ //测试 $arrayli = $this->weObj->getRevGeo(); //计算最大最小经纬度 $range = 180 / pi() * 1 / 6372.797; //里面的 1 就代表搜索范围为1km之内 $lngR = $range / cos($arrayli[x] * pi() / 180); $maxLat = $arrayli[y] + $range;//最大纬度 $minLat = $arrayli[y] - $range;//最小纬度 $maxLng = $arrayli[x] + $lngR;//最大经度 $minLng = $arrayli[x] - $lngR;//最小经度 $this->weObj->text("您现在的位置为: ".$arrayli[label]." "."经度为:".$arrayli[x]."纬度".$arrayli[y])->reply(); //测试 $this->selectStores($maxLat,$minLat,$maxLng,$minLng); } 然后根据这个经纬度,在数据库里找经纬度在最大最小范围内的数据,private function selectStores($maxLat,$minLat,$maxLng,$minLng){ //测试 $store_model = M("store"); // 实例化User对象 $condition['latitude'] = array('between','$maxLat','$minLat'); $condition['longitude'] = array('between','$maxLng','$minLng'); $condition['_logic'] = 'AND'; $stores=$store_model->where($condition)->select(); }这些的是不是有问题啊 我刚学php,基本的东西都不太懂,求教。 应该就是这样啦,你这还是Thinkphp框架。刚学PHP的话,已经进步很大啦 $condition['latitude'] = array('between','$min_Y,$max_Y'); $condition['longitude'] = array('between','$min_X,$max_X'); $condition['_logic'] = 'AND'; $stores=$store_model->where($condition)->select();//查询范围之间的店铺但是这个查询出错了,查不出要的数据 求php正则匹配3个字符相同的输出yes ecmall 调试模式怎么打开? 有谁搞过pfsense? 一个窗口问题!在线等!!!! php的ftp上传问题 如何用php将中文字符转化为unicode形式(在线等待) oci8函数库怎么调用! 如何判断页面是不是在指定的Frame里呢? PHP本地CURL正常,但是放到SAE上后出现object moved to here phpmailer邮件发送失败:SMTP Error: Could not connect to SMTP host 微信公众平台PHP代码单图文回复无法实现 php+mysql百万级数据如何排序?
switch($type)
{
case "event";
if($customevent == "subscribe")
{$contentStr = "感谢关注"}
break;
case "image"
$contentStr ="图片很棒";
break;
case "location";
$contentStr ="{$latitude},{longitude}";
break;
case "text";
switch($keyword)
{case "1"
$contentStr="1"
break;
case "2"
$contentStr ="2"
break;
default;
$contentStr= "hi";}
break;
}
$msgType = "text";
$resultStr = sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$contentStr);
echo $resultStr;
}else
{
private function locationPro(){ //测试
$arrayli = $this->weObj->getRevGeo();
//计算最大最小经纬度
$range = 180 / pi() * 1 / 6372.797; //里面的 1 就代表搜索范围为1km之内
$lngR = $range / cos($arrayli[x] * pi() / 180);
$maxLat = $arrayli[y] + $range;//最大纬度
$minLat = $arrayli[y] - $range;//最小纬度
$maxLng = $arrayli[x] + $lngR;//最大经度
$minLng = $arrayli[x] - $lngR;//最小经度
$this->weObj->text("您现在的位置为: ".$arrayli[label]." "."经度为:".$arrayli[x]."纬度".$arrayli[y])->reply(); //测试
$this->selectStores($maxLat,$minLat,$maxLng,$minLng);
}
然后根据这个经纬度,在数据库里找经纬度在最大最小范围内的数据,
private function selectStores($maxLat,$minLat,$maxLng,$minLng){ //测试
$store_model = M("store"); // 实例化User对象
$condition['latitude'] = array('between','$maxLat','$minLat');
$condition['longitude'] = array('between','$maxLng','$minLng');
$condition['_logic'] = 'AND';
$stores=$store_model->where($condition)->select();
}
这些的是不是有问题啊 我刚学php,基本的东西都不太懂,求教。
$condition['longitude'] = array('between','$min_X,$max_X');
$condition['_logic'] = 'AND';
$stores=$store_model->where($condition)->select();//查询范围之间的店铺但是这个查询出错了,查不出要的数据