![]() |
|
[Java] How to pass latitude and Longitude from sqlite database to Google Maps Activity - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] How to pass latitude and Longitude from sqlite database to Google Maps Activity (/showthread.php?tid=5611997) |
How to pass latitude and Longitude from sqlite database to Google Maps Activity - VIPhiggz10 - Apr 30, 2017 I've set up a database which through a textview displays the latitude and longitude of a specific building. There is a "go" button underneath which loads up my mapsActivity. However, I can't seem to get the lat and long to be placed on the map. Maps Activity Code public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {Go to location Method being called Code public void goToLocation(double lat, double lng) {building Activity Code btnGoLocation.setOnClickListener(new View.OnClickListener() {As you can see my code is pretty messy trying to get this to work. If anyone could teamview with me it'd be a lot easier to show what i'm trying to do. I feel like i'm close. * - SIM-429621 - Apr 30, 2017 Imagine you have Table called GeoLocations, in that table you have following columns: City, CityLongitude, CityLatitude, in order to get back values from columns CityLatitude and CityLongitude for let's say city New York, you would do something like this: ("SELECT CityLatitude FROM GeoLocations WHERE City=\"New York\""); and assign this to a variable of type double, or whatever is the kind of value you stored in the DB. And you do the same for the CityLongitude, if you don't want to use "\" to escape double quotes, you can surround city name with single quotes: ("SELECT CityLatitude FROM GeoLocations WHERE City='New York'"); If you want to learn this and not just put shit up in order to make your app work, read this, it's short and concise and you will learn how to do basic stuff with JDBC: https://docs.oracle.com/javase/tutorial/jdbc/ EDIT: For more Java tutorials and courses you can look up google stuff or PM me and I will give you access to some paid courses that go into more details about Java and JDBC. * - VIPhiggz10 - Apr 30, 2017 (Apr 30, 2017 12:56 PM)Passenger Wrote: Imagine you have Table called GeoLocations, in that table you have following columns: City, CityLongitude, CityLatitude, in order to get back values from columns CityLatitude and CityLongitude for let's say city New York, you would do something like this: Hi thanks for the reply. I hope that over the summer i'll be able to focus more time in getting deeper into Java. This project however needs to be complete by tuesday and this is the last piece of the puzzle before the app is ready to be demonstrated. This is in android studio. Do you think you could team view me and help fix the problem? it'd be greatly appreciated and would take a lot of stress off. * - Khamul - May 1, 2017 (Apr 30, 2017 07:54 PM)VIPhiggz10 Wrote: Hi thanks for the reply. I hope that over the summer i'll be able to focus more time in getting deeper into Java. This project however needs to be complete by tuesday and this is the last piece of the puzzle before the app is ready to be demonstrated. This is in android studio. Do you think you could team view me and help fix the problem? it'd be greatly appreciated and would take a lot of stress off. Really weird, I have a uni assignment (team project actually) that's an android app that interacts with a database and uses the Google Maps API etc. and it's also due to be demonstrated on Tuesday haha... I wish you luck and if you need any help then PM me! |