【问题标题】:Cannot Resolve symbol class RoutingListener无法解析符号类 RoutingListener
【发布时间】: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);

【问题讨论】:

  • 你能添加代码吗?
  • 是的,我编辑我的问题
  • 您需要创建 RoutingListesner 接口。请查看this 链接。另请查看this 项目以获得更多帮助。
  • ok 得先创建一个RoutingListener的接口然后再添加
  • 但之后 Routingexception 也显示界面错误

标签: android android-studio android-fragments android-intent android-activity


【解决方案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);

【讨论】:

  • 这里的例子anddev.org/…
  • 无论路由在哪里,RoutingListener 都不会出现错误,它以红色显示。
  • 我在回答中给出了实施谷歌地图的建议,这将更有帮助和更简单。
猜你喜欢
  • 1970-01-01
  • 2018-11-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-04
  • 2016-12-31
相关资源
最近更新 更多