我正在为Mapview做代码,通过搜索两个位置来获取路线。但是我收到了RoutingListener的错误。是否有任何jar文件。请给我一些建议。无论路由在哪里都会出现错误。请帮帮我。
提前致谢。
public class MapView2 extends AppCompatActivity implements RoutingListener, GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks {
protected GoogleMap map;
protected LatLng start;
protected LatLng end;
@InjectView(R.id.start)
AutoCompleteTextView starting;
@InjectView(R.id.destination)
AutoCompleteTextView destination;
@InjectView(R.id.send)
ImageView send;
private static final String LOG_TAG = "MyActivity";
protected GoogleApiClient mGoogleApiClient;
private PlaceAutoCompleteAdapter mAdapter;
private ProgressDialog progressDialog;
private ArrayList<Polyline> polylines;
private static final int[] COLORS = new int[]{R.color.primary_dark, R.color.primary, R.color.primary_light, R.color.accent, R.color.primary_dark_material_light};
private static final LatLngBounds BOUNDS_JAMAICA = new LatLngBounds(new LatLng(-57.965341647205726, 144.9987719580531),
new LatLng(72.77492067739843, -9.998857788741589));
/**
* This activity loads a map and then displays the route and pushpins on it.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapview2);
ButterKnife.inject(this);
getSupportActionBar().setDisplayShowHomeEnabled(true);
polylines = new ArrayList<>();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Places.GEO_DATA_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
MapsInitializer.initialize(this);
mGoogleApiClient.connect();
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
if (mapFragment == null) {
mapFragment = SupportMapFragment.newInstance();
getSupportFragmentManager().beginTransaction().replace(R.id.map, mapFragment).commit();
}
map = mapFragment.getMap();
mAdapter = new PlaceAutoCompleteAdapter(this, android.R.layout.simple_list_item_1,
mGoogleApiClient, BOUNDS_JAMAICA, null);
答案 0 :(得分:1)
查看https://developers.google.com/maps/documentation/directions/
使用意图
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=xx.xx,xx.xx&daddr=xx.xx,xx.xx"));
startActivity(intent);
答案 1 :(得分:0)