Przeglądaj źródła

新增初始化数据到村

wulanhaote
hbao 3 lat temu
rodzic
commit
d93ebc212e
1 zmienionych plików z 103 dodań i 29 usunięć
  1. +103
    -29
      src/components/Map/MapGisDrawing.vue

+ 103
- 29
src/components/Map/MapGisDrawing.vue Wyświetl plik

@@ -272,37 +272,111 @@ export default {
isGroup: true,
name: "天地图文字标注--卫星影像图",
});

//加载地图
map = new ol.Map({
controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
layers: [aerial, yingxzi],
projection: projection,
logo: 'false',
target: that.uuidMap,
view: new ol.View({
//center: ol.proj.fromLonLat(Zb),
//center: ol.proj.fromLonLat([115.452752, 31.789033]),
zoom: 16.9,
minZoom: 5, //地图缩小限制
maxZoom: 18, //地图放大限制
}),
});
//获取坐标是否存在
var Zb;
getQueryLand().then((response) => {
if (response.code == 200) {
let InsertCode = response.data;
if (InsertCode != null) {
var lat = InsertCode.lat;
var lng = InsertCode.lng;
if(lat !=null && lng !=null && lat !="" && lng !=""){
Zb = [lng,lat];
}else {
Zb =[115.452752, 31.789033];
}
//加载地图
map = new ol.Map({
controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
layers: [aerial, yingxzi],
projection: projection,
logo: 'false',
target: that.uuidMap,
view: new ol.View({
center: ol.proj.fromLonLat(Zb),
//center: ol.proj.fromLonLat([115.452752, 31.789033]),
zoom: 16.9,
minZoom: 5, //地图缩小限制
maxZoom: 18, //地图放大限制
}),
});
}
}
//var Zb;
//村边界查询开始 ------------------------------start
var cql_filter = "dept_id='" + that.$cookies.get("item").deptId + "'";
var cunTc= new ol.layer.Tile({
source: new ol.source.TileWMS({
url: "http://116.255.223.226:8080/geoserver/zjd_dc/wms",
params: {
LAYERS: 'zjd_dc:t_house_survey_border_village',
TILED: true,
cql_filter: cql_filter,
SRID: 3857,
},
}),
});
//定位查询位置
let param_dw = {
srsName: "EPSG:3857",
service: "WFS",
version: "1.0.0",
request: "GetFeature",
typename: "zjd_dc:t_house_survey_border_village",
//featureNS: 'nsgk_hc',//命名空间 URI
cql_filter: cql_filter,
//featurePrefix: 'nationalwater',//工作区名称
//featureTypes: ['nationalwater:01fir'],//查询图层,可以是同一个工作区下多个图层,逗号隔开
outputFormat: "application/json",
//filter: ol.format.filter.equalTo(t,e,r)//前者是属性名,后者是对应值
};
let url_dw = "http://116.255.223.226:8080/geoserver/zjd_dc/wfs"; //wfsurl;
url_dw = url_dw + "?";
for (let key in param_dw) {
url_dw = url_dw + key + "=" + param_dw[key] + "&";
}
url_dw = url_dw.substr(0, url_dw.length - 1);
fetch(url_dw, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
})
.then((res) => {
var geojsonmap = res.json();
return geojsonmap;
})
.then((data) => {
console.log(data);
let resolution = map.getView().getResolutionForExtent(data.bbox,map.getSize());
map.getView().fit(data.bbox);
map.getView().setResolution(resolution);
// var datamap = data.bbox;
// var center = ol.extent.getCenter(datamap);
// map.getView().animate({
// // 只设置需要的属性即可
// center: center, // 中心点
// rotation: undefined, // 缩放完成view视图旋转弧度
// });
})
.catch((error) => {
console.log("【异常】", error);
});
map.addLayer(cunTc);
//村边界查询开始 ------------------------------end
// getQueryLand().then((response) => {
// if (response.code == 200) {
// let InsertCode = response.data;
// if (InsertCode != null) {
// var lat = InsertCode.lat;
// var lng = InsertCode.lng;
// if(lat !=null && lng !=null && lat !="" && lng !=""){
// Zb = [lng,lat];
// }else {
// Zb =[115.452752, 31.789033];
// }
// //加载地图
// map = new ol.Map({
// controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮
// layers: [aerial, yingxzi],
// projection: projection,
// logo: 'false',
// target: that.uuidMap,
// view: new ol.View({
// center: ol.proj.fromLonLat(Zb),
// //center: ol.proj.fromLonLat([115.452752, 31.789033]),
// zoom: 16.9,
// minZoom: 5, //地图缩小限制
// maxZoom: 18, //地图放大限制
// }),
// });
// }
// }
// });

//图层查询定位结束 ---------end
//开始绘制地图


Ładowanie…
Anuluj
Zapisz