0

Right now I am trying to allow a user to select a location which will take them to it on a map. This works fine, however it is hard coded. What I want to be able to do is read in values I have stored in a text file which will then take the user to the lat and lon values on my map.

 public void onMapReady(GoogleMap map) {    // map is loaded but not laid out yet
    this.map = map;
    // code to run when the map has loaded

    double lat, lon;

    if (city.equals("Dublin"))
    {
        lat = 53.343908;
        lon = -6.267554;
    }
    else if (city.equals("Cork"))
    {
        lat= 51.892751;
        lon= -8.491542;
    }
    else
    {
        lat=0;
        lon=0;
    }

    map.addMarker(new MarkerOptions()
                    .position(new LatLng(lat, lon))
                    .title("")
    );

    map.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lon)));
    map.moveCamera(CameraUpdateFactory.zoomTo(10));

}

This is currently how I am doing it. I can supply the rest or more of my code if neccessary. Thank you for reading.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • I read it. You wrote what you want. But you did not describe problems doing so. Reading a text file line by line is pretty standard so why dont you post that code to begin with? Or isnt that your problem? If not then what is the problem? – greenapps Dec 01 '17 at 14:50
  • So many questions in your question. What is your problem exactly? What have you tried so far as we're not going to code your app for you? – Eselfar Dec 01 '17 at 14:50
  • 1
    Many questions? I dont see one! – greenapps Dec 01 '17 at 14:51
  • Let's say 'potential' questions then, as it implies to: read a file, display a ui for the user to choose a location based on the info from the file, redirect the user to the map, display the selected location on the map. – Eselfar Dec 01 '17 at 14:53
  • But still, it looks like OP asks for an entire app! :D – Eselfar Dec 01 '17 at 14:54
  • Are you aware of a post by `m.rajabi` about the same? https://stackoverflow.com/questions/47583634/how-read-a-file-from-storage-and-edit-text-of-the-file-and-add-to-code?noredirect=1#comment82140094_47583634 – greenapps Dec 01 '17 at 14:55
  • I had answered a similar question here https://stackoverflow.com/questions/47509681/reading-latitude-and-longitude-from-a-text-file/47511628#47511628 – lakshman.pasala Dec 02 '17 at 05:58

0 Answers0