let layer=null;
if (data.status == 0) {
// 判断数据类型是否为天地图
if (data.target == "tiandidu") {
// 创建图层
layer = new TileLayer({
name: data.name,
id:data.serverid,
visible: false,
source: new XYZ({
url: data.url,
}),
});
}else if(data.target == "geojson"){
// 创建 VectorLayer 用于加载 GeoJSON
layer = new VectorLayer({
source: new VectorSource({
url: data.url, // 替换为您的 GeoJSON 服务 URL
format: new GeoJSON(),
}),
id:data.serverid,
style: new Style({
fill: new Fill({
color: '#ff00ff',
}),
// 样式-边框
stroke: new Stroke({
color: '#6600ff',
width: 2,
}),
// 使用 CircleStyle 创建一个圆形的点
image:new CircleStyle({
// 点样式
fill:new Fill({
color: 'rgba(255,0,0,0.4)',
}),
// 点周边样式
stroke:new Stroke({
color: '#3399CC',
uniapp 整合 openlayers 加载 天地图、geojson、wms、wfs、TMS数据
最新推荐文章于 2025-05-14 18:14:11 发布