【问题标题】:MapBox User Location Icon (Android)MapBox 用户位置图标 (Android)
【发布时间】:2016-02-12 04:17:34
【问题描述】:
【问题讨论】:
标签:
android
api
geolocation
mapbox
【解决方案1】:
MapBox 回应了澄清这些方法的替代品的请求,并表示:
至于更改自定义标记的位置以显示运动,最好的办法是在需要显示进度时添加和删除标记。根据您需要多快刷新位置,这种方法可能看起来有点不稳定,但这是目前最好的解决方法。这将通过
MapView.addMarker()
和
MapView.removeAnnotation()
这不是一个理想的解决方案,但现在应该可以完成工作。
【解决方案2】:
我添加了一个巴士图标,您可以随意更改它。
@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);
}
}
【解决方案3】:
标记表示地图上的单个位置。您可以通过更改默认颜色或将标记图标替换为自定义图像来自定义标记。信息窗口可以为标记提供额外的上下文。
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);
废话不多说,让我们看看
好的,我们会检查的
这里什么都没有。
如果你看到
你需要
我会检查并回复
现在你可以
别担心
@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();