Commit 2eff3920 by 前端

111

1 parent dc283fb9
......@@ -29,5 +29,6 @@ export const CONSTANT = {
// 静态图标地址
export const STATICIMAGE = {
POI_MARKER:`${IMAGE_PREFIX}/e-shield/poi_icon.gif`
POI_MARKER:`${IMAGE_PREFIX}/e-shield/poi_icon.gif`,
POI_MASS_ICON:`${IMAGE_PREFIX}/e-shield/poi-marker-default.png`
}
\ No newline at end of file
......@@ -21,7 +21,7 @@
placeholder="请输入搜索地址"
id="poiMapSearch"
size="small"
maxlength="20"
maxlength="40"
v-model="poiMapSearch"
:disabled="readonlyStatus"
>
......@@ -101,7 +101,7 @@
<script>
import mapService from "@/utils/mapService.js";
import "@/utils/mapEvent.js";
import { CONSTANT, STATICIMAGE } from "@/constant";
import { STATICIMAGE } from "@/constant";
import FenceMapControll from "./FenceMapControll";
import EventBus from "@/event-bus";
import { showToast, deepClone, showModal } from "@/utils/utils.js";
......@@ -146,9 +146,6 @@ export default {
],
},
hideFooter: false,
drawDone: false,
mouseTool: null,
mapMass: null,
poi: {},
poiMapSearch: "",
poiMarker: null, // 通过搜索、右键创建的点标记
......@@ -167,19 +164,21 @@ export default {
// 地图初始化
initMap() {
let _this = this;
let plugins = CONSTANT.MAP_PLUGINS.concat([
let plugins = [
"AMap.LngLat",
"AMap.AutoComplete",
"AMap.MassMarks",
"AMap.MouseTool",
"AMap.Geocoder",
"AMap.MassMarks",
]);
];
_this.$mapInit({ plugins: plugins }).then((AMap) => {
_this.mapLoading = false;
window.AMap = AMap;
_this.map = mapService.init("map", { zoom: 15 });
_this.map = mapService.init("map", {
zoom: 15,
viewMode: "3D",
showIndoorMap: false,
showLabel: true,
});
_this.bindSearch();
_this.initMapEvent();
_this.getPoiTrack();
......@@ -210,30 +209,29 @@ export default {
let _query = _this.$route.query;
let markers = [];
let _icon = {
type: "image",
url: require("images/poi-marker-default.png"),
size: [24, 15],
anchor: new AMap.Pixel(4, 4),
url: STATICIMAGE.POI_MASS_ICON,
size: new AMap.Size(16, 21),
anchor: new AMap.Pixel(3, 3),
};
for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i];
if (k.id != _query.id) {
let m = k.lnglat.split(",");
k.lng = m[0];
k.lat = m[1];
k.lnglat = m;
markers.push(k);
if (k.lnglat) {
let m = k.lnglat.split(",");
k.lng = m[0];
k.lat = m[1];
k.lnglat = m;
markers.push(k);
}
}
}
let mass = new AMap.MassMarks(markers, {
opacity: 0.8,
zIndex: 111,
zIndex: 10,
cursor: "pointer",
style: _icon,
alwaysRender: false,
});
mass.on("click", function (e) {
......@@ -259,8 +257,8 @@ export default {
});
if (options.id) {
_icon = new AMap.Icon({
image: require("images/poi-marker-default.png"),
imageSize: new AMap.Size(24, 31),
image: STATICIMAGE.POI_MASS_ICON,
imageSize: new AMap.Size(16, 21),
});
}
......@@ -417,8 +415,15 @@ export default {
console.log(row);
let _this = this;
let _message = "确认删除该POI信息吗?";
let _typeList = {
1: "黑区圆心",
2: "二押点",
3: "异常聚集点",
};
if (row.poiName) {
_message = `确认删除【${row.poiName}】的【${row.poiTypeStr}】POI信息吗?`;
_message = `确认删除【${row.poiName}】的【${
_typeList[row.poiType]
}】POI信息吗?`;
}
showModal({
message: _message,
......@@ -471,28 +476,11 @@ export default {
GET_POI_TRACK().then((res) => {
if (res.code == 200) {
let _list = res.data || [];
// _list.map((k) => {
// if (k.lnglat) {
// let m = k.lnglat.split(",");
// k.lng = m[0];
// k.lat = m[1];
// console.log(k);
// _this.addPoiMarker(k);
// }
// });
_this.addMassMarkers(_list);
// 编辑页面,如果id存在,则显示对应的marker
//let _markerList = _this.markerList;
// 编辑页面
if (_query.id) {
_this.getInfo();
// let _marker = _markerList[_query.id];
// if (_marker) {
// let _markerInfo = _marker.getExtData();
// _this.markerEvent(_markerInfo);
// //_this.map.setFitView(_marker);
// _this.setCenter(_markerInfo.lng, _markerInfo.lat);
// }
}
_this.trackList = res.data || [];
}
......@@ -513,7 +501,7 @@ export default {
_obj.lng = arr[0];
_obj.lat = arr[1];
}
console.log(_obj)
_this.addPoiMarker(_obj, "", true);
});
},
......
......@@ -101,7 +101,8 @@ export default {
},
mounted() {
let _this = this;
_this.$mapInit().then((AMap) => {
let plugins = ["AMap.LngLat", "AMap.AutoComplete"];
_this.$mapInit({ version: "1.4.2", plugins: plugins }).then((AMap) => {
window.AMap = AMap;
_this.mapObj = mapService.init("mapContainer");
_this.bindContextMenu();
......@@ -172,14 +173,11 @@ export default {
}
});
AMap.event.addListener(self.auto, "select", (e) => {
self.auto.on("select", (e) => {
console.log(e.poi);
if (e.poi && e.poi.location) {
self.mapObj.setCenter(e.poi.location);
self.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
}*/
self.lng = e.poi.location.lng;
self.lat = e.poi.location.lat;
self.autoCenterMarker.show();
......@@ -188,6 +186,23 @@ export default {
self.mapObj.setZoom(14);
});
// AMap.event.addListener(self.auto, "select", (e) => {
// console.log(e.poi);
// if (e.poi && e.poi.location) {
// self.mapObj.setCenter(e.poi.location);
// self.autoCenterMarker.setPosition(e.poi.location);
// /*for(var i = 0, l = this.polygons.length; i < l; i++) {
// this.polygons[i].setMap(null);
// }*/
// self.lng = e.poi.location.lng;
// self.lat = e.poi.location.lat;
// self.autoCenterMarker.show();
// self.mapObj.add(self.autoCenterMarker);
// }
// self.mapObj.setZoom(14);
// });
});
},
bindContextMenu() {
......@@ -420,19 +435,33 @@ export default {
return new Promise((resolve, reject) => {
mapObj.plugin("AMap.Geolocation", function () {
self.geolocation = new AMap.Geolocation();
self.geolocation.getCurrentPosition();
self.geolocation.getCurrentPosition(function (status, result) {
if (status == "complete") {
var lnglatXY = mapService.getLngLat(
result.position.lng,
result.position.lat
);
resolve(lnglatXY);
}
AMap.event.addListener(self.geolocation, "complete", function (e) {
console.log("complete", e);
//返回定位信息
var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
resolve(lnglatXY);
});
AMap.event.addListener(self.geolocation, "error", function (e) {
console.log("error", e);
//返回定位出错信息
resolve(mapObj.getCenter());
if (status == "error") {
console.log("error", result);
//返回定位出错信息
resolve(mapObj.getCenter());
}
});
// AMap.event.addListener(self.geolocation, "complete", function (e) {
// console.log("complete", e);
// //返回定位信息
// var lnglatXY = mapService.getLngLat(e.position.lng, e.position.lat);
// resolve(lnglatXY);
// });
// AMap.event.addListener(self.geolocation, "error", function (e) {
// console.log("error", e);
// //返回定位出错信息
// resolve(mapObj.getCenter());
// });
});
});
},
......
......@@ -202,7 +202,7 @@ import InfiniteLoading from "vue-infinite-loading";
import MapControll from "./MapControll.vue";
import { replayShortcuts } from "@/common/index";
import { GET_ELECFENCE_INFO } from "@/api/services/fence";
import listJson from "./test.json";
export default {
data() {
let checkDaterange = (rule, vaule, cb) => {
......@@ -444,6 +444,7 @@ export default {
MONITOR_SERVICE.getTrackHistory(params).then((result) => {
//result = mock.getTrackHistory
console.log(result);
result = listJson;
if (result.code == "200") {
let data = result.data;
this.replayData = data;
......@@ -775,8 +776,22 @@ export default {
},
created() {
let _this = this;
_this.$mapInit({ version: "1.0.11" }).then((AMap) => {
let _config = { version: "1.4.2" };
_config.AMapUI = {
version: "1.1",
plugins: ["ui/misc/PathSimplifier"],
};
_this.$mapInit(_config).then((AMap) => {
console.log(window.AMap);
_this.initMap();
// if (AMap) {
// remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
// () => {
// _this.initMap();
// }
// );
// }
});
//轨迹播放当前位置地址显示
......
......@@ -2,19 +2,23 @@ import AMapLoader from "@amap/amap-jsapi-loader";
import { CONSTANT } from "@/constant";
export const mapInit = params => {
return new Promise((resolve,reject) => {
let plugins = params.plugins|| CONSTANT.MAP_PLUGINS;
let version = params.version || '2.0';
let options = params || {};
let plugins = options.plugins|| CONSTANT.MAP_PLUGINS;
let version = options.version || '2.0';
if(window.AMap){
resolve(window.AMap)
return false;
}
let mapConfig ={};
mapConfig.key = CONSTANT.MAP_KEY; // 申请好的Web端开发者Key,首次调用 load 时必填
mapConfig.version = options.version || '2.0';; // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
mapConfig.plugins = options.plugins|| CONSTANT.MAP_PLUGINS;// 需要使用的的插件列表,如比例尺'AMap.Scale'等
if(options.AMapUI){
mapConfig.AMapUI = options.AMapUI;
}
AMapLoader.reset();
AMapLoader.load({
key: CONSTANT.MAP_KEY, // 申请好的Web端开发者Key,首次调用 load 时必填
version: version, // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: plugins, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
window.AMap = AMap;
AMapLoader.load(mapConfig).then((AMap) => {
window.AMap = AMap;
resolve(AMap);
})
.catch((error) => {
......
......@@ -29,7 +29,8 @@ MapService.prototype = {
}
var map = new AMap.Map(id, {
resizeEnable: true,
zoom: params.zoom||11
zoom: params.zoom||11,
...params
});
// 添加比例尺
......@@ -53,8 +54,18 @@ MapService.prototype = {
},
toggleMapType: function () {
var self = this;
let _map = self.map;
self.type = self.type ? 0 : 1; //0:使用2D地图,1:混合图
_map.plugin(["AMap.MapType"],function(){
//地图类型切换
let _mapType= new AMap.MapType({
defaultType: self.type,
});
_map.addControl(_mapType);
_mapType.hide();
});
return false;
if (self.type === 1) {
// 构造官方卫星、路网图层
......@@ -69,6 +80,7 @@ MapService.prototype = {
} else {
// 地图上设置图层
self.map.remove(self.mixLayers);
/*self.map.plugin(["AMap.MapType"],function(){
//地图类型切换
var type = new window.AMap.MapType({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!