gpt4 book ai didi

java - getMapPostition 返回空值

转载 作者:行者123 更新时间:2023-11-30 10:31:01 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com