Baidu Map API Route simulation

Source: Internet
Author: User

<! DOCTYPE html>Baidu Map API Features
Add a map type control var map = new Bmap.map ("Allmap");  Map.centerandzoom (New Bmap.point (Lon,lat), 15); Added scale var Top_left_control = new Bmap.scalecontrol ({anchor:bmap_anchor_top_left});//upper left corner, add scale var Top_left_navigati on = new Bmap.navigationcontrol (); Upper left corner, add default zoom translation control var top_right_navigation = new Bmap.navigationcontrol ({anchor:bmap_anchor_top_right, TYPE:BMAP_ Navigation_control_small}); upper right corner Map.addcontrol (Top_left_control);         Increase scale Map.addcontrol (top_left_navigation); Map.addcontrol (top_right_navigation);
var myP1 = new Bmap.point (Lon,lat); Starting point var myP2 = new Bmap.point (Mylon,mylat);        End point var Myicon = new Bmap.icon ("Http://lbsyun.baidu.com/jsdemo/img/Mario.png", New Bmap.size (32, 70), {//Trolley pictures Offset:new bmap.size (0,-5),//corresponds to the offset of the CSS sprite Imageoffset:new bmap.size (0, 0)//Picture.     In order to align the coordinates at the bottom center of the picture.    }); var driving2 = new Bmap.drivingroute (map, {renderoptions:{map:map, autoviewport:true}}); Driving example Driving2.search (myP1, myP2); Show a bus line
Window.run = function () {var driving = new Bmap.drivingroute (map);//Driving Example Driving.search (myP1, myP2); Driving.setsearchcompletecallback (function () {var pts = Driving.getresults (). Getplan (0). Getroute (0). GetPath ( ); By driving the example, get a series of points of the array var paths = Pts.length; Get a few points
            var carMk = new BMap.Marker (Pts[0],{icon: Myicon});             map.addoverlay (carMk);             i=0;             function Resetmkpoint (i) {                 carmk.setposition (Pts[i]);                 if (i < paths) {                     settimeout (Function ( ) {                         i++;               &nBsp;         resetmkpoint (i);       &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;},60);                 }             }             settimeout (function () {                 resetmkpoint (5);             }, 100)
}); }
SetTimeout (function () {run (); },1500);</script>

Baidu Map API Route simulation

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.