我将MapBox用于我的Android应用程序,我需要修改用于指示当前用户位置和方向的标准蓝色“点”。
我发现这个帖子表明过去的MapBox Android API提供了修改用户位置图标的方法: https://github.com/mapbox/mapbox-android-sdk-legacy/issues/717
线程提到了这些方法:
mapView.getUserLocationOverlay().setDirectionArrowBitmap();
mapView.getUserLocationOverlay().setPersonBitmap();
最新的MapBox Android SDK未显示这些方法。有没有人知道这些方法的替代品或修改用户位置图标的替代方法?
答案 0 :(得分:2)
MapBox回应了澄清这些方法替换的请求,并说:
至于更改自定义标记的位置以显示移动,最好的选择是在需要显示进度时添加和删除标记。根据您需要刷新位置的速度,这种方法可能看起来有点不稳定,但这是目前最好的解决方法。这将通过
完成
MapView.addMarker()
和
MapView.removeAnnotation()
这不是一个理想的解决方案,但它现在应该完成工作。
答案 1 :(得分:1)
Markers indicate single locations on the map. You can customize your markers by changing the default color, or replacing the marker icon with a custom image. Info windows can provide additional context to a marker.
MarkerView markerView = new MarkerView(new LatLng(LAT,LONG), customView);
markerViewManager.addMarker(markerView);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
MarkerViewManager markerViewManager = new MarkerViewManager(mapView, mapboxMap);
}
});
markerViewManager.removeMarker(markerView);
let us put them together to work
足够多的谈话,让我们看看一些 好,我们会检查一下 这里什么都没有。 如果你看到 你需要 我会检查并回复 现在你可以 不用担心
@Volatile
已同步 intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK.or(Intent.FLAG_ACTIVITY_CLEAR_TASK)
// for Log
public static final String TAG = MyApplication.class
.getSimpleName();
答案 2 :(得分:0)
我已经添加了一个公交车图标,您可以根据需要进行更改。
@SuppressWarnings({"MissingPermission"})
private void enableLocationComponent(@NonNull Style loadedMapStyle) {
// Check if permissions are enabled and if not request
if (PermissionsManager.areLocationPermissionsGranted(mainActivity)) {
// Activate the MapboxMap LocationComponent to show user location
// Adding in LocationComponentOptions is also an optional parameter
locationComponent = mapboxMap.getLocationComponent();
locationComponent.activateLocationComponent(mainActivity, loadedMapStyle);
locationComponent.setLocationComponentEnabled(true);
// Create and customize the LocationComponent's options
LocationComponentOptions customLocationComponentOptions = LocationComponentOptions.builder(getActivity())
.foregroundDrawable(R.drawable.bus)
.build();
// Get an instance of the component
locationComponent = mapboxMap.getLocationComponent();
LocationComponentActivationOptions locationComponentActivationOptions =
LocationComponentActivationOptions.builder(getActivity(), loadedMapStyle)
.locationComponentOptions(customLocationComponentOptions)
.build();
// Activate with options
locationComponent.activateLocationComponent(locationComponentActivationOptions);
// Set the component's camera mode
locationComponent.setCameraMode(CameraMode.TRACKING);
// IconFactory iconFactory = IconFactory.getInstance(getActivity());
// mapboxMap.addMarker(new MarkerOptions().icon(iconFactory.fromResource(R.drawable.bus)));
} else {
permissionsManager = new PermissionsManager(this);
permissionsManager.requestLocationPermissions(mainActivity);
}
}