First, the use of Baidu Map API
1, Address: http://developer.baidu.com/map/
2. Get the demo of anti-address resolution in JS Demo
3, modify the demo key, to create the application can create the key, and then copy the key to this page
4. Use PhoneGap geolocation to obtain the latitude and longitude assigned to point
<!DOCTYPE HTML> <HTML><Head><MetaCharSet= "Utf-8"><title>Phonegap_device_network_notification01</title><Linkhref=".. /jquery.mobile-1.3.2.css "rel= "stylesheet"type= "Text/css"/><Scriptsrc=".. /jquery.js "type= "Text/javascript"></Script><Scriptsrc=".. /jquery.mobile-1.3.2.js "type= "Text/javascript"></Script><Scriptsrc=".. /cordova.js "type= "Text/javascript"></Script><Scripttype= "Text/javascript"src= "http://api.map.baidu.com/api?v=2.0&ak=17923c0196cbabf7603ea9edabdf787d"></Script><Scripttype= "Text/javascript"CharSet= "Utf-8"> //wait for phonegap to loadDocument.addeventlistener ("Deviceready", Ondeviceready,false); //Load Complete functionOndeviceready () {navigator.geolocation.getCurrentPosition (onsuccess, onerror,{timeout:100000, Enablehighaccuracy:true }); } functiononsuccess (position) {varelement=document.getElementById ('geolocation'); varLatitude=Position.coords.latitude;//Latitude varLongitude=Position.coords.longitude;//Diameter degreegetPosition (longitude,latitude); } //OnError callback function that receives the Positionerror object containing the specific error message functionOnError (Error) {alert ('Error code:' +Error.code+ '\ n' + 'More information:' +Error.message+ '\ n'); } //get a detailed address based on latitude and longitude functiongetPosition (longitude,latitude) {//Baidu Map API features varMap= NewBmap.map ("Map"); var Point= NewBmap.point (longitude,latitude); Map.centerandzoom (Point, A); varGC= NewBmap.geocoder (); Gc.getlocation (Point,function(RS) {varAddcomp=rs.addresscomponents; Alert (addcomp.province+ ", " +addcomp.city+ ", " +addcomp.district+ ", " +Addcomp.street+ ", " +addcomp.streetnumber); }); } </Script></Head> <styletype= "Text/css">#map{width:100%;Height:200px;}</style><Body><DivData-role= "page"> <DivData-role= "header"> <H1>PhoneGap100 Combat</H1> </Div> <DivData-role= "Content"ID= "Map"> </Div> <DivData-role= "Footer"> <h4> </h4> </Div></Div></Body></HTML>
PhoneGap geolocation combine Baidu Map API to get geolocation API