LBS for public account development and lbs for public development
Baidu map Web Service api: http://lbsyun.baidu.com/index.php? Title = webapi
1. Ranging
Route Matrix API v2.0: http://lbsyun.baidu.com/index.php? Title = webapi/route-matrix-api-v2
1 case "location": // location Information 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; // distance from 10 $ durationobj = $ apiobj-> result-> duration-> text; // time 11 $ label = $ postObj-> Label; 12 $ contentStr = "the geographic location you sent is :". "\ n ". $ label. ", \ n ". "longitude is :". $ location_Y. ", \ n ". "latitude :". $ location_X13. ", \ n ". "You still need to walk {$ distanceobj} meters to our shop, about {$ durationobj }. "; 14 break;Ranging
2. Navigation
Upi api: http://lbsyun.baidu.com/index.php? Title = uri/api/web (interface description-web terminal-bus, driving, walking navigation)
1 case "location": // geographic location information 2 $ location_X = $ postObj-> Location_X; // latitude 3 $ location_Y = $ postObj-> Location_Y; // longitude 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; // distance from 10 $ durationobj = $ apiobj-> result-> duration-> text; // time 11 $ label = $ postObj-> Label; 12 $ contentStr = "the geographic location you sent is :". "\ n ". $ label. ", \ n ". "longitude is :". $ lo Cation_Y. ", \ n ". "latitude :". $ location_X13. ", \ n ". "You still need to walk {$ distanceobj} meters to our shop, about {$ 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: xindongsheng market, No. 233, Lushan West Road" 16. "& mode = walking & output = html & region = Hangzhou & src = yourCompanyName | yourAppName \"> walking navigation </a> "; 17 break;Walking navigation
3. Panorama
Upi api: http://lbsyun.baidu.com/index.php? Title = uri/api/web (interface description-web-panoramic Service)
1 case "location": // geographic location information 2 $ location_X = $ postObj-> Location_X; // latitude 3 $ location_Y = $ postObj-> Location_Y; // longitude 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; // distance from 10 $ durationobj = $ apiobj-> result-> duration-> text; // time 11 $ label = $ postObj-> Label; 12 $ contentStr = "the geographic location you sent is :". "\ n ". $ label. ", \ n ". "longitude is :". $ lo Cation_Y. ", \ n ". "latitude :". $ location_X13. ", \ n ". "You still need to walk {$ distanceobj} meters to our shop, about {$ 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: xindongsheng market, No. 233, Lushan West Road" 16. "& mode = walking & output = html & region = Hangzhou & src = yourCompanyName | yourAppName \"> View walking navigation </a> ". "\ n" 17. "<a href = \" http://api.map.baidu.com/pano? X = {$ location_Y} & y = {$ location_X} & lc = 0 & ak = f6UkU0QqVAhABUeGKSxZBCeb \ ">" 18. "view the panorama of your location </a>"; 19 break;Panorama
4. Weather
Iov api: http://developer.baidu.com/map/wiki/index.php? Title = car/api/weather (interface description-weather query)
1 case "Weather": 2 $ weatherurl = "http://api.map.baidu.com/telematics/v3/weather? Location = Hangzhou & ak = f6UkU0QqVAhABUeGKSxZBCeb "; 3 $ apistr = file_get_contents ($ weatherurl); 4 $ apiobj = simplexml_load_string ($ apistr ); 5 $ placeobj = $ apiobj-> results-> currentCity; // read the city name 6 $ todayobj = $ apiobj-> results-> weather_data-> date; // read the current time 7 $ weatherobj = $ apiobj-> results-> weather_data-> weather; // read weather 8 $ export bj = $ apiobj-> results-> weather_data-> wind; // read wind 9 $ temobj = $ apiobj-> results-> weather_data-> temperature; // read temperature 10 $ pm25obj = $ apiobj-> results-> pm25; // read pm2.511 $ contentStr = "{$ placeobj} {$ todayobj}, weather: {$ weatherobj}, wind power: {$ 20.bj}, temperature: {$ temobj}, pm2.5: {$ pm25obj }. "; 12 break;Weather
You can also return weather information by geographic location. (Case "location": omitted)