首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模拟中的复制点层

模拟中的复制点层
EN

Stack Overflow用户
提问于 2017-10-06 19:25:16
回答 1查看 38关注 0票数 0

我试图模拟城市交通的运动(目前我只喜欢车辆),但我有一个问题。

所发生的是,我试图在地图上每点模拟一辆汽车,但我不知道如何复制某一层(每个层都有不同的路径),例如这个:

代码语言:javascript
复制
map.addSource('point', {
    "type": "geojson",
    "data": pointOnCircle(0)
});

map.addLayer({
    "id": "point",
    "source": "point",
    "type": "circle",
    "paint": {
        "circle-radius": 10,
        "circle-color": "#007cbf"
    }
});

我不知道我是否可以用不同的名字循环和生成N个点,或者用另一种方式来做。

下面是我迄今为止所做工作的视频(为了模拟它,我创建了两个不同的层,因为我不知道如何复制它们):

https://www.youtube.com/watch?v=xWZD9aBUFlg

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-09 00:08:45

您应该将所有的点放在一个数据层中:

代码语言:javascript
复制
map.addSource('points', {
    "type": "geojson",
    "data": pointsOnCircle(0) // change this function to return multiple features
});

map.addLayer({
    "id": "points",
    "source": "points",
    "type": "circle",
    "paint": {
        "circle-radius": 10,
        "circle-color": "#007cbf" // possibly make this a data-driven function
    }
});

您的GeoJSON数据源如下所示:

代码语言:javascript
复制
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          146.25,
          -37.16031654673676
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          138.515625,
          35.460669951495305
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          -81.5625,
          33.43144133557529
        ]
      }
    }
  ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46612645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档