Geo-positioning Geolocation |
One-time positioning: Navigator.geolocation.getCurrentPosition (Success, [error],[options]); Repeatability positioning: Navigator.geolocation.watchPosition (Success, [error],[options]); |
Call interface with Left |
Both methods are called consistent In the PhoneGap location, due to device differences, resulting in some devices can not be located, need to rely on Baidu Map SDK positioning. |
Camera Carema |
HTML5 's media capture API provides programmatic access to the camera, which allows users to obtain video streaming from the camera directly with Getusermedia Call: Navigator.getusermedia (' video ', Success,error) (1) Get the video stream: a HTML5 video tag that will be taken from the camera as the input source for this tag. Function Success (Videostream) { Viedo_ele.src=videostream; } (2) using canvas to draw the contents of the video tag, Ctx.drawimage (VIDEO_ELEMENT,0,0,CW,CH,0,0,VW,VH) (3) Get PICTURES: Convert canvas data to base64-bit encoded PNG images Var Imgdata=canvas.todataurl ("Image/png"); |
Provides access to the device's default camera application, which is returned as a base64 encoded string or picture URI: Navigator.camera.getPicture (Success, Cameraerror, [cameraoptions]); Return format by cameraoptions parameter: Base64 encoding is returned by default DestinationType:Camera.DestinationType.FILE_URI (return URI) |
The calling interface is not the same HTML5 uses video and canvas tags to simulate photo effects by accessing the camera's interface. Currently only chrome and opera support. PhoneGap is a direct call to the native camera. |
Direction change Compass |
HTML5 provides the Deviceorientation event to monitor the physical direction and movement of the device. Depending on the rotation of the phone, the compass rotation angle compass is determined to be displayed with canvas. Window.addeventlistener ("Deviceorientation", update, FALSE); The Deviceorientation direction event object contains the angle of the device before and after rotation, left and right rotation, rotation along the z axis, and so on. (1) Deviceorientationevent.absolute returns a BOOL value indicating whether the device absolutely supports directional positioning (2) Deviceorientationevent.alpha indicates the rotation angle of the device along the z axis, and the range is 0~360. (3) The Deviceorientationevent.beta range is -180~180. It describes the case where the device is rotated from front to back. (4) The Deviceorientationevent.gamma range is -90~90. It describes the case where the device is rotated from left to right. |
Detection device direction or orientation, use as a unit of measure, the value range from 0 degrees to 359.99 degrees. Navigator.compass.getCurrentHeading (success,error,options); Get the angle change of the compass orientation at a fixed time interval: Navigator.compass.watchHeading (Success,error, [compassoptions]); function Success (heading) { alert (heading.magneticheading); }; |
The calling interface is not the same HTML5 provides a more detailed information about the directional change events that are included. The PhoneGap only provides equipment orientation |
Local storage Storage |
The HTML5 supports the localstorage and sessionstorage two storage storage methods, which are persistent data stores, which are session-level data stores. Localstorage.setitem (Key,value); Localstorage.getitem (key); |
PHONEGAP provides access to the Localstorage interface, which stores data in the form of key-value pairs. var storage= window.localstorage; Storage.setitem (Key,value) Storage.getitem (key); |
They call the interface consistent |
File system FileSystem |
HTML5 provides two storage modes, persistent (persistent storage) and temporary (temporary storage). (1) Gets the method that invokes the FS object Window.requestfilesystem=window.requestfilesystem | | Window.webkitrequestfilesystem; (2) Request FS Object Window.requestfilesystem (Type,size,success,error); (3) Obtain files through FS object, use FileReader, FileWriter read and write files: Function Success (FS) { Get directory Fs.root.getDirectory (); Fs.root.getFile (); Get file } /* Request 5MB temporary storage space */ Window.requestfilesystem (window. Temporary,5*1024*1024,oninitfs,errorhandler); |
There are also two storage modes available, but the storage type is specified by a LocalFileSystem object. (1) Request a FileSystem object: Window.requestfilesystem (localfilesystem.persistent,0,onsuccess, onError); (2) Obtain files through FS, use FileReader, FileWriter read and write files: function onsuccess (FS) { Fs.root.getDirectory (); Fs.root.getFile (); } |
The interface is basically the same as the call. Only the former method of requesting the FileSystem object is related to the browser, and only Chrome is supported. The PHONEGAP uses its own encapsulated interface, regardless of the browser. |