android - 地图上的标记在这里 sdk android - 'com.here.sdk.mapviewlite.MapMarker' 中的受保护访问
问题描述
我收到此消息: MapMarker(long, java.lang.Object)' has protected access in 'com.here.sdk.mapviewlite.MapMarker'
在这一行:
MapMarker mapMarker = new MapMarker(geoCoordinates, mapImage);
我正在寻找的是添加当前位置的标记。因为你所在的地方在地图上显示但没有具体显示
public class MainActivity extends AppCompatActivity implements LocationListener {
private static final String TAG = MainActivity.class.getSimpleName();
private PermissionsRequestor permissionsRequestor;
private MapViewLite mapView;
private MapObjectsExample mapObjectsExample;
protected LocationManager locationManager;
double latitud, longitud;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
latitud=location.getLatitude();
longitud=location.getLongitude();
mapView = findViewById(R.id.map_view);
mapView.onCreate(savedInstanceState);
handleAndroidPermissions();
}
private void handleAndroidPermissions() {
permissionsRequestor = new PermissionsRequestor(this);
permissionsRequestor.request(new PermissionsRequestor.ResultListener() {
@Override
public void permissionsGranted() {
loadMapScene();
}
@Override
public void permissionsDenied() {
Log.e(TAG, "Permissions denied by user.");
}
});
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
permissionsRequestor.onRequestPermissionsResult(requestCode, grantResults);
}
private void loadMapScene() {
// Load a scene from the SDK to render the map with a map style.
mapView.getMapScene().loadScene(MapStyle.NORMAL_DAY, new MapScene.LoadSceneCallback() {
@Override
public void onLoadScene(@Nullable MapScene.ErrorCode errorCode) {
if (errorCode == null) {
mapObjectsExample = new MapObjectsExample(mapView);
GeoCoordinates geoCoordinates=new GeoCoordinates( latitud,longitud);
MapImage mapImage = MapImageFactory.fromResource(getApplicationContext().getResources(), R.drawable.here_car);
MapMarker mapMarker = new MapMarker(geoCoordinates, mapImage);
mapView.getMapScene().addMapMarker(mapMarker);
mapView.getCamera().setTarget(new GeoCoordinates( latitud,longitud));
mapView.getCamera().setZoomLevel(15);
} else {
Log.d(TAG, "onLoadScene failed: " + errorCode.toString());
}
}
});
}
我该如何解决?
解决方案
推荐阅读
- php - 理解流明语法:router->get()
- c++ - c++ boost http程序,什么是“需要缓冲区”错误?
- reactjs - 如何在redux中为同一个查询存储多个结果
- angularjs - 在同一个控制器中重复使用模板两次,但显示不同的数据
- windows - CMD 脚本在星期一复制 Fridays 文件
- istio - 安装 istioctl 1.4.0 抛出“错误:缺少图表元数据 (Chart.yaml)”
- bluetooth-lowenergy - 如何在没有嗅探器的情况下在 linux 中捕获/转储蓝牙 LE 链路层数据包?
- react-native - 如何在本机反应中进行多重导航?
- angular - 在 Angular 中启用 HashLocationStrategy 时,Okta 重定向 URL 不起作用
- javascript - Django 与 JS 的集成