保存并加载latlng

4si2a6ki  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(153)

我有Map活动在我的应用程序中显示2个标记和多段线,我想保存。
我的应用程序具有跟踪用户位置的前台服务,但是当我通过通知启动应用程序时,addresslocation为空,这意味着它没有保存latlng。。
我试着用sharedpreference来保存标记线和折线,但是没有成功,有人有更好的解决方案吗?
我的标记和多段线:

line = mMap.addPolyline(new PolylineOptions()
                .add(new LatLng(addressLatLng.latitude, addressLatLng.longitude), new LatLng(userLocation.latitude, userLocation.longitude))
                .width(10)
                .color(Color.RED));

            destinationMarker = mMap.addMarker(new MarkerOptions().position(addressLatLng).title("Destination - " + mAddress).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))); // Destination Address

            startMarker = mMap.addMarker(new MarkerOptions().position(new LatLng(userLocation.latitude, userLocation.longitude)).title("Your Starting Location").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); // Start Location

谢谢你的建议。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题