Swanky 2 years ago
parent 944ddf8d66
commit 2ecc14e949
  1. 17
      components/layer-checkbox.vue
  2. 4
      manifest.json
  3. 127
      pages/index/index.vue

@ -32,7 +32,8 @@
<style scoped> <style scoped>
.checked { .checked {
border-color: #ff0 !important; border-color: #f00 !important;
/* border-width: 4px; */
color: #01D393 !important; color: #01D393 !important;
} }
@ -42,13 +43,13 @@
} }
.icon { .icon {
width: 72px; width: 60px;
height: 72px; height: 60px;
position: absolute; position: absolute;
left: -6px; left: 0;
right: -6px; right: 0;
top: -6px; top: 0;
bottom: -6px; bottom: 0;
} }
.check-icon { .check-icon {
@ -60,7 +61,7 @@
.content { .content {
width: 60px; width: 60px;
height: 60px; height: 60px;
border: 1px solid #ddd; border: 2px solid #dddddd00;
border-radius: 12px; border-radius: 12px;
margin-bottom: 8px; margin-bottom: 8px;
position: relative; position: relative;

@ -2,8 +2,8 @@
"name" : "草原管理", "name" : "草原管理",
"appid" : "__UNI__BBBC950", "appid" : "__UNI__BBBC950",
"description" : "", "description" : "",
"versionName" : "1.0.2", "versionName" : "1.0.4",
"versionCode" : 102, "versionCode" : 104,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
/* 5+App */ /* 5+App */

@ -22,7 +22,7 @@
</view> </view>
<view class="btn-location right-btn" @click="location"> <view class="btn-location right-btn" @click="location">
<image src="/static/dw.png" class="img-location" /> <image src="/static/dw.png" class="img-location" />
<view>定位</view> <view>{{locationing?'定位中':'定位'}}</view>
</view> </view>
<view class="btn-mjcl right-btn" @click="showJwdPopup"> <view class="btn-mjcl right-btn" @click="showJwdPopup">
<image src="/static/jwd.png" class="img-jwd" /> <image src="/static/jwd.png" class="img-jwd" />
@ -135,6 +135,7 @@
export default { export default {
data() { data() {
return { return {
locationing: false,
searchVisible: false, searchVisible: false,
searchValue: '', searchValue: '',
mapData: { mapData: {
@ -251,7 +252,7 @@
this.mapData = { this.mapData = {
center: [formData.longitude, formData.latitude, Math.random()] center: [formData.longitude, formData.latitude, Math.random()]
} }
this.$refs.jwdPopup.close(); this.$refs.jwdPopup.close();
return return
} }
console.log('error', err, formData) console.log('error', err, formData)
@ -384,14 +385,18 @@
console.log('查询值:' + res.value); console.log('查询值:' + res.value);
}, },
location() { location() {
this.locationing = true;
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
success: (res) => { success: (res) => {
console.log('当前位置的经度:' + res.longitude); console.log(res);
console.log('当前位置的纬度:' + res.latitude); this.locationing = false;
this.mapData = { this.mapData = {
center: [res.longitude, res.latitude, Math.random()] center: [res.longitude, res.latitude, Math.random()]
} }
},
fail: () => {
this.locationing = false;
} }
}); });
}, },
@ -515,10 +520,12 @@
} from 'ol/style' } from 'ol/style'
import helper from '../../common/helper'; import helper from '../../common/helper';
import { import {
Image Image,
Tile
} from 'ol/layer'; } from 'ol/layer';
import { import {
ImageWMS ImageWMS,
WMTS
} from 'ol/source'; } from 'ol/source';
import { import {
GeoJSON, GeoJSON,
@ -527,6 +534,9 @@
import { import {
getForViewAndSize getForViewAndSize
} from 'ol/extent'; } from 'ol/extent';
import {
WMTS as WMTSGrid
} from 'ol/tilegrid'
let map, vectorLayer; let map, vectorLayer;
export default { export default {
name: 'c-ol-map', name: 'c-ol-map',
@ -549,13 +559,26 @@
const pFeature = new Feature({ const pFeature = new Feature({
geometry: point geometry: point
}); });
pFeature.setStyle(new Style({ pFeature.setStyle([new Style({
image: new IconStyle({ image: new IconStyle({
src: './static/wz.png', src: './static/wz.png',
scale: 0.5, scale: 0.5,
anchor: [0.5, 0] anchor: [0.5, 1]
})
}) })
})) // , new Style({
// image: new CircleStyle({
// radius: 8,
// fill: new Fill({
// color: 'rgba(0,0,0,0)',
// }),
// stroke: new Stroke({
// width: 3,
// color: '#00ffff'
// }),
// })
// })
])
vectorLayer.getSource().clear(); vectorLayer.getSource().clear();
vectorLayer.getSource().addFeature(pFeature); vectorLayer.getSource().addFeature(pFeature);
map.getView().fit(point, { map.getView().fit(point, {
@ -571,23 +594,69 @@
return l.get('businessIndex') === opt.layerIndex; return l.get('businessIndex') === opt.layerIndex;
}) })
if (!layer) { if (!layer) {
layer = new Image({ if (opt.layerType === 'wmts') {
businessId: 'business-layer', var gridsetName = 'EPSG:4326';
businessName: opt.layerName, var gridNames = ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2', 'EPSG:4326:3',
businessIndex: opt.layerIndex, 'EPSG:4326:4', 'EPSG:4326:5', 'EPSG:4326:6', 'EPSG:4326:7',
source: new ImageWMS({ 'EPSG:4326:8', 'EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11',
ratio: 1, 'EPSG:4326:12', 'EPSG:4326:13', 'EPSG:4326:14', 'EPSG:4326:15',
url: `${opt.geoserverUrl}/geoserver/yzt/wms`, 'EPSG:4326:16', 'EPSG:4326:17', 'EPSG:4326:18', 'EPSG:4326:19',
params: { 'EPSG:4326:20', 'EPSG:4326:21'
'FORMAT': 'image/png', ];
'VERSION': '1.1.1', var resolutions = [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125,
"STYLES": opt.layerStyle || '', 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125,
"LAYERS": `${opt.layerWorkspace}:${opt.layerName}`, 0.001373291015625, 6.866455078125E-4, 3.4332275390625E-4,
"exceptions": 'application/vnd.ogc.se_inimage', 1.71661376953125E-4, 8.58306884765625E-5, 4.291534423828125E-5,
} 2.1457672119140625E-5, 1.0728836059570312E-5, 5.364418029785156E-6,
}), 2.682209014892578E-6, 1.341104507446289E-6, 6.705522537231445E-7,
zIndex: opt.zIndex 3.3527612686157227E-7
}); ];
// const url = `${opt.geoserverUrl}/geoserver/${opt.layerWorkspace}/gwc/service/wmts?layer=${opt.layerWorkspace}:${opt.layerName}&style=${opt.layerStyle||''}&tilematrixset=EPSG:4326&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:4326:{z}&TileCol={y}&TileRow={x}`
// console.log(url)
var source = new WMTS({
url: `${opt.geoserverUrl}/geoserver/${opt.layerWorkspace}/gwc/service/wmts`,
// url,
layer: `${opt.layerWorkspace}:${opt.layerName}`,
matrixSet: gridsetName,
format: 'image/png',
projection: "EPSG:4326",
tileGrid: new WMTSGrid({
tileSize: [256, 256],
extent: [-180.0, -90.0, 180.0, 90.0],
origin: [-180.0, 90.0],
resolutions: resolutions,
matrixIds: gridNames
}),
style: opt.layerStyle || '',
wrapX: true
});
layer = new Tile({
businessId: 'business-layer',
businessName: opt.layerName,
businessIndex: opt.layerIndex,
zIndex: opt.zIndex,
source
});
} else {
layer = new Image({
businessId: 'business-layer',
businessName: opt.layerName,
businessIndex: opt.layerIndex,
source: new ImageWMS({
ratio: 1,
url: `${opt.geoserverUrl}/geoserver/${opt.layerWorkspace}/wms`,
params: {
'FORMAT': 'image/png',
'VERSION': '1.1.1',
"STYLES": opt.layerStyle || '',
"LAYERS": `${opt.layerWorkspace}:${opt.layerName}`,
"exceptions": 'application/vnd.ogc.se_inimage',
}
}),
zIndex: opt.zIndex
});
}
businessLayers.push(layer); businessLayers.push(layer);
map.addLayer(layer); map.addLayer(layer);
} else { } else {

Loading…
Cancel
Save