Android: Here maps sdk 的地图显示的坐标不准确

Android: Here maps sdk's map is showing not accurate coordinates

我在我的项目中使用 Android 的 HERE Maps Lite SDK 作为库。 我想显示 MapView,并在我的数据库中添加所有避难所的特定坐标的叠加层。 该地图运行良好,但显示的坐标不准确。我尝试对经纬度网站中的坐标进行地理编码,它们是正确的,但在地图中它们显示为正确的真实位置。

我的代码:

 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shelters_map);
        mapView = findViewById(R.id.mapview);
        mapView.onCreate(savedInstanceState);
        ActivityCompat.requestPermissions(SheltersMapActivity.this, new String[] {
                Manifest.permission.ACCESS_FINE_LOCATION}, 123);
        if (ContextCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION)
                != PackageManager.PERMISSION_GRANTED) {
            // Permission is not granted
            Toast.makeText(getApplicationContext(), "אנא אפשר גישה לשירותי מיקום", Toast.LENGTH_SHORT).show();
            ActivityCompat.requestPermissions(this,
                    new String[]{ACCESS_FINE_LOCATION},
                    1);
        } else // premission is granted
        {
            GPStracker g = new GPStracker(getApplicationContext());
            userLocation = g.getLocation();
        }
        loadMapScene();
        addSheltersOverlay();
        // loadMapScene();


    }

    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) {
                    mapView.getCamera().setTarget(new GeoCoordinates(userLocation.getLatitude(),
                            userLocation.getLongitude()));
                    mapView.getCamera().setZoomLevel(15);
                } else {
                    Log.d("data1", "onLoadScene failed: " + errorCode.toString());
                }
            }
        });
    }

    private void addSheltersOverlay() {
        db = new DatabaseHandler(this);
        ArrayList<Shelter> places = this.db.getAllPlaces();
        Shelter userLocationPlace = new Shelter("המיקום שלך", "", userLocation, null, 0, "");
        places.add(userLocationPlace);
        int size = places.size();
        for(int i = 0; i < size; i++) {
            TextView textView = new TextView(this);
            textView.setTextColor(Color.parseColor("#FFFFFF"));
            textView.setText(places.get(i).getName());

            LinearLayout linearLayout = new LinearLayout(this);
            if (places.get(i) instanceof Basement)
                linearLayout.setBackgroundColor(Color.BLACK);
            else if (places.get(i) instanceof Stairs)
                linearLayout.setBackgroundColor(Color.GREEN);
            else
                linearLayout.setBackgroundColor(Color.BLUE);
            linearLayout.setPadding(10, 10, 10, 10);
            linearLayout.addView(textView);

            GeoCoordinates geoCoordinates = new GeoCoordinates(places.get(i).getLocation().getLatitude(),
                    places.get(i).getLocation().getLongitude());
            MapOverlay<LinearLayout> mapOverlay = new MapOverlay<>(linearLayout, geoCoordinates);

            mapView.addMapOverlay(mapOverlay);
        }
    }

显示的地图:

.

我可以在显示的地图中看到街道名称,但我发现它不是准确的点。 有人帮忙吗?

从代码来看它看起来是正确的,但我看不到位置与预期位置。默认情况下,MapOverlays 以坐标为中心绘制。您可以设置锚点以相对于坐标移动叠加层。如果数据库中的坐标与地图上的位置之间始终存在偏移,这可能会有所帮助。

也许,您可以尝试在地图上预期位置渲染一个小的 MapCircle 项目吗?然后您可以更轻松地查看该位置在地图上的位置。您可以将结果与 https://www.latlong.net/.

进行比较