2

Core Location についていくつか質問があります。

1) アプリがコア ロケーションを使用する許可をユーザーが拒否した場合、または何らかの理由でコア ロケーションが利用できない場合、フォールバックはありますか? (たとえば、デバイスのロケール?)

2)次回のためにデバイスの位置をキャッシュできますか? Core Location はこれ自体を行いますか?

3)春の半ばにユーザーの地域の日没時間が本当に必要であり、デバイスの緯度と経度を取得したら、それを行う機能があります。おそらく、ロケールに基づいて時間について推測することはできますか? (例: 米国では、約 7:00pm と想定します。)

編集:

私は本当にアプリのユーザー領域で日没を計算しようとしています. 地図とは関係ありません。次の一連のイベントを検討しています。

  • Core Location の可用性を確認します。はいの場合は、それを使用して NSUserPreferences に保存します。Core Location が利用できない場合は、フォールバックに進みます。
  • 保存された場所を確認します。保存されている場合は、それを使用してください。そうでない場合は、続けてください...
  • ユーザーが選択した時間を確認します。
4

2 に答える 2

1

1) Strictly speaking, if the user does not allow using CoreLocation or, if permission were given but CoreLocation is not available, there is no other fallback to get the user's location as a latitude, longitude pair. Using the locale may not work in all of the cases. First, it will just give you an approximation which may be way too far from reality. However, it's up to you to judge whether this approximation is ok for your app. Moreover, there are some users using a locale different from the one related to their country. And, you have no guarantee that people travelling abroad will adjust the date/time every time.

2) Core Location caches by default the last location retrieved from the GPS unit. However, for people travelling abroad this cached location will be certainly wrong (even for people travelling just a few miles away), and in general, you should discard the cached value and localize again the user each time. I understand that for people travelling within their country this will not (usually) create huge problems. But it just depends on the country: travelling within Italy will not change the time, but travelling across the US may change the time up to 3 hours.

3) I would suggest to try using Core Location and, in case of problems, simply ask the user to input his/her local time or location (the city should be enough for your purpose). If you choose to ask for the user's location, then you can get the corresponding latitude/longitude pair but this will require a working network connection.

于 2010-04-08T08:25:35.010 に答える
0

2) CLLocationManager のオンライン ドキュメントから:

位置情報サービスは可能な限り迅速に初期位置を返し、利用可能な場合はキャッシュされた情報を返します。

CLLocation タイムスタンプをチェックして、キャッシュされた値かどうかを確認できます。

3) 最初の TZ 概算にロケールを使用することに決めた場合、ユーザーは移動するため、すぐにロケールをリセットしない可能性があることに注意してください。現在の TZ オブジェクトは次の方法で取得できます。

[NSTimeZone localTimeZone]
于 2010-04-05T16:38:45.013 に答える