如何添加point_count被某个值划分为映射

发布于 2025-02-11 08:45:07 字数 1095 浏览 2 评论 0原文

使用Mapbox GL JS,我想将其添加到地图上的群集中的标记数除以10。

我可以添加point_count和point_count_abbreviated属性如下:

map.addSource("uploaded-source", {
            type: "geojson",
            data: geoJSONcontent,
            cluster: true,
            clusterMaxZoom: 15, 
            clusterRadius: 50, 
          });

map.addLayer({
            id: "cluster-count",
            type: "symbol",
            source: "uploaded-source",
            filter: ["has", "point_count"],
            layout: {
              "text-field": "{point_count_abbreviated}",
              "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
              "text-size": 12,
            },
          });

我如何添加point_count_abbreviation dive dive dive dive subly MAP?

不幸的是,我的JS知识不是那么先进,我尝试了类似的事情:

 "text-field"://{point_count_abbreviated}/10
              //String(Number("{point_count_abbreviated}")/10),
              //"{point_count_abbreviated}".slice(0, -1),
              //String(Number(['/', ["get", Number("{point_count_abbreviated}")], Number(10)]))

Using Mapbox GL JS I want to add to the map the number of markers in a cluster divied by 10.

I can add the point_count and point_count_abbreviated attributes as following:

map.addSource("uploaded-source", {
            type: "geojson",
            data: geoJSONcontent,
            cluster: true,
            clusterMaxZoom: 15, 
            clusterRadius: 50, 
          });

map.addLayer({
            id: "cluster-count",
            type: "symbol",
            source: "uploaded-source",
            filter: ["has", "point_count"],
            layout: {
              "text-field": "{point_count_abbreviated}",
              "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
              "text-size": 12,
            },
          });

How do I add point_count_abbreviated divided by some number to the map?

Unfortunately my JS knowledge is not that advanced, I tried things like:

 "text-field"://{point_count_abbreviated}/10
              //String(Number("{point_count_abbreviated}")/10),
              //"{point_count_abbreviated}".slice(0, -1),
              //String(Number(['/', ["get", Number("{point_count_abbreviated}")], Number(10)]))

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

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

发布评论

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

评论(1

心碎无痕… 2025-02-18 08:45:07

您需要一个 mapbox gl expression

"text-field": ["/", ["get", "point_count"], 10]

我不确定是否需要将其转换为字符串。如果是这样:

"text-field": ["to-string", ["/", ["get", "point_count"], 10]]

You need a Mapbox GL expression.

"text-field": ["/", ["get", "point_count"], 10]

I'm not sure if it needs to be converted to a string. If so:

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