[問題] 隧道內或地下室定位?

作者: HelloJimmy (Angel Michael)   2014-09-14 22:45:22
大家好,
我寫了一支程式去紀錄定位座標,
因有考量到GPS無法定位問題,
因此我有使用GPS_Provider與Network_Provider.
程式如下:
Location location=null;
locationMgr = (LocationManager)
(ctx.getSystemService(Context.LOCATION_SERVICE));
isGPSEnabled = locationMgr.isProviderEnabled(LocationManager.GPS_PROVIDER);
isNetworkEnabled =
locationMgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (isGPSEnabled || isNetworkEnabled) {
//若GPS有效則以GPS優先
if (isGPSEnabled) {
if (location == null) {
locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER,..略);
if (locationMgr != null) {
location = locationMgr.getLastKnownLocation(LocationManager.
GPS_PROVIDER);
}
}
}
//若GPS無效,則以網路定位
if (isNetworkEnabled) {
if(location == null){
locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,.略);
if (locationMgr != null) {
location = locationMgr.getLastKnownLocation(LocationManager.
NETWORK_PROVIDER);
}
}
}
}
但我在捷運隧道測試時我的程式卻定不到位,
但是Google Map若可以!!
請問有人知道原因嗎?
謝謝!
作者: bdvstg (bdvstg)   2014-09-18 15:02:00
GoogleMap還會使用G-Sensor來輔助吧(聽說的)
作者: JULONE780701 (亞)   2014-09-18 22:53:00
因為你GPS有效,所以用GPS但你GPS確抓不到位置...就這樣...
作者: HelloJimmy (Angel Michael)   2014-09-19 00:32:00
GPS有效卻抓不到位置?那如何判斷切到Network_Provider
作者: hayden2111 (hayden)   2014-09-19 01:37:00
之前看過有用getLastKnownLocation("gps") != null的方式來判定GPS是否有效,可以試試看

Links booklink

Contact Us: admin [ a t ] ucptt.com