简体   繁体   English

以线为中心放置的符号不会随着地图旋转而旋转

[英]Symbol placed with line-center doesn't rotate as the map rotates

I'm having a problem rotating an image with property symbol-placement set to line-center .我在旋转属性symbol-placement设置为line-center的图像时遇到问题。 This is what it looks like这是它的样子

在此处输入图片说明

Removing the property half-solve the issue;移除财产就解决了一半的问题; the icon rotate as I rotate the map, but they position at the start of the line, and it's not what I'm trying to do.图标随着我旋转地图而旋转,但它们位于行的开头,这不是我想要做的。

在此处输入图片说明

The definition of my layer is:我的层的定义是:

{
  "id": "my_symbol",
  "type": "symbol",
  "source": "XXXX",
  "source-layer": "XXXXXXX",
  "minzoom": 19,
  "layout": {
    "symbol-placement": "line-center",
    "icon-size": {
      "stops": [
        [20, 0.2],
        [21, 0.1],
        [22, 0.3],
        [23, 0.5],
        [24, 0.7]
      ]
    },
    "icon-image": [
      "concat",
      "edge_",
      ["get", "status_list"]
    ],
    "icon-allow-overlap": true
  }
}

I'm trying to achieve this behaviour only by the layer's definition.我试图仅通过层的定义来实现这种行为。 I tried looking for a solution, here on SO and on some other sites but I haven't found anything that would help me.我试图在 SO 和其他一些网站上寻找解决方案,但我没有找到任何可以帮助我的东西。

you can set your icon rotation with icon-rotation-alignment您可以使用icon-rotation-alignment设置图标旋转

setting it to viewport will fix the icon rotation to your viewport while setting it to map won't rotate it将其设置为viewport会将图标旋转固定到您的视口,而将其设置为map不会旋转它

在此处输入图片说明

i'm sorry the gif is hard to see!很抱歉 gif 很难看!

{
  "id": "my_symbol",
  "type": "symbol",
  "source": "XXXX",
  "source-layer": "XXXXXXX",
  "minzoom": 19,
  "layout": {
    "symbol-placement": "line-center",
    "icon-size": {
      "stops": [
        [20, 0.2],
        [21, 0.1],
        [22, 0.3],
        [23, 0.5],
        [24, 0.7]
      ]
    },
    "icon-image": [
      "concat",
      "edge_",
      ["get", "status_list"]
    ],
    "icon-allow-overlap": true,
    "symbol-placement": "line-center",
    "icon-rotation-alignment": "viewport"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM