-1

Hey friends i am showing the path as user(smartphone) moves from one location to another in my app. I want to store that path till user explicitly clears it . when I close the application the drawn path gets removed from the map. I want to save that path

Here is my code for drawing polyline in google map

   LatLng sydney = new LatLng(latitude,longitude);
    myloc= mMap.addMarker(new MarkerOptions().position(phone).title("My Loc"));
    now=mMap.addMarker(new MarkerOptions().position(sydney).title(node));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom((sydney),19.0f));
    PolylineOptions pOptions = new PolylineOptions()
            .width(10)
            .color(Color.GREEN)
            .geodesic(true);
    for (int z = 0; z < routePoints.size(); z++) {
        LatLng point = routePoints.get(z);
        pOptions.add(point);
    }
    line = googleMap.addPolyline(pOptions);
    routePoints.add(sydney);
AkashK
  • 201
  • 1
  • 4
  • 13
  • okay what is the problem ? – Basil Battikhi Nov 29 '17 at 12:44
  • Hello sir.. In this I am drawing a path when user moves but that path gets removed after closing the application. So I want to save this path – AkashK Nov 29 '17 at 12:46
  • you can store latitude and longitude in shared preference after that when user want to access it. it is very easy to get. you can also use library for it that is TinyDB from github. https://github.com/kcochibili/TinyDB--Android-Shared-Preferences-Turbo – Tara Nov 29 '17 at 12:47
  • i preferred to use shared preference setKey("key",new Gson().toJson(pOptions)) ; – Basil Battikhi Nov 29 '17 at 12:52

1 Answers1

2

you can store latitude and longitude in shared preference after that you can access it even application is closed and draw a path again according to that latitude and longitude. you can also use library for it that is Tiny Db from GitHub.

Tara
  • 692
  • 5
  • 23