【发布时间】:2016-08-12 22:12:33
【问题描述】:
我正在使用 MapBox 并显示一个设置用户地理编码的图钉。该程序在所有 api 上都可以正常工作......除了 19 是黑屏。当我按照此处的文档进行操作时,我不确定该怎么做:
https://www.mapbox.com/android-sdk/examples/marker/
我的一些代码如下:
分级:
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.1@aar'){
transitive=true
}
compile('com.mapbox.mapboxsdk:mapbox-android-services:1.2.1@aar') {
transitive = true
}
获取地图视图
mapView = (MapView) findViewById(R.id.mapView);
mapView.setStyle(Style.MAPBOX_STREETS);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
地图准备好后回调:
public void onMapReady(MapboxMap mapboxMap) {
// Relevant sources shown only
mapboxMap.setStyleUrl(Style.MAPBOX_STREETS);
mapboxMap.setOnInfoWindowClickListener(this);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(geocodeLatLng)
.zoom(15)
.bearing(0)
.build();
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
Marker position = mapboxMap.addMarker(new MarkerOptions().position(geocodeLatLng).title(location));
position.setSnippet(address);
position.showInfoWindow(mapboxMap, mapView);
}
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:style_url="mapbox://styles/mapbox/streets-v9"
mapbox:zoom="11"/>
</RelativeLayout>
我还有什么遗漏的吗?我也有 AndroidManifest.xml 和 gradle 更改。它显然适用于较新的 API,而不是较旧的 API。该网站说他们支持 API 15+?
【问题讨论】:
-
有什么有用的 logcat 信息可以发布吗?可能不是,但只是检查。