Roman Marius
Roman Marius

Reputation: 476

Find Location on Google Maps using coordinates

I want to show a location on a map based on latitude and longitude coordinates. When I press a button I want to send the coordinates to Google Maps (or other app) and pinpoint that location. Any ideas of how I can achieve that?

Upvotes: 1

Views: 15655

Answers (3)

Roman Marius
Roman Marius

Reputation: 476

I've found a simple solution. I start the google maps app via an intent

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
                        Uri.parse("http://maps.google.com/maps?q=" + serviceActivity.Latitude.toString() + "," + serviceActivity.Longitude.toString()));
                        startActivity(intent);

Upvotes: 1

fabzy
fabzy

Reputation: 373

If you want to animate to a specific point on a google map you need to define a MapView. Then create a MapController and animate to a specific GeoPoint:

MapController mapController = mapView.getController();

double lat = latitude * 1e6;
double lon = longitude * 1e6;

GeoPoint startpoint = new GeoPoint((int) lat, (int) lon);
mapController.animateTo(startpoint);

Try this tutorial :MapView Tutorial

Upvotes: 1

Related Questions