我已经创建了一个网站 (https://webapps.fhsu.edu/ksHerp/alldata.aspx) 提取坐标位置信息(按所选物种过滤)和动态(基于下拉框中的所选值)在 Web 服务器上创建一个 geojson 文件,该文件被拉入 Mapbox 层以绘制点。
另外,我已经为所有物种创建了 shapefile,并且也想在地图上显示它们。
有没有办法在地图上动态显示形状文件?可以将 shapefile 上传到 Web 服务器,以便可以像 geojson(点)一样引用和访问它们吗?
我相信我可以将 shapefile 移动到 Mapbox 中的图块,但是,有将近 800 种|shapefile,每次更新它们在 Mapbox 中的维护都是一项重要任务。
这里是动态添加geojson层的代码。
var siteUrl = 'https://webapps.fhsu.edu/ksHerp/geojsonAll/349-870.geojson';
map.on('load', function () {
window.setInterval(function () {
map.getSource('markers').setData(siteUrl);
}, 2000);
map.on('load', function() {
map.addSource('terrain-tiles', {
"type": "raster-dem",
"url": "`mapbox://mapbox.mapbox-terrain-dem-v1",
});
map.setTerrain({ "source": "mapbox-dem"});
});
map.setTerrain({
'source': 'mapbox-dem',
'exaggeration': [
'interpolate', ['exponential', 1.5],
['zoom'], 0, 0.2, 7, 1
]
});
map.addSource('markers', { type: 'geojson', data: siteUrl });
map.addLayer({
'id': 'sky',
'type': 'sky',
'paint': {
'sky-type': 'atmosphere',
'sky-atmosphere-sun': [0.0, 0.0],
'sky-atmosphere-sun-intensity': 15
}
});
map.addLayer({
"id": "markers",
"type": "symbol",
"source": "markers",
"layout": {
"icon-image": "{marker-symbol}-11",
"icon-allow-overlap": true,
"text-field": "{title}",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top"
}
});
});
这就像将我的 shapefile 转换为 geoJson 一样简单吗?或者是否可以将它们保留为 shapefile(最好)。
谢谢。