W3C Geolocation API
| Halaman artikel ini diterjemahkan, sebagian atau seluruhnya, dari halaman di en.wikipedia yang berjudul « W3C Geolocation API ». Lihat pula sejarah suntingan halaman aslinya untuk melihat daftar penulisnya. |
W3C Geolocation API merupakan upaya oleh World Wide Web Consortium (W3C) untuk membakukan sebuah antarmuka untuk mengambil informasi lokasi geografis untuk perangkat.[1] Ini mendefinisikan satu set objek, ECMAScript standar compliant, yang mengeksekusi dalam aplikasi klien memberikan lokasi perangkat klien melalui konsultasi Server Informasi Lokasi, yang transparan untuk antarmuka pemrograman aplikasi (API). Sumber yang paling umum dari informasi lokasi yang alamat IP, Wi-Fi dan Bluetooth alamat MAC, radio-frekuensi identifikasi (RFID), Wi-Fi lokasi koneksi, atau perangkat Global Positioning System (GPS) dan GSM / CDMA. Lokasi dikembalikan dengan akurasi yang diberikan tergantung pada sumber informasi lokasi terbaik yang tersedia.
Implementasi
Contoh kode
Kode JavaScript simpel yang dapat mengecek peramban web dapat menjalankan Geolocation API atau mempunyai Google Gears untuk membuat objek geolokasi dan menggunakannya untuk mendapatkan lokasi dari alat.
var gl;
function displayPosition(position) {
var p = document.getElementById("p");
p.innerHTML = "<table border='1'><tr><th>Timestamp</th><td>" + position.timestamp +
"<tr><th>Latitude (WGS84)</th><td>" + position.coords.latitude + " deg</td></tr>" +
"<tr><th>Longitude (WGS84)</th><td>" + position.coords.longitude + " deg</td></tr></table>";
}
function displayError(positionError) {
alert("error");
}
try {
if (typeof navigator.geolocation === 'undefined'){
gl = google.gears.factory.create('beta.geolocation');
} else {
gl = navigator.geolocation;
}
} catch(e) {}
if (gl) {
gl.getCurrentPosition(displayPosition, displayError);
} else {
alert("Geolocation services are not supported by your web browser.");
}
Daftar Pustaka
- ^ Popescu, Andrei (editor, Google Inc.) (22 Desember 2008). "Geolocation API Specification: W3C Candidate Recommendation 07 September 2010". W3C. Diakses tanggal 23 Januari 2013. Pemeliharaan CS1: Banyak nama: authors list (link)
Pranala luar
- Fitur Firefox 3.5 Geolocation Diarsipkan 2012-05-12 di Wayback Machine. untuk mengembangkan aplikasi lokasi
- Tutorial dan contoh dari Geolocation API dengan Google Gears
- Tambah sebuah penyedia layanan lokasi Diarsipkan 2012-01-06 di Wayback Machine. ke Gears
- WebScanNotes.com - W3C Geolocation API
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.