|
@@ -317,6 +317,8 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
addIserverLayers() {
|
|
|
+ // 加载底图
|
|
|
+ this.loadiServerLayers(this.config.iServerUrl.baseMapLayers)
|
|
|
// 加载公房宗地图层
|
|
|
this.loadiServerLayers(this.config.iServerUrl.publicHouseLayers)
|
|
|
// 加载基础GIS图层
|
|
@@ -329,125 +331,67 @@ export default {
|
|
|
**/
|
|
|
getMap(options) {
|
|
|
if (!options) return;
|
|
|
- // 获取图层
|
|
|
- if (options.layers) {
|
|
|
- options.layers.forEach(element => {
|
|
|
- this.layers.push(
|
|
|
- new TileLayer({
|
|
|
- visible: element.visible,
|
|
|
- title: element.name,
|
|
|
- source: new XYZ({
|
|
|
- crossOrigin: 'anonymous', // 支持跨域
|
|
|
- url: element.url
|
|
|
- }),
|
|
|
- type: element.type,
|
|
|
- isGroup: element.isGroup,
|
|
|
- name: element.name
|
|
|
- })
|
|
|
- );
|
|
|
- });
|
|
|
+ // 获取鹰眼图层
|
|
|
+ let viewTileLayer = options.iServerUrl.baseMapLayers.filter(item => {
|
|
|
+ return item.name == '电子地图'
|
|
|
+ });
|
|
|
+ if (viewTileLayer.length > 0) {
|
|
|
this.viewTileLayers = [
|
|
|
new TileLayer({
|
|
|
- source: new OSM({
|
|
|
- url: options.layers[0].url
|
|
|
- })
|
|
|
- }),
|
|
|
- new TileLayer({
|
|
|
- source: new OSM({
|
|
|
- url: options.layers[3].url
|
|
|
+ source: new TileSuperMapRest({
|
|
|
+ url: viewTileLayer[0].url,
|
|
|
+ crossOrigin: 'anonymous'
|
|
|
})
|
|
|
})
|
|
|
- ];
|
|
|
+ ]
|
|
|
}
|
|
|
|
|
|
- // if (options.image && options.image.layers) {
|
|
|
- // const version = options.image.params.VERSION;
|
|
|
- // options.image.layers.forEach(item => {
|
|
|
- // this.layers.push(
|
|
|
- // new ImageLayer({
|
|
|
- // source: new ImageWMS({
|
|
|
- // url: options.image.url,
|
|
|
- // params: {
|
|
|
- // LAYERS: item.layerName,
|
|
|
- // VERSION: version
|
|
|
- // },
|
|
|
- // crossOrigin: 'anonymous'
|
|
|
- // }),
|
|
|
- // name: item.name,
|
|
|
- // visible: item.visible
|
|
|
- // })
|
|
|
- // );
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
- if (options.view) {
|
|
|
- this.view = new View({
|
|
|
- center: options.view.center,
|
|
|
- // projection: this.projection,
|
|
|
- projection: "EPSG:4326",
|
|
|
- zoom: options.view.zoom,
|
|
|
- maxZoom: 23,
|
|
|
- constrainResolution: true
|
|
|
- });
|
|
|
- this.params.mapView = this.view;
|
|
|
- }
|
|
|
+ this.view = new View({
|
|
|
+ center: [104.753586, 31.521350],
|
|
|
+ // projection: this.projection,
|
|
|
+ projection: "EPSG:4326",
|
|
|
+ zoom: 15,
|
|
|
+ maxZoom: 23,
|
|
|
+ minZoom: 13,
|
|
|
+ constrainResolution: true
|
|
|
+ });
|
|
|
+ this.params.mapView = this.view;
|
|
|
},
|
|
|
/**
|
|
|
* 获取地图工具
|
|
|
**/
|
|
|
getMapTools(options) {
|
|
|
const arrControls = [];
|
|
|
- if (!options.maptools) return;
|
|
|
-
|
|
|
- if (
|
|
|
- options.maptools.ScaleLine &&
|
|
|
- options.maptools.ScaleLine.isExistence
|
|
|
- ) {
|
|
|
- // 添加比例尺
|
|
|
- arrControls.push(
|
|
|
- new ScaleLine({
|
|
|
- units: 'metric',
|
|
|
- target: this.$refs['tofly-map-ScaleLine']
|
|
|
- })
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- options.maptools.MousePosition &&
|
|
|
- options.maptools.MousePosition.isExistence
|
|
|
- ) {
|
|
|
- // 添加鼠标位置
|
|
|
- arrControls.push(
|
|
|
- new MousePosition({
|
|
|
- coordinateFormat: coordinate => {
|
|
|
- return format(coordinate, '经度:{x} 纬度:{y}', 6);
|
|
|
- }, // 保留6位小数位
|
|
|
- target: this.$refs['tofly-map-MousePosition']
|
|
|
- })
|
|
|
- );
|
|
|
- }
|
|
|
|
|
|
- if (
|
|
|
- options.maptools.OverviewMap &&
|
|
|
- options.maptools.OverviewMap.isExistence
|
|
|
- ) {
|
|
|
- if (this.viewTileLayers.length > 0) {
|
|
|
- // 添加一个鹰眼控件
|
|
|
- arrControls.push(
|
|
|
- new OverviewMap({
|
|
|
- // className: "ol-overviewmap ol-custom-overviewmap tofly-overviewmap", //鹰眼控件样式
|
|
|
- target: this.$refs['tofly-map-OverviewMap'],
|
|
|
- // 在鹰眼中加载相同坐标系下不同数据源的图层
|
|
|
- layers: this.viewTileLayers,
|
|
|
- collapseLabel: '', // 鹰眼控件展开时功能按钮上的标识
|
|
|
- label: '', // 鹰眼控件折叠时功能按钮上的标识
|
|
|
- collapsed: options.maptools.OverviewMap.collapsed, // 初始为展开方式
|
|
|
- tipLabel: '鹰眼'
|
|
|
- // className:"ol-overviewmap iconfont iconyy"
|
|
|
- })
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
+ // 添加比例尺
|
|
|
+ arrControls.push(
|
|
|
+ new ScaleLine({
|
|
|
+ units: 'metric',
|
|
|
+ target: this.$refs['tofly-map-ScaleLine']
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ // 添加鼠标位置
|
|
|
+ arrControls.push(
|
|
|
+ new MousePosition({
|
|
|
+ coordinateFormat: coordinate => {
|
|
|
+ return format(coordinate, '经度:{x} 纬度:{y}', 6);
|
|
|
+ }, // 保留6位小数位
|
|
|
+ target: this.$refs['tofly-map-MousePosition']
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ // 添加一个鹰眼控件
|
|
|
+ arrControls.push(
|
|
|
+ new OverviewMap({
|
|
|
+ target: this.$refs['tofly-map-OverviewMap'],
|
|
|
+ layers: this.viewTileLayers,
|
|
|
+ collapseLabel: '',
|
|
|
+ label: '',
|
|
|
+ collapsed: false,
|
|
|
+ tipLabel: '鹰眼'
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
if (arrControls && arrControls.length > 0) {
|
|
|
this.controls = defaults({
|
|
@@ -462,56 +406,12 @@ export default {
|
|
|
*/
|
|
|
ResetMap() {
|
|
|
// 重置中心点位置为初始化位置
|
|
|
- this.view.setZoom(this.config.view.zoom);
|
|
|
+ this.view.setZoom(15);
|
|
|
this.view.animate({
|
|
|
- center: this.config.view.center,
|
|
|
+ center: [104.753586, 31.521350],
|
|
|
duration: 600
|
|
|
});
|
|
|
},
|
|
|
- /**
|
|
|
- * 鹰眼
|
|
|
- */
|
|
|
- initOverviewMap() {
|
|
|
- var overview = new Map({
|
|
|
- target: 'overview',
|
|
|
- layers: this.viewTileLayers,
|
|
|
- view: new View({
|
|
|
- // projection: this.projection,
|
|
|
- projection: "EPSG:4326",
|
|
|
- center: [104.053277, 30.658171],
|
|
|
- zoom: 11,
|
|
|
- maxZoom: 11,
|
|
|
- minZoom: 11
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- var extent = this.map.getView().calculateExtent(this.map.getSize());
|
|
|
- var coor = [
|
|
|
- [
|
|
|
- [extent[0], extent[1]],
|
|
|
- [extent[2], extent[1]],
|
|
|
- [extent[2], extent[3]],
|
|
|
- [extent[0], extent[3]],
|
|
|
- [extent[0], extent[1]]
|
|
|
- ]
|
|
|
- ];
|
|
|
- var polygonFeature = new Feature(new Polygon(coor));
|
|
|
- var vectorSource = new Vector({
|
|
|
- features: [polygonFeature]
|
|
|
- });
|
|
|
-
|
|
|
- var vectorLayer = new Vector({
|
|
|
- source: vectorSource,
|
|
|
- style: new Style({
|
|
|
- fill: new Fill({ color: 'rgba(160,160,160,0.2)' }),
|
|
|
- stroke: new Stroke({
|
|
|
- color: 'white',
|
|
|
- width: 2
|
|
|
- })
|
|
|
- })
|
|
|
- });
|
|
|
- overview.addLayer(vectorLayer);
|
|
|
- },
|
|
|
/**
|
|
|
* 加载iserver服务图层
|
|
|
*/
|