Objective
This article mainly introduces the Baidu map automatic positioning to the current function, then you can specify the starting location to query the bus.
Source
<! DOCTYPE html><html><head> <meta http-equiv="Content-type" Content="text/html; Charset=utf-8 " /> <meta name="viewport" content="initial-scale=1.0, User-scalable=no " /> <style type="Text/css"> Body,HTML {width: %; height: %; margin:0; font-family:"Microsoft Jas Black"; font-size:px; } #l-map{height: +px; width:%; } #r-result,#r-result Table{width:%; Clear:both; } #routePanel P{float:left;} </style> <script type="text/javascript" src="http://api.map.baidu.com /API?V=2.0&AK=DDD05FCBA9FEA5B83BF648515E04FC4C "></script> <script src="Http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <title>Multi-end selection of bus transfer query</title></head><body> <div id="L-map"></div> <div id="Routepanel"> <p Style="margin-right:10px;" >Starting point:<span><input type="text" id="Start"></input></span></P> <p>End:<span id="b_pointname1"><input type="text" id="End"></input></span></span> <button onclick="search ()">Inquire</button> </div> <div id="R-result" style="Display:none;" ></div></body></html><script type="Text/javascript"> varMap =NewBmap.map ("L-map"); Map.centerandzoom (NewBmap.point (116.404,39.915), A); Map.enablescrollwheelzoom ();//Navigate to Current location varGeolocation =NewBmap.geolocation (); Geolocation.getcurrentposition ( function(r){ if( This. getStatus () = = bmap_status_success) {varmk =NewBmap.marker (R.point); Map.addoverlay (MK); Map.panto (R.point);//alert (' Your location: ' +r.point.lng+ ', ' +r.point.lat ');}Else{Alert (' failed '+ This. GetStatus ()); }},{enablehighaccuracy:true})//About status code //bmap_status_success retrieved successfully. Corresponds to the value "0". //bmap_status_city_list City list. Corresponds to the value "1". //bmap_status_unknown_location location result unknown. Corresponds to the value "2". //bmap_status_unknown_route navigation results are unknown. Corresponds to the value "3". //bmap_status_invalid_key illegal keys. Corresponds to the value "4". //bmap_status_invalid_request illegal request. Corresponds to the value "5". //bmap_status_permission_denied does not have permissions. Corresponds to the value "6". (added since 1.1) The //bmap_status_service_unavailable service is not available. Corresponds to the value "7". (added since 1.1) //bmap_status_timeout Timeout. Corresponds to the value "8". (added since 1.1) varTransit =NewBmap.transitroute (map, {renderoptions: {map:map, Panel:"R-result"}, Onresultshtmlset: function(){$("#r-result"). Show ()}); function search() { varStart = $ ("#start"). Val (), End = $ ("#end"). Val (); Transit.search (Start,end); }</script>
Test results
Summarize
According to some of Baidu's API, can make their own personalized navigation system, interested friends can be in-depth study. Related to Baidu provided reference: Http://developer.baidu.com/map/jsdemo.htm#i8_3
Baidu Map API positioning current and bus query