Address conversion on Google Maps

Asked

Viewed 816 times

1

I’m making an App to search addresses on Google Maps.

Is there any way to convert a String in Location, so I can take longitude and latitude? Or is there a better way?

2 answers

2

Is in JAVASCRIPT?

str = "12.12345 -15.12345";

x = str.split(" "); // para partir em 2 a string

lat = x[0];
lon = x[1];

latLon = new google.maps.LatLng(lat, lon);

latLon will be in the format accepted by the google app.
Want a hint? see how the latLon format is written:

alert(  JSON.stringify( latLon )  );
  • Not in Java anyway.

0


I found the answer (delayed but found!).

Android has a class called Geocoder, that allows you to make these conversions. You also need to give permission to access the internet and GPS:

uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.