嵌入式GeoJSON样式是否适用于Mapbox GL? [英] Do embedded GeoJSON styles work with Mapbox GL?

查看:122
本文介绍了嵌入式GeoJSON样式是否适用于Mapbox GL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以利用GeoJSON数据源的内置属性属性来自动设置Mapbox GL地图的样式而无需预先指定样式?

Is it possible to utilize the built-in properties attribute of a GeoJSON data source to automatically style a Mapbox GL map without having to pre-specify a style?

我有一个用例,我在GeoJSON LineString 中动态加载需要特定颜色的数据已经内置了样式数据:

I have a use case where I dynamically load in GeoJSON LineString data that needs to be a particular color and it already has style data built in:

{properties:{color:#ffff33...

现在,我有一个相当不优雅的设置,其中相关的颜色被解析出来,翻译成一种风格,并在每次加载时添加到地图中:

Right now, I have a rather inelegant setup where the relevant color is parsed out, translated into a style, and added to the map upon every load:

    $scope.patternPropToStyle = function(props) {
      var id = 'pattern' + props.pid;
      var style = {
        "id": id,
        "type": "line",
        "source": id,
        "render": {
          "$type": "LineString",
          "line-join": "round",
          "line-cap": "round"
        },
        "paint": {
          "line-color": props.color,
          "line-width": 8
        }
      }
      $scope._mapStyle.layers.push(style);
      $scope._map.setStyle($scope._mapStyle);
    }

我觉得必须有更好的方法来做到这一点。

I feel like there has to be a better way to do this.

推荐答案

目前,没有 - simplestyle-spec 。目前GeoJSON支持仍然非常原始,因为焦点最初是在矢量切片上。 simplestyle-spec支持肯定在计划中。

Currently, no - simplestyle-spec isn't supported in Mapbox GL. Currently the GeoJSON support is still very primitive, given that the focus was initially on vector tiles. simplestyle-spec support is certainly in the plans.

这篇关于嵌入式GeoJSON样式是否适用于Mapbox GL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆