Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. @Override
  2. protected void onPause(){
  3. super.onPause();
  4. try {
  5. // Modes: MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITABLE
  6. FileOutputStream output = openFileOutput("latlngpoints.txt",
  7. Context.MODE_PRIVATE);
  8. DataOutputStream dout = new DataOutputStream(output);
  9. dout.writeInt(listPoints.size()); // Save line count
  10. for (LatLng point : listPoints) {
  11. dout.writeUTF(point.latitude + "," + point.longitude);
  12. Log.v("write", point.latitude + "," + point.longitude);
  13. }
  14. dout.flush(); // Flush stream ...
  15. dout.close(); // ... and close.
  16. } catch (IOException exc) {
  17. exc.printStackTrace();
  18. }
  19. }
  20.  
  21. protected void onResume(GoogleMap googleMap) {
  22. super.onResume();
  23. try {
  24. FileInputStream input = openFileInput("latlngpoints.txt");
  25. DataInputStream din = new DataInputStream(input);
  26.  
  27.  
  28. int sz = din.readInt(); // Read line count
  29. for (int i = 0; i < sz; i++) {
  30. String str = din.readUTF();
  31.  
  32. String[] stringArray = str.split(",");
  33. double latitude = Double.parseDouble(stringArray[0]);
  34. double longitude = Double.parseDouble(stringArray[1]);
  35. // newlist.add(new LatLng(latitude, longitude));
  36. Log.v("Read", String.valueOf(latitude));
  37. Log.v("Read1", String.valueOf(longitude));
  38.  
  39. LatLng latLng = new LatLng(Double.parseDouble(stringArray[0]),Double.parseDouble(stringArray[1]));
  40. mMap1 = googleMap;
  41.  
  42. mMap1.addCircle(new CircleOptions()
  43. .center(latLng)
  44. .radius(100)
  45. .strokeColor(Color.RED));
  46.  
  47.  
  48. }
  49. din.close();
  50.  
  51. } catch (IOException exc) {
  52. exc.printStackTrace();
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement