修复slot-scope record版本不匹配bug
This commit is contained in:
parent
8e195777e0
commit
4cf26ef260
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fromLonLat, toLonLat } from "ol/proj.js";
|
||||
const { fromLonLat, toLonLat } = ol.proj
|
||||
import { PointSelect } from "@/components/utils/olInteraction";
|
||||
import { deleteJSON, postJSON, URL_MAP } from "@/utils/http";
|
||||
let mapForSelect = null
|
||||
@ -73,17 +73,23 @@ export default {
|
||||
}))
|
||||
},
|
||||
init() {
|
||||
var osm = new ol.source.OSM();
|
||||
var layer = new ol.layer.Tile({
|
||||
source: osm,
|
||||
wrapX: false,
|
||||
this.projection = ol.proj.get("EPSG:3857");
|
||||
var AMapLayer = new ol.layer.Tile({
|
||||
// source: new ol.source.XYZ({
|
||||
// url:
|
||||
// "http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}",
|
||||
// }),
|
||||
source: new ol.source.XYZ({
|
||||
url:
|
||||
"http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}",
|
||||
crossOrigin: "anonymous",
|
||||
}),
|
||||
});
|
||||
this.projection = osm.getProjection();
|
||||
|
||||
mapForSelect = new ol.Map({
|
||||
interactions: ol.interaction.defaults().extend([new PointSelect(this.pointFeature)]),
|
||||
layers: [
|
||||
layer,
|
||||
AMapLayer,
|
||||
new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
features: [ new ol.Feature(this.pointFeature)],
|
||||
|
@ -20,7 +20,7 @@
|
||||
{{ item.name }}
|
||||
</a-tag>
|
||||
</span>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<span slot="action" slot-scope="record">
|
||||
<a-button size="small" type="link" @click="() => handleDetail(record)"
|
||||
>查看</a-button
|
||||
>
|
||||
|
@ -10,7 +10,7 @@
|
||||
:rowKey="idName"
|
||||
@change="handleTableChange"
|
||||
>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<span slot="action" slot-scope="record">
|
||||
<a-button size="small" type="link" @click="() => handleDetail(record)" >查看</a-button>
|
||||
<a-divider type="vertical" />
|
||||
<a-button type="danger" size="small" @click="() => handleDelete(record)" >删除</a-button>
|
||||
|
@ -15,7 +15,7 @@
|
||||
{{ permissionMap[permission] }}
|
||||
</a-tag>
|
||||
</span>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<span slot="action" slot-scope="record">
|
||||
<a-button size="small" type="link" @click="() => handleDetail(record)" >查看</a-button>
|
||||
<a-divider type="vertical" />
|
||||
<a-button type="danger" size="small" @click="() => handleDelete(record)" >删除</a-button>
|
||||
|
@ -12,7 +12,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fromLonLat, toLonLat } from "ol/proj.js";
|
||||
// import { fromLonLat, toLonLat } from "ol/proj.js";
|
||||
const { fromLonLat, toLonLat } = ol.proj;
|
||||
import { getData, login, logout, URL_MAP } from "@/utils/http";
|
||||
|
||||
let map = null;
|
||||
@ -39,22 +40,29 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
mapinit() {
|
||||
var osm = new ol.source.OSM();
|
||||
var layer = new ol.layer.Tile({
|
||||
source: osm,
|
||||
wrapX: false,
|
||||
});
|
||||
this.projection = osm.getProjection();
|
||||
this.waterLayer = this.getDeviceVectorLayer();
|
||||
this.projection = ol.proj.get("EPSG:3857");
|
||||
|
||||
this.waterLayer = this.getDeviceVectorLayer();
|
||||
var AMapLayer = new ol.layer.Tile({
|
||||
// source: new ol.source.XYZ({
|
||||
// url:
|
||||
// "http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}",
|
||||
// }),
|
||||
source: new ol.source.XYZ({
|
||||
url:
|
||||
"http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}",
|
||||
crossOrigin: "anonymous",
|
||||
}),
|
||||
});
|
||||
this.view = new ol.View({
|
||||
center: this.center,
|
||||
zoom: 10,
|
||||
projection: this.projection,
|
||||
});
|
||||
|
||||
map = new ol.Map({
|
||||
target: "map",
|
||||
layers: [layer],
|
||||
layers: [AMapLayer],
|
||||
view: this.view,
|
||||
});
|
||||
|
||||
|
50
src/components/utils/amap.js
Normal file
50
src/components/utils/amap.js
Normal file
@ -0,0 +1,50 @@
|
||||
export function wgs84togcj02(wgs_lon, wgs_lat)
|
||||
{
|
||||
if (out_of_china(wgs_lon, wgs_lat))
|
||||
{
|
||||
//不在国内
|
||||
let back = [ wgs_lon, wgs_lat ];
|
||||
return back;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dwgs_lon = transformlon(wgs_lon - 105.0, wgs_lat - 35.0);
|
||||
var dwgs_lat = transformlat(wgs_lon - 105.0, wgs_lat - 35.0);
|
||||
var radwgs_lat = wgs_lat / 180.0 * Math.PI;
|
||||
var magic = Math.sin(radwgs_lat);
|
||||
var magic = 1 - ee * magic * magic;
|
||||
var sqrtmagic = Math.sqrt(magic);
|
||||
var dwgs_lon = (dwgs_lon * 180.0) / (a / sqrtmagic * Math.cos(radwgs_lat) * Math.PI);
|
||||
var dwgs_lat = (dwgs_lat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * Math.PI);
|
||||
var gcj_lon = wgs_lon + dwgs_lon;
|
||||
var gcj_lat = wgs_lat + dwgs_lat;
|
||||
var gcj = [ gcj_lon, gcj_lat ];
|
||||
return gcj;
|
||||
}
|
||||
}
|
||||
|
||||
function transformlon(lon, lat)
|
||||
{
|
||||
var PI = Math.PI
|
||||
var ret = 300.0 + lon + 2.0 * lat + 0.1 * lon * lon + 0.1 * lon * lat + 0.1 * Math.sqrt(Math.abs(lon));
|
||||
ret += (20.0 * Math.sin(6.0 * lon * PI) + 20.0 * Math.sin(2.0 * lon * PI)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(lon * PI) + 40.0 * Math.sin(lon / 3.0 * PI)) * 2.0 / 3.0;
|
||||
ret += (150.0 * Math.sin(lon / 12.0 * PI) + 300.0 * Math.sin(lon / 30.0 * PI)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
function transformlat(lon, lat)
|
||||
{
|
||||
var PI = Math.PI
|
||||
var ret = -100.0 + 2.0 * lon + 3.0 * lat + 0.2 * lat * lat + 0.1 * lon * lat + 0.2 * Math.sqrt(Math.abs(lon));
|
||||
ret += (20.0 * Math.sin(6.0 * lon * PI) + 20.0 * Math.sin(2.0 * lon * PI)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
|
||||
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//判断是否在国内,不在国内则不做偏移
|
||||
function out_of_china(lon, lat)
|
||||
{
|
||||
return (lon < 72.004 || lon > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
|
||||
}
|
@ -10,7 +10,7 @@ module.exports = {
|
||||
proxy: {
|
||||
'/backend': {
|
||||
// target: 'http://223.75.53.208:8081',
|
||||
target: 'http://127.0.0.1:7788',
|
||||
target: 'http://121.36.155.145:10025/',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user