Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
143023864X_HT5.pdf
Скачиваний:
8
Добавлен:
21.02.2016
Размер:
7.98 Mб
Скачать

CHAPTER 5 USING THE GEOLOCATION API

Table 5-4. Pros and Cons of Cell Phone–based Geolocation Data

Pros

Cons

Fairly accurate

Requires a device with access to a cell

 

phone or cell modem

Works indoors

Not good in rural areas with fewer cell

 

phone towers

Can get fix quickly and cheaply

 

User–Defined Geolocation Data

Instead of programmatically figuring out where the user is, you can also allow users to define their location themselves. An application may allow users to enter their address, ZIP code, or some other details; your application can then use that information to provide location-aware services. Table 5-5 shows the pros and cons of user–defined geolocation data.

Table 5-5. Pros and Cons of User–defined Geolocation Data

Pros

Cons

Users may have more accurate

Can also be very inaccurate, especially if

location data than programmatic

the location changes

services

 

Allows geolocation services for

 

alternate locations

 

User entry might be faster than

 

detection

 

Browser Support for Geolocation

Geolocation was one of the first HTML5 features to be fully embraced and implemented, and it is available in all the major browsers now. For a complete overview of the current browser support, including mobile support, refer to http://caniuse.com and search for Geolocation.

If you have to support older browsers, it’s always a good idea to first see whether Geolocation is supported before you use the API. The section “Checking for Browser Support” later in this chapter will show you how you can programmatically check for browser support.

111