2014-07-15 214 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卫星”。

相关问题