MapBox用户位置图标(Android)
我在Android应用程序中使用MapBox,我需要修改用于指示当前用户位置和方向的标准蓝点 我发现这个线程表明过去的MapBox Android API提供了修改用户位置图标的方法: 该线程提到了以下方法:MapBox用户位置图标(Android),android,api,geolocation,mapbox,Android,Api,Geolocation,Mapbox,我在Android应用程序中使用MapBox,我需要修改用于指示当前用户位置和方向的标准蓝点 我发现这个线程表明过去的MapBox Android API提供了修改用户位置图标的方法: 该线程提到了以下方法: mapView.getUserLocationOverlay().setDirectionArrowBitmap(); mapView.getUserLocationOverlay().setPersonBitmap(); 最新的MapBox Android SDK没有显示这些方法。有
mapView.getUserLocationOverlay().setDirectionArrowBitmap();
mapView.getUserLocationOverlay().setPersonBitmap();
最新的MapBox Android SDK没有显示这些方法。有人知道这些方法的替代品或修改用户位置图标的替代品吗
maven归档文件在这里:MapBox回应了澄清这些方法的替代品的请求,说: 至于更改自定义标记的位置以显示移动,最好的办法是在需要显示进度时添加和删除标记。根据您需要刷新位置的速度,这种方法可能看起来有点不稳定,但在这一点上它是最好的解决方法。这将通过 及
这不是一个理想的解决方案,但现在应该可以完成这项工作。MapBox回应了澄清这些方法替代品的请求,称: 至于更改自定义标记的位置以显示移动,最好的办法是在需要显示进度时添加和删除标记。根据您需要刷新位置的速度,这种方法可能看起来有点不稳定,但在这一点上它是最好的解决方法。这将通过 及
这不是一个理想的解决方案,但现在应该可以完成这项工作。我添加了一个总线图标,您可以根据需要进行更改
@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);
}
}
我添加了一个总线图标,您可以根据需要进行更改
@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);
}
}
标记表示地图上的单个位置。您可以通过更改默认颜色或用自定义图像替换标记图标来自定义标记。信息窗口可以为标记提供附加上下文
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.removeMarkerView
说够了,让我们看看
好的,我们会检查的
这里什么都没有。
如果你看到
你需要
我查一下再答复
现在你可以
别担心
@Volatile
synchronized intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK.or(Intent.FLAG_ACTIVITY_CLEAR_TASK)
// for Log
public static final String TAG = MyApplication.class.getSimpleName();
标记表示地图上的单个位置。您可以通过更改默认颜色或用自定义图像替换标记图标来自定义标记。信息窗口可以为标记提供附加上下文
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.removeMarkerView
说够了,让我们看看
好的,我们会检查的
这里什么都没有。
如果你看到
你需要
我查一下再答复
现在你可以
别担心
@Volatile
synchronized intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK.or(Intent.FLAG_ACTIVITY_CLEAR_TASK)
// for Log
public static final String TAG = MyApplication.class.getSimpleName();