如何在关闭GPS的谷歌地图addMarker中设置默认位置?

时间:2013-12-10 07:18:31

标签: android google-maps gps location

我正在做一个需要在谷歌地图中标记的项目。如果我关闭GPS,我无法在地图中设置默认标记位置。但是当我打开GPS时,我可以看到我的默认位置。是否有可能我的GPS关闭我可以设置默认标记位置???

1 个答案:

答案 0 :(得分:0)

可以将Marker添加到GoogleMap。这种方法当然取决于您拥有用户的最后位置。您可以尝试使用LocationManager.getLastKnownLocation NETWORK_PROVIDERGPS_PROVIDER获取最后一个位置,然后根据该信息创建LatLng

LatLng latLng = new LatLng(location.getLatitude(),
            location.getLongitude());
map.addMarker(new MarkerOptions().position(latLng)
                .icon(BitmapDescriptorFactory
                        .defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));