【发布时间】:2016-04-18 09:28:33
【问题描述】:
我正在为 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);
【问题讨论】:
-
你能添加代码吗?
-
是的,我编辑我的问题
-
ok 得先创建一个RoutingListener的接口然后再添加
-
但之后 Routingexception 也显示界面错误
标签: android android-studio android-fragments android-intent android-activity