1. Preface
It's always a little unaccustomed to say something at the beginning. Or say something, about Baidu map, I use the number of times or more, no way, demand ah. Well, when using Baidu map, there have been a lot of demand, but fortunately, Baidu map is very powerful, every need after exploration can meet the function. Baidu map in the future to meet some of the common functions of sorting out, but also convenient for some children's shoes reference. One of my projects is to start by positioning the viewable area of the map in its current position. Actually very simple, a lot of search on the Internet.
2. Details
Say more, rather than stick to the code more straightforward. But use Baidu map, must have AK. I don't think anyone knows that.
1. Introduction of JS File
1 <script type= "Text/javascript" src= "http://api.map.baidu.com/api?v1.5&ak= afb5d4d8279a19b2fc3a16d063f26772 "></script>
2.html Code Layout
<id= "Allmap" styleheight:500px; ' ></ Div >
3.js Code
var New Bmap.map ("Allmap"); var New bmap.geolocation (); geolocation.getcurrentposition (function (r) { if ( this. GetStatus () = = bmap_status_success) { map.centerandzoom (new Bmap.point ( R.POINT.LNG, R.point.lat); true })
4. After running the HTML, you can see the Baidu map is located in your current location. Some browsers will pop up the message "Want to get your location" and remember to click "Allow".
3. Summary
Well, it seems to be so simple, you can try it yourself. There will be more to write about my use of Baidu map problems and solutions, as well as the recent use of Baidu Eagle eye related.
Baidu Map API locates the viewable area to its current location