且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JavaFX创建交互式地图

更新时间:2022-12-03 18:15:53

您的问题有点难以回答,因为您没有告诉我们您的地图是如何绘制的以及您已经绘制了什么了解地图上显示的几何图形。如果您只有地图的光栅图像,例如从纸质地图扫描,然后事情变得复杂。
对于类似的任务,我首先编写了一个程序来对地图进行地理参考,并以多边形的形式确定有趣区域的轮廓。
然后我使用多边形在地图显示上绘制轮廓。我为每个多边形添加了监听器,以便在鼠标进入或退出某个区域时收到通知。

Your question is a little bit difficult to answer because you do not tell us how your map is drawn and what you already know about the geometry shown on the map. If you only have a raster image of your map, e.g. scanned from a paper map, then things are getting complicated. For a similar task I first wrote a program to geo-reference the map and determine the outlines of the interesting areas in the form of polygons. Then I used the polygons to draw the outlines on the map display. I added listeners to each polygon so that I am notified when the mouse enters or exits an area.