| | |
| | | projection: 'EPSG:4326', |
| | | // 设置缩放倍数 |
| | | zoom: 13, |
| | | minZoom: 6, |
| | | maxZoom: 20 |
| | | minZoom: 8, |
| | | maxZoom: 19 |
| | | }) |
| | | }) |
| | | _this.lineVector = new VectorLayer({ |
| | |
| | | this.lineVector.getSource().addFeature(feature_LineString); |
| | | } |
| | | }, |
| | | //添加点 |
| | | // 添加点 |
| | | addPoint(pointLonLat){ |
| | | if (pointLonLat){ |
| | | //设置点 |
| | |
| | | //点样式 |
| | | let style = new Style({ |
| | | image: new Icon({ |
| | | src: "/img/favicon.png", |
| | | src: "/img/dwicon.jpeg", |
| | | anchor: [0.48, 0.52], |
| | | scale:0.5 |
| | | // imgSize: [250,320], |
| | | scale: 0.2 |
| | | }), |
| | | }); |
| | | feature_Point.setStyle(style); |
| | | this.pointVector.getSource().addFeature(feature_Point); |
| | | var center = [Number(pointLonLat.lon), Number(pointLonLat.lat)]; |
| | | var view = this.map.getView(); |
| | | let center = [Number(pointLonLat.lon), Number(pointLonLat.lat)]; |
| | | let view = this.map.getView(); |
| | | view.setZoom(16); |
| | | view.animate({ |
| | | center: center, |
| | |
| | | if(!_this.showTip){ |
| | | _this.showTip = true |
| | | } |
| | | _this.tipTitle = "单击左键开始绘画"; |
| | | _this.tipTitle = "单击左键或者右键开始绘画" |
| | | //提示器 |
| | | $("#map").off("mousemove").mousemove(function (e) { |
| | | _this.setTipPosition(e.offsetX, e.offsetY, 5, 5); |
| | | }); |
| | | }) |
| | | $("#map").off("mousedown").mousedown(function () { |
| | | _this.tipTitle = "可继续,或选择最终位置双击结束绘画" |
| | | }) |
| | | |
| | | _this.draw = new Draw({ |
| | | source: _this.lineVector.getSource(), |
| | |
| | | _this.map.on('click', function (e) { |
| | | // 将点坐标保存集合 |
| | | _this.coordinates.push(e.coordinate) |
| | | _this.tipTitle = "可继续,或单击鼠标结束"; |
| | | }) |
| | | // 结束事件 |
| | | _this.draw.on('drawend', function () { |
| | |
| | | vectorLayer.getSource().addFeature(feature)// 将Feature对象填入图层源 |
| | | this.map.addLayer(vectorLayer) // 将图层添至地图对象 |
| | | }, |
| | | //画多边形 |
| | | // 画多边形 |
| | | drawPolygon(point) { |
| | | this.polygonPoints.push(point) |
| | | let feature = new Feature({ |
| | |
| | | |
| | | this.map.addLayer(clusters) |
| | | }, |
| | | // 重置图层 |
| | | clearDraw(){ |
| | | let _this = this |
| | | _this.coordinates = [] |
| | |
| | | // } |
| | | }) |
| | | }, |
| | | //设置提示位置 |
| | | // 设置提示位置 |
| | | setTipPosition(x, y, n, m) { |
| | | let _this = this |
| | | _this.tipPosition.w = x + n; |