TAILIEUCHUNG - Xây dựng ứng dụng cho Android với HTML, CSS và javascript - part 16

Tham khảo tài liệu 'xây dựng ứng dụng cho android với html, css và javascript - part 16', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Next we ll rewrite the createEntry function that we first saw in Chapter 5 to use the geolocation feature of the phone to determine the current latitude and longitude. Replace the existing createEntry function in with this function createEntry 0 function position var latitude var longitude insertEntry latitude longitude function insertEntry return false O Begin the createEntry function. Q Call the getCurrentPosition function of the geolocation object and pass it two callback functions one for success and one for errors. This is the beginning of the success callback. Notice that it accepts a single parameter . position . These two lines grab the latitude and longitude coordinates out of the position object. Pass the latitude and longitude coordinates into a function called insertEntry which we ll look at momentarily. This is the beginning of the error callback. O Because we re in the error callback this will only be called if geolocation fails for example if the user does not allow the application to access his location when prompted so call the insertEntry function without parameters. Return false to prevent the default navigation behavior of clicking the form s Submit button. Wondering where the SQL INSERT statement got to Let s take a look at the insertEntry function. This new function creates the entry in the database. Add the following to function insertEntry latitude longitude var date var calories calories .val var food food .val O function transaction INSERT INTO entries date calories food latitude longitude VALUES date calories food latitude longitude Controlling the Phone with JavaScript 133 Download from function refreshEntries checkBudget errorHandler O The beginning of the insertEntry function allowing for latitude and longitude values to be passed in. .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.