Вопрос

I am trying to develop an android program that finds the location of the nearest hospital WITHOUT using the internet. Instead, I want it to use a stored map on the android device. Is this feasible? If so, Can anyone refer me to the code?

I successfully developed a similar program that uses google API, meaning it will contact the server and use the internet. I reused the source code in this link.

But in some cases, my user might not have an access to the internet and it is urgent to find the nearest hospital. How can I solve this issue?

Это было полезно?

Решение

Another much simpler solution is to store the coordinates of each hospital in a file. At App start your read the file in.

Possible file format:

Hospital Name, latitude, longitude, Adress Optional

Then simple calculate the line of sight distance to all hospitals using CLLocation distanceTo(). Then sort by distance.

Take the shortest. Although this is not road distance, it will work as long as there is no river or rail road inbetween

Другие советы

It's definitely possible. You'll need to use offline map data - you can get map data from the OpenStreetMap project. I'd recommend letting the user choose which areas to download after initial app installation, and then the data will always be available.

Later on, usage of the location API does not require internet connection. You'll get co-ordinates, with which you can calculate the distance to other co-ordinates (of hospitals..).

Obviously, your challenge will be to create a hard-coded list of hospital locations (albeit update-able, make sure the app can download a new list when internet is present, for example download a XML file).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top