1. First get Baidu JavaScript API
First open the http://api.map.baidu.com/api?v=1.3 as shown in the browser
Where http://api.map.baidu.com/getscript?v=1.3&key=&services=&t=20121108061854 this link is the API file we're looking for,
Also open it in the browser and save it as "Apiv1.3.min.js"
and Baidu map must be some of the controls, cursors, logos and other pictures are also downloaded down
2. Modify the "apiv1.3.min.js" to replace the map control inside the picture, cursor, logo and other links replaced by local.
3. Download Baidu map Tile, there are many ways to get it. Like this tool: Maptiledownloader
4. Start loading local map tiles using the offline Map API
Now, can completely out of the network to use Baidu map. Sample source code is as follows:
<!DOCTYPE HTML><HTML> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title>Baidu Offline Map Demo</title> <Scripttype= "Text/javascript"src= "Js/apiv1.3.min.js"></Script> <Scripttype= "Text/javascript"src= "Js/map,oppc,navictrl,tile,copyrightctrl"></Script> <!--script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=1.3" ></script - <Linkrel= "stylesheet"type= "Text/css"href= "Bmap.css" /> </Head> <Body> <Divstyle= "left:0;top:0;width:100%;height:100%;p osition:absolute;"ID= "Container"></Div> </Body></HTML><Scripttype= "Text/javascript"> varTilelayer= NewBmap.tilelayer ({istransparentpng:true }); Tilelayer.gettilesurl= function(Tilecoord, zoom) {varx=tilecoord.x; vary=Tilecoord.y; return 'maptile/' +Zoom+ '/' +x+ '/' +y+ '. PNG'; } varMap= NewBmap.map ('Container'); Map.addtilelayer (Tilelayer); Map.addcontrol (NewBmap.navigationcontrol ()); Map.centerandzoom (NewBmap.point (100.675, 39.007978), 5); Map.enablescrollwheelzoom (); //Enable wheel zoom in and zoom outMap.enablekeyboard (); //enables keyboard actions, which are disabled by default. The top, bottom, left, and right keys of the keyboard can move the map continuously. map.enablecontinuouszoom ();//Enable continuous zoom effect varCopyctrl= NewBmap.copyrightcontrol ({anchor:bmap_anchor_bottom_right}); Copyctrl.addcopyright ({ID:1, Content:"http://maptiledownloader.googlecode.com Baidu offline map demo" }); Map.addcontrol (Copyctrl);</Script>
Make Baidu map offline JavaScript API load local tile map