You are on page 1of 1

cara install cordova plugin :

cordova plugin add (nama modul)


contoh :
cordova plugin add cordova-plugin-geolocation -> untuk plugin peta
cordova plugin add cordova-plugin-splashscreen -> untuk plugin splashscreen
memanggil fungsi geolocaation
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1,
maximum-scale=1, minimum-scale=1, width=device-width">
<title>Hello World</title>
</head>
<body>
<h1> Geolocation </h1>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n');
};
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
</script>
</body>
</html>

You might also like