Карты Google не отображают детали карты

У кого-нибудь есть мысли о том, почему я получаю следующие экраны? Существует множество предложений, касающихся ключа, но я прошел все этапы, чтобы получить ключ. Возможно ли, что цвет не будет отображаться, потому что я использую Android Studio на старом ноутбуке?

Изображение до клика

Изображение после клика

Карта перемещается в правильное местоположение, но ни один из цветов не отображается для карты. Я не думаю, что это ключевой вопрос API. Ниже приведен код, используемый для карты. Я, очевидно, не использовал настоящий ключ.

package sheldonjohn.com.offcampus;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_directions);


    origin = new LatLng(29.572813, -97.984900);

    Bundle bundle = getIntent().getExtras();
    double destLatitude = bundle.getDouble("latitude");
    double destLongitude = bundle.getDouble("longitude");
    Log.d("Latitude", "Latitude is: " + destLatitude);
    Log.d("Longitude", "Longitude is:" + destLongitude);
    destination = new LatLng(destLatitude, destLongitude);

    get_directions_btn = (Button) findViewById(R.id.get_directions_btn);
    get_directions_btn.setOnClickListener(this);

    mapFragment = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment));
    mapFragment.getMapAsync(this);

}

public void onMapReady(GoogleMap googleMap) {
    this.googleMap = googleMap;
}

public void onClick(View v) {
    int id = v.getId();
    if (id == R.id.get_directions_btn) {
        requestDirection();

    }
}

public void requestDirection() {
    Log.d("RequestOrigin", "Origin inside request: " + origin);
    Log.d("RequestDestination", "Destination inside request: " + destination);
    Snackbar.make(get_directions_btn, "Direction Requesting...", Snackbar.LENGTH_SHORT).show();
    GoogleDirection.withServerKey(serverKey)
            .from(origin)
            .to(destination)
            .transportMode(TransportMode.DRIVING)
            .execute(this);
}

public void onDirectionSuccess(Direction direction, String rawBody) {
    Log.d("Status","Direction Status is:" +direction.getStatus());
    Snackbar.make(get_directions_btn, "Success with status : " + direction.getStatus(), Snackbar.LENGTH_SHORT).show();
    if (direction.isOK()) {
        Route route = direction.getRouteList().get(0);
        Log.d("Route ", "Route is: " + route);

        Log.d("Origin Marker", "Origin Marker: " + origin);
        Log.d("Destination Marker", "Destination Marker: " + destination);
        googleMap.addMarker(new MarkerOptions().position(origin));
        googleMap.addMarker(new MarkerOptions().position(destination));

        ArrayList<LatLng> directionPositionList = route.getLegList().get(0).getDirectionPoint();
        googleMap.addPolyline(DirectionConverter.createPolyline(this, directionPositionList, 5, Color.RED));
        setCameraWithCoordinationBounds(route);

        get_directions_btn.setVisibility(View.GONE);

    }
    else{
        Log.d("Status","Direction Status is:" +direction.getStatus());
        Snackbar.make(get_directions_btn, direction.getStatus(), Snackbar.LENGTH_SHORT).show();
    }
}

    public void onDirectionFailure(Throwable t) {
        Snackbar.make(get_directions_btn, t.getMessage(), Snackbar.LENGTH_SHORT).show();
    }


private void setCameraWithCoordinationBounds(Route route) {
    LatLng southwest = route.getBound().getSouthwestCoordination().getCoordination();
    LatLng northeast = route.getBound().getNortheastCoordination().getCoordination();
    LatLngBounds bounds = new LatLngBounds(southwest, northeast);
    googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
}

}

0 ответов

Другие вопросы по тегам