为模拟复制点层
Duplicating Point Layer for Simulation
我正在尝试模拟城市交通运动(目前我只研究车辆),但我遇到了问题。
我试图在地图上的每个点模拟 1 辆车,但我不知道如何复制某个层(并且每个层都有不同的路线),例如这个:
map.addSource('point', {
"type": "geojson",
"data": pointOnCircle(0)
});
map.addLayer({
"id": "point",
"source": "point",
"type": "circle",
"paint": {
"circle-radius": 10,
"circle-color": "#007cbf"
}
});
我不知道我是否可以循环生成 N 个不同名称的点,或者以其他方式进行。
这是我到目前为止所做的视频(为了模拟它,我创建了 2 个不同的图层,因为我不知道如何复制它们):
您应该将所有点放在一个数据层中:
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
]
}
}
]
}
我正在尝试模拟城市交通运动(目前我只研究车辆),但我遇到了问题。
我试图在地图上的每个点模拟 1 辆车,但我不知道如何复制某个层(并且每个层都有不同的路线),例如这个:
map.addSource('point', {
"type": "geojson",
"data": pointOnCircle(0)
});
map.addLayer({
"id": "point",
"source": "point",
"type": "circle",
"paint": {
"circle-radius": 10,
"circle-color": "#007cbf"
}
});
我不知道我是否可以循环生成 N 个不同名称的点,或者以其他方式进行。
这是我到目前为止所做的视频(为了模拟它,我创建了 2 个不同的图层,因为我不知道如何复制它们):
您应该将所有点放在一个数据层中:
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
]
}
}
]
}