【问题标题】:Google maps : Current location blue bubble not shown , current location button not working in older device谷歌地图:当前位置蓝色气泡未显示,当前位置按钮在旧设备中不起作用
【发布时间】:2014-07-15 13:28:38
【问题描述】:

我正在使用谷歌地图进行项目。当前位置显示在新设备中,但未显示在旧 2.3 设备中。如何使当前位置在旧设备中可见。

我的代码:

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));

        }

我听说使用支持库会有所帮助..有人也可以澄清这一点吗?

【问题讨论】:

  • 我已经添加了支持库。

标签: java android google-maps


【解决方案1】:

Not shown in older 2.3 device.

除非出于非常特殊的目的,否则您应该开始为 Android 4.0+ 进行开发。您编写的代码可能在 2.3 设备上不可用。

【讨论】:

  • 您能否建议对我上面发布的代码进行哪些更改?
  • 不幸的是,没有。我真正能建议的是你离开 Android 2.3。但如果您真的希望它在 2.3 上运行,您可以找到兼容的外部库/API。
  • 它怎么会部分工作。除了蓝色气泡和当前位置按钮之外的一切都很好。
  • 可能有很多东西。程序/API 从 2.3 到 4.0+、硬件等方面的变化。再次,我强烈建议进一步开发 4.0 及更高版本。
【解决方案2】:

蓝点外观取决于您的设备是否能够自行定位。

确保您打开 GPS 并在“设置”应用的“我的位置”部分启用了相关设置:“使用无线网络”和“使用 GPS 卫星”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-24
    • 1970-01-01
    • 2015-08-14
    相关资源
    最近更新 更多