Ok,
here is my solution:
private void searchOnMap(String search) {
// ** brings up Google Maps with results, but unable to pass data back
to my app - no go
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:
0,0?q=" + search.replace(" ", "+")));
// this.startActivityForResult(intent, MAP_ACTIVITY);
// ** works with address only; NO BUSINESS search - no go
// Geocoder geoCoder = new Geocoder(this);
// try {
// List<Address> results =
geoCoder.getFromLocationName(search,
MAX_SEARCH_RESULTS);
// int a=results.size();
// } catch (IOException e) {
// e.printStackTrace();
// }
// ** works like a charm! The only unsure is the map key. I generated
for http://localhost; see how far we get
StringBuilder responseBuilder = new StringBuilder();
try {
URL url = new
URL("http://ajax.googleapis.com/ajax/services/search/
local?v=1.0&q="
+ URLEncoder.encode(search, "UTF-8")
+
"&key=ABQIAAAArsnSCSicZxq21ogV4Uu_JxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQ3l8j5e79VEU4_ht1ROH0YrZtWuw");
BufferedReader in = new BufferedReader(new InputStreamReader
(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
responseBuilder.append(inputLine);
}
in.close();
} catch (MalformedURLException me) {
me.printStackTrace();
} catch (UnsupportedEncodingException ue) {
ue.printStackTrace();
} catch (IOException ie) {
ie.printStackTrace();
}
try {
JSONObject json = new
JSONObject(responseBuilder.toString());
int a = json.length();
} catch (JSONException e) {
e.printStackTrace();
}
}
On Feb 2, 3:14 pm, gnugu <[email protected]> wrote:
> Got
> it!http://developer.android.com/reference/android/location/Geocoder.html...
>
> On Feb 2, 3:03 pm, Rastislav Hodul <[email protected]> wrote:
>
> > Thanks. I'm looking at it, but can't see any example of search.
>
> > Rastio Hodul
> > [email protected]
>
> > 2010/2/2 Rogério de Souza Moraes <[email protected]>:
>
> > > Hi,
>
> > > did you looked at the code MJAndroid? Download it at
> > >http://examples.oreilly.com/9780596521509/
>
> > > It's a good example for you!
>
> > > Regards,
>
> > > Rogerio
>
> > > 2010/2/2 gnugu <[email protected]>
>
> > >> Ok, this will do the search:
>
> > >> private void searchOnMap(String search) {
> > >> Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?
> > >> q=" + search.replace(" ", "+")));
> > >> this.startActivity(intent);
> > >> }
>
> > >>NoI need to get back long/lat of selected Costco. Any way? Anybody?
>
> > >> On Feb 2, 2:09 pm, gnugu <[email protected]> wrote:
> > >> > Or better yet, would it be possible to invoke Google Maps from my
> > >> > application, do the search there and have it return lat/lng back to
> > >> > me?
>
> > >> > When user clicks on a search result several options like Show on Map/
> > >> > GetDirections etc a re presented. Could I insert my own option there?
>
> > >> > On Feb 2, 1:57 pm, gnugu <[email protected]> wrote:
>
> > >> > > Hi,
> > >> > > I'm adding MapView to my app and I would like the user to be able to
> > >> > > search for location just like in Google Maps app.
>
> > >> > > Is there any way to do it?
>
> > >> > > Thanks.
>
> > >> --
> > >> You received this message because you are subscribed to the Google
> > >> Groups "Android Developers" group.
> > >> To post to this group, send email to [email protected]
> > >> To unsubscribe from this group, send email to
> > >> [email protected]
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en