我试图模拟城市交通的运动(目前我只喜欢车辆),但我有一个问题。
所发生的是,我试图在地图上每点模拟一辆汽车,但我不知道如何复制某一层(每个层都有不同的路径),例如这个:
map.addSource('point', {
"type": "geojson",
"data": pointOnCircle(0)
});
map.addLayer({
"id": "point",
"source": "point",
"type": "circle",
"paint": {
"circle-radius": 10,
"circle-color": "#007cbf"
}
});我不知道我是否可以用不同的名字循环和生成N个点,或者用另一种方式来做。
下面是我迄今为止所做工作的视频(为了模拟它,我创建了两个不同的层,因为我不知道如何复制它们):
发布于 2017-10-09 00:08:45
您应该将所有的点放在一个数据层中:
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数据源如下所示:
{
"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
]
}
}
]
}https://stackoverflow.com/questions/46612645
复制相似问题