百度地图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}..\n14 .步行导航;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}..\n14 .查看步行导航.\n17 .18 .查看你所在位置的全景图;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:略)