diff --git a/src/components/Map/MapGisObtain.vue b/src/components/Map/MapGisObtain.vue index 47b9b87a..2f813638 100644 --- a/src/components/Map/MapGisObtain.vue +++ b/src/components/Map/MapGisObtain.vue @@ -72,27 +72,28 @@ export default { name: "天地图文字标注--卫星影像图", resolution:Math.random() * 0.00000001 }); + //加载地图 + that.map = new ol.Map({ + controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮 + layers: [aerial, yingxzi], + projection: projection, + target: that.uuidMap, + view: new ol.View({ + //center: ol.proj.fromLonLat([115.452752, 31.789033]), + zoom: 15, + minZoom: 5, //地图缩小限制 + maxZoom: 18.3, //地图放大限制 + }), + interactions: ol.interaction.defaults({ + pinchRotate: false // 移动端禁止地图旋转 + }), + //view: new ol.View({ol.view.getResolution() + Math.random() * 0.00000001)});//随机数缩放实现刷新 + }); if (response.data.length > 0) { //setTimeout(() => { for (var i = 0; response.data.length > i; i++) { - //加载地图 - that.map = new ol.Map({ - controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]), //隐藏放大缩小按钮 - layers: [aerial, yingxzi], - projection: projection, - target: that.uuidMap, - view: new ol.View({ - //center: ol.proj.fromLonLat([115.452752, 31.789033]), - zoom: 15, - minZoom: 5, //地图缩小限制 - maxZoom: 18.3, //地图放大限制 - }), - interactions: ol.interaction.defaults({ - pinchRotate: false // 移动端禁止地图旋转 - }), - //view: new ol.View({ol.view.getResolution() + Math.random() * 0.00000001)});//随机数缩放实现刷新 - }); //图层查询定位开始 ---------start + console.log( response.data[i].zjdzd.theGeom); hc_land = new ol.layer.Vector({ title: "add Layer", source: new ol.source.Vector({ @@ -121,6 +122,7 @@ export default { var minYMap = hc_land.values_.source.featuresRtree_.rbush_.data.minY; //定位查询位置 var center = ol.extent.getCenter([maxXMap, maxYMap, minXMap, minYMap]); //获取边界区域的中心位置 + console.log(center); that.map.getView().animate({ // 只设置需要的属性即可 center: center, // 中心点 @@ -130,45 +132,64 @@ export default { resolution:Math.random() * 0.00000001, }); } - that.map.on("singleclick", function (evt) { - console.info(1111111); - let feature = that.map.forEachFeatureAtPixel( - evt.pixel, - (feature) => feature - ); - document.getElementById(that.uuidMap).innerHTML = ''; - - if (feature) { - that.map.removeLayer(geo_zjdzd); - this.closeMoule= null; - //图层查询定位开始 ---------start - geo_zjdzd = new ol.layer.Vector({ - title: "add Layer", - source: new ol.source.Vector({ - projection: projection, - features: new ol.format.GeoJSON().readFeatures("{\n" + - " \"type\": \"Feature\",\n" + - " \"geometry\":" + feature.values_.zjdzd.theGeom + "}"), - }), - style: new ol.style.Style({ - fill: new ol.style.Fill({ - //矢量图层填充颜色,以及透明度 - color: "rgb(204, 255, 255,0.5)", - }), - stroke: new ol.style.Stroke({ - //边界样式 - color: "#00FFFF", - width: 8, - }), - }), - }); - that.map.addLayer(geo_zjdzd); - that.closeMoule = feature.values_.zjddm; - } - }); } var geo_zjdzd; - console.log("1111"); + that.map.on("singleclick", function (evt) { + let feature = that.map.forEachFeatureAtPixel( + evt.pixel, + (feature) => feature + ); + //document.getElementById(that.uuidMap).innerHTML = ''; + if (feature && (feature !==undefined)) { + that.map.removeLayer(geo_zjdzd); + var aleft = []; + for(var i=0;i - - - + + +