blob: a5b9a947586f6783eeb17bf93c3d753ca3fd674b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
import cgeo.geocaching.CgeoApplication;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.MapProviderFactory;
import cgeo.geocaching.utils.Log;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
public class GoogleMapsDirectionApp extends AbstractPointNavigationApp {
protected GoogleMapsDirectionApp() {
super(getString(R.string.cache_menu_maps_directions), null);
}
@Override
public boolean isInstalled() {
return MapProviderFactory.isGoogleMapsInstalled();
}
@Override
public void navigate(Activity activity, Geopoint coords) {
try {
IGeoData geo = CgeoApplication.getInstance().currentGeo();
final Geopoint coordsNow = geo == null ? null : geo.getCoords();
if (coordsNow != null) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://maps.google.com/maps?f=d&saddr="
+ coordsNow.getLatitude() + "," + coordsNow.getLongitude() + "&daddr="
+ coords.getLatitude() + "," + coords.getLongitude())));
} else {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://maps.google.com/maps?f=d&daddr="
+ coords.getLatitude() + "," + coords.getLongitude())));
}
} catch (Exception e) {
Log.i("GoogleMapsDirectionApp: application not available.", e);
}
}
}
|