如何增加Vaadin地图中的最大标记数?

发布于 2025-01-19 18:30:07 字数 417 浏览 5 评论 0原文

在Vaadin地图(Vaadin 23)中,我发现仅在地图上显示一定数量的标记。例如,我如何出现说500个标记(如下面的代码中的500个位置)?

locations.stream().forEach(location -> {
        Coordinate coordinate = Coordinate.fromLonLat(Double.parseDouble(location.getLon()), Double.parseDouble(location.getLat()));
        MarkerFeature customerMarker = new MarkerFeature(coordinate);
        map.getFeatureLayer().addFeature(customerMarker);
    });

In Vaadin Maps (Vaadin 23) I'm finding that only a certain number of markers are displayed on the map. How do I for example show up to say 500 markers (as in 500 locations in the code below)?

locations.stream().forEach(location -> {
        Coordinate coordinate = Coordinate.fromLonLat(Double.parseDouble(location.getLon()), Double.parseDouble(location.getLat()));
        MarkerFeature customerMarker = new MarkerFeature(coordinate);
        map.getFeatureLayer().addFeature(customerMarker);
    });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

許願樹丅啲祈禱 2025-01-26 18:30:07

感谢您查看新的地图组件。

您可以添加的标记数量不应受到任何限制,无论是来自 Vaadin 组件还是底层 OpenLayers 库。

以下是显示 500 个标记的示例:

int numMarkers = 500;
double x = 0;
double y = 0;

for (int i = 0; i < numMarkers; i++) {
    // Display ten rows of fifty markers
    if (i % 50 == 0) {
        y += 1000;
        x = 0;
    } else {
        x += 1000;
    }

    Coordinate coordinate = new Coordinate(x, y);
    MarkerFeature marker = new MarkerFeature(coordinate);

    map.getFeatureLayer().addFeature(marker);
}

在此处输入图像描述

您可以检查的一件事是所有位置是否实际上都有唯一的坐标,也许存在一些重叠。例如,如果经度/纬度超出范围,则使用 Cooperative.fromLonLat 方法来修剪值,在这种情况下,这会将多个标记放置在同一位置。

除此之外,您始终可以通过复制打开问题,我们会看一下。

thanks for checking out the new Map component.

There shouldn't be any limit to the number of markers that you can add, neither from the Vaadin component, nor the underlying OpenLayers library.

Here is an example that displays 500 markers:

int numMarkers = 500;
double x = 0;
double y = 0;

for (int i = 0; i < numMarkers; i++) {
    // Display ten rows of fifty markers
    if (i % 50 == 0) {
        y += 1000;
        x = 0;
    } else {
        x += 1000;
    }

    Coordinate coordinate = new Coordinate(x, y);
    MarkerFeature marker = new MarkerFeature(coordinate);

    map.getFeatureLayer().addFeature(marker);
}

enter image description here

One thing you could check is whether all locations actually have unique coordinates, maybe there are some overlaps. For example the Coordinate.fromLonLat method you use trims values if longitude/latitude are out of bounds, which would put multiple markers in the same location in that case.

Apart from that you can always open an issue with a reproduction, and we'll take a look.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文