1. First, follow the getting start document to create a project:
2. Call js
Coordinates:
[Javascript]
Var getLocation = function (){
Var suc = function (p ){
Alert (p. coords. latitude + "" + p. coords. longpolling );
};
Var locFail = function (error ){
Alert ('Code: '+ error. code +' \ n' +
'Message: '+ error. message +' \ n ');
};
Navigator. geolocation. getCurrentPosition (suc, locFail );
};
If an error is returned, it may be that the geographic feature in the browser is not turned on (http://stackoverflow.com/questions/5407973/navigator-geolocation-getcurrentposition-throws-the-last-location-provider-was)
Take a photo:
[Javascript]
Function dump_pic (data ){
Var viewport = document. getElementById ('viewport ');
Console. log (data );
// Alert (data );
Viewport. style. display = "";
Viewport. style. position = "absolute ";
Viewport. style. top = "10px ";
Viewport. style. left = "10px ";
Document. getElementById ("test_img"). src = data;
}
Function fail (msg ){
Alert (msg );
}
Function show_pic (){
Navigator. camera. getPicture (dump_pic, fail ,{
Quality: 50
});
}
Author: xiaoguang44