Point da = map1().getMapPosition(48.922499263758255, 16.875);
System.out.println(da);
有人可以帮助我吗?我想使用此 getMapPosition
将坐标转换为点,但无论我做什么,它都会给我一个 null
值。为什么会这样?
谢谢。
最佳答案
快速查看相关JMapViewer
源代码显示您对 getMapPosition()
的调用调用附近的重载,其中 checkOutside
设置为 true
。如果坐标对应的Point
在可见 map 之外,则结果为null
。
if (checkOutside && (p.x < 0 || p.y < 0 || p.x > getWidth() || p.y > getHeight())) {
return null;
}
相反,使用允许您将 checkOutside
显式设置为 false
的实现之一。例如,
Point da = map1().getMapPosition(48.9225, 16.875, false);
或
Coordinate coord = new Coordinate(48.9225, 16.875);
Point da = map1().getMapPosition(coord, false);
关于java - getMapPostition 返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43463367/