2014-07-15 212 views
-2

我做的使用谷歌maps.The當前位置的項目在新設備中顯示舊設備不能正常工作,但不能在較早的2.3 device.How做所示我在舊設備中顯示當前位置。谷歌地圖:當前位置藍泡泡未顯示,當前位置按鈕

我的代碼:

public void initialiseMap() 
    { 
     if (googleMap == null) { 
      googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
         R.id.map)).getMap(); 


     } 
     // check if map is created successfully or not 
     if (googleMap == null) { 
      Toast.makeText(getApplicationContext(), 
        "Sorry! unable to create maps", Toast.LENGTH_SHORT) 
        .show(); 
     } 
     else 
     { 
     googleMap.setMyLocationEnabled(true); 
     googleMap.getUiSettings().setMyLocationButtonEnabled(true); 
     googleMap.getUiSettings().setCompassEnabled(true); 
//   UiSettings uiSettings = googleMap.getUiSettings(); 
//   uiSettings.setMyLocationButtonEnabled(true); 



      } 
      //locationManager.requestLocationUpdates(provider, 20000, 0, this); 
     LatLng latLng = new LatLng(current_latitude, current_longitude); 
     googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); 

     // Zoom in the Google Map 
     //googleMap.animateCamera(CameraUpdateFactory.zoomTo(15)); 
     googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 11.5f)); 

     } 

我一直在使用一個支持libarary將help..Can有人澄清這一點也請聽到。

+0

我已添加支持庫。 – user3837228

回答

0

Not shown in older 2.3 device

除非非常特殊的目的,則應該開始爲Android 4.0以上版本開發。您可能正在編寫在2.3設備上不可用的代碼。

+0

你能建議我在上面的代碼中做什麼更改嗎? – user3837228

+0

不幸的是,沒有。我真的可以建議的是,你離開Android 2.3。但是如果你真的希望它能在2.3上工作,你可以找到一個兼容的外部庫/ API。 – Andrew

+0

它是如何工作的除了藍色氣泡和當前位置按鈕以外的所有東西都很好。 – user3837228

0

藍點外觀取決於您的設備能夠本地化。

請確保您打開GPS,並在設置應用的我的位置部分啓用相關設置:「使用無線網絡」和「使用GPS衛星」。

相關問題