Commit 2eff3920 by 前端

111

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