微信公众号开发之LBS
来源:互联网 发布:穿越火线数据异常 编辑:程序博客网 时间:2024/05/17 02:33
百度地图Web服务api:http://lbsyun.baidu.com/index.php?title=webapi测距步行导航全景图天气
1.测距
Route Matrix API v2.0:http://lbsyun.baidu.com/index.php?title=webapi/route-matrix-api-v2
1 case "location"://地理位置信息 2 $location_X = $postObj->Location_X; 3 $location_Y = $postObj->Location_Y; 4 $geourl="http://api.map.baidu.com/routematrix/v2/walking?output=xml" 5 ."&origins=30.281341,120.209929&destinations={$location_X},{$location_Y}" 6 ."&ak=f6UkU0QqVAhABUeGKSxZBCeb"; 7 $apistr = file_get_contents($geourl); 8 $apiobj = simplexml_load_string($apistr); 9 $distanceobj = $apiobj->result->distance->value;//距离10 $durationobj = $apiobj->result->duration->text;//时间11 $label = $postObj->Label;12 $contentStr = "你发送的地理位置是:"."\n".$label.",\n"."经度是:".$location_Y.",\n"."纬度是:".$location_X13 .",\n"."你到我们店铺还需要步行{$distanceobj}米,大约需要{$durationobj}.";14 break;
2.导航
UPI API:http://lbsyun.baidu.com/index.php?title=uri/api/web(接口说明-》web端-》公交、驾车、步行导航)
1 case "location"://地理位置信息 2 $location_X = $postObj->Location_X;//纬度 3 $location_Y = $postObj->Location_Y;//经度 4 $geourl="http://api.map.baidu.com/routematrix/v2/walking?output=xml" 5 ."&origins=30.281341,120.209929&destinations={$location_X},{$location_Y}" 6 ."&ak=f6UkU0QqVAhABUeGKSxZBCeb"; 7 $apistr = file_get_contents($geourl); 8 $apiobj = simplexml_load_string($apistr); 9 $distanceobj = $apiobj->result->distance->value;//距离10 $durationobj = $apiobj->result->duration->text;//时间11 $label = $postObj->Label;12 $contentStr = "你发送的地理位置是:"."\n".$label.",\n"."经度是:".$location_Y.",\n"."纬度是:".$location_X13 .",\n"."你到我们店铺还需要步行{$distanceobj}米,大约需要{$durationobj}."."\n"14 ."<a href=\"http://api.map.baidu.com/direction?origin=latlng:{$location_X},{$location_Y}"15 ."|name:{$label}&destination=latlng:30.281341,120.209929|name:艮山西路233号新东升市场"16 ."&mode=walking&output=html®ion=杭州&src=yourCompanyName|yourAppName\">步行导航</a>";17 break;
3.全景图
UPI API:http://lbsyun.baidu.com/index.php?title=uri/api/web(接口说明-》web端-》全景服务)
1 case "location"://地理位置信息 2 $location_X = $postObj->Location_X;//纬度 3 $location_Y = $postObj->Location_Y;//经度 4 $geourl="http://api.map.baidu.com/routematrix/v2/walking?output=xml" 5 ."&origins=30.281341,120.209929&destinations={$location_X},{$location_Y}" 6 ."&ak=f6UkU0QqVAhABUeGKSxZBCeb"; 7 $apistr = file_get_contents($geourl); 8 $apiobj = simplexml_load_string($apistr); 9 $distanceobj = $apiobj->result->distance->value;//距离10 $durationobj = $apiobj->result->duration->text;//时间11 $label = $postObj->Label;12 $contentStr = "你发送的地理位置是:"."\n".$label.",\n"."经度是:".$location_Y.",\n"."纬度是:".$location_X13 .",\n"."你到我们店铺还需要步行{$distanceobj}米,大约需要{$durationobj}."."\n"14 ."<a href=\"http://api.map.baidu.com/direction?origin=latlng:{$location_X},{$location_Y}"15 ."|name:{$label}&destination=latlng:30.281341,120.209929|name:艮山西路233号新东升市场"16 ."&mode=walking&output=html®ion=杭州&src=yourCompanyName|yourAppName\">查看步行导航</a>"."\n"17 ."<a href=\"http://api.map.baidu.com/pano/?x={$location_Y}&y={$location_X}&lc=0&ak=f6UkU0QqVAhABUeGKSxZBCeb\">"18 ."查看你所在位置的全景图</a>";19 break;
4.天气
车联网API:http://developer.baidu.com/map/wiki/index.php?title=car/api/weather(接口说明-》天气查询)
1 case "天气": 2 $weatherurl="http://api.map.baidu.com/telematics/v3/weather?location=杭州&ak=f6UkU0QqVAhABUeGKSxZBCeb"; 3 $apistr = file_get_contents($weatherurl); 4 $apiobj = simplexml_load_string($apistr); 5 $placeobj = $apiobj->results->currentCity;//读取城市名 6 $todayobj = $apiobj->results->weather_data->date;//读取当前时间 7 $weatherobj = $apiobj->results->weather_data->weather;//读取天气 8 $windobj = $apiobj->results->weather_data->wind;//读取风力 9 $temobj = $apiobj->results->weather_data->temperature;//读取温度10 $pm25obj = $apiobj->results->pm25;//读取pm2.511 $contentStr = "{$placeobj}{$todayobj},天气:{$weatherobj},风力:{$windobj},温度:{$temobj},pm2.5:{$pm25obj}.";12 break;
还可以通过地理位置返回天气信息。(case "location":略)
阅读全文
0 0
- 微信公众号开发之LBS
- 微信公众平台开发之LBS定位
- 微信公众平台开发之LBS等API使用-php语言(六)
- 微信公众号开发之接入
- 微信开发之公众号支付
- 微信公众号开发之数据库
- 微信公众号开发之微信支付开发
- 深入浅出微信公众平台实战开发(微网站、LBS云、Api接口调用、服务号高级接口)
- 微信公众平台开发视频教程(微网站、LBS云、Api接口调用、服务号高级接口)
- 微信公众号开发之微信买单
- 微信公众平台开发实战(08) 基于地理信息的服务(LBS)
- 微信公众号开发之对接微信公众平台
- 微信公众号开发
- 微信公众号开发
- 微信公众号开发
- 微信公众号开发
- 微信公众号开发
- 微信公众号开发
- 深入理解人工神经网络——从原理到实现
- 微信公众号开发之文本消息自动回复
- 微信公众号开发之语音消息识别
- c++11多线程编程(二):joining和detaching 线程
- PE文件结构及其加载机制(三)
- 微信公众号开发之LBS
- 51nod 1681 公共祖先【树状数组】【DFS序】
- 微信公众号开发之数据库
- 洛谷 1631 序列合并 堆 解题报告
- Java开发之文件上传
- centos7之firewalld规则详解(二)
- Java开发之Servlet生命周期
- Java开发之@PostConstruct和@PreConstruct注解
- Java开发之Servlet之间的跳转