LBS for WeChat public account development and lbs for public development

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.