Browse Source

社区自组织页面

dev-烟台中转登录
dai 3 years ago
parent
commit
80180a24c7
  1. 17
      src/utils/dai-map.js
  2. 51
      src/views/modules/communityService/dqfwzx/index.vue
  3. 96
      src/views/modules/communityService/sqzzz/cpts/edit.vue
  4. 8
      src/views/modules/cpts/base/cpts/edit.vue

17
src/utils/dai-map.js

@ -1,8 +1,9 @@
import nextTick from "dai-js/tools/nextTick"; import nextTick from "dai-js/tools/nextTick";
export const mapType = typeof window.TMap !== "undefined" ? "qq" : "td";
// 封装了地图相关函数,兼容天地图、腾讯地图常用api // 封装了地图相关函数,兼容天地图、腾讯地图常用api
export default function init(ele, position, params) { export default function init(ele, position, params) {
const mapType = typeof window.TMap !== "undefined" ? "qq" : "td";
this.mapType = mapType; this.mapType = mapType;
this.map = null; this.map = null;
this.marker = null; this.marker = null;
@ -14,7 +15,7 @@ export default function init(ele, position, params) {
}; };
}; };
this.setCenter = function (lat, lng) {}; this.setCenter = function (lat, lng) {};
this.setMarker = function (lat, lng) {}; this.setMarker = function (lat, lng, title) {};
this.getAddress = async function (lat, lng) {}; this.getAddress = async function (lat, lng) {};
this.searchNearby = async function (keyword) {}; this.searchNearby = async function (keyword) {};
this.on = function (eventType, fn) {}; this.on = function (eventType, fn) {};
@ -51,7 +52,7 @@ export default function init(ele, position, params) {
this.map.setCenter(new QQMap.LatLng(lat, lng)); this.map.setCenter(new QQMap.LatLng(lat, lng));
}; };
this.setMarker = function (lat, lng) { this.setMarker = function (lat, lng, title = "位置") {
this.markers.setGeometries([]); this.markers.setGeometries([]);
this.markers.add([ this.markers.add([
{ {
@ -59,7 +60,7 @@ export default function init(ele, position, params) {
styleId: "marker", styleId: "marker",
position: new QQMap.LatLng(lat, lng), position: new QQMap.LatLng(lat, lng),
properties: { properties: {
title: "marker4", title,
}, },
}, },
]); ]);
@ -103,8 +104,6 @@ export default function init(ele, position, params) {
const { const {
location: { lat, lng, address }, location: { lat, lng, address },
} = data[0]; } = data[0];
this.setCenter(lat, lng);
this.setMarker(lat, lng);
reslove({ reslove({
msg: "success", msg: "success",
data: { data: {
@ -159,10 +158,12 @@ export default function init(ele, position, params) {
this.map.panTo(new TDMap.LngLat(lng, lat)); this.map.panTo(new TDMap.LngLat(lng, lat));
}; };
this.setMarker = function (lat, lng) { this.setMarker = function (lat, lng, title = "位置") {
let lnglat = new TDMap.LngLat(lng, lat); let lnglat = new TDMap.LngLat(lng, lat);
if (!this.marker) { if (!this.marker) {
this.marker = new TDMap.Marker(lnglat, {}); this.marker = new TDMap.Marker(lnglat, {
title,
});
this.map.addOverLay(this.marker); this.map.addOverLay(this.marker);
} else { } else {
this.marker.setLngLat(lnglat); this.marker.setLngLat(lnglat);

51
src/views/modules/communityService/dqfwzx/index.vue

@ -162,12 +162,9 @@ import { mapGetters } from "vuex";
import editForm from "./cpts/edit"; import editForm from "./cpts/edit";
import orderForm from "./cpts/order"; import orderForm from "./cpts/order";
import orderList from "./cpts/orderList"; import orderList from "./cpts/orderList";
import daiMap from "@/utils/dai-map";
var map; var map;
var search;
var markers;
var infoWindowList;
let loading; //
export default { export default {
components: { editForm, orderForm, orderList }, components: { editForm, orderForm, orderList },
@ -207,49 +204,25 @@ export default {
methods: { methods: {
// init // init
initMap() { initMap() {
// let { latitude, longitude } = this.$store.state.user;
var center = new window.TMap.LatLng(36.0722275, 120.38945519);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById("centerIndexApp"), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45, //
});
search = new window.TMap.service.Search({ pageSize: 10 });
//
markers = new TMap.MultiMarker({
map: map,
geometries: [],
});
infoWindowList = Array(10);
},
setMarker(lat, lng, centerName) { map = new daiMap(
markers.setGeometries([]); document.getElementById("centerIndexApp"),
markers.add([ { latitude, longitude },
{ {
id: "911", zoom: 16.2, //
styleId: "marker", pitch: 43.5, //
position: new TMap.LatLng(lat, lng), rotation: 45, //
properties: { }
title: centerName, );
},
},
]);
},
setCenter(lat, lng) {
map.setCenter(new window.TMap.LatLng(lat, lng));
}, },
setMap() { setMap() {
const { tableData, currentIndex } = this; const { tableData, currentIndex } = this;
let item = tableData[currentIndex]; let item = tableData[currentIndex];
if (item) { if (item) {
this.setCenter(item.latitude, item.longitude); map.setCenter(item.latitude, item.longitude);
this.setMarker(item.latitude, item.longitude, item.centerName); map.setMarker(item.latitude, item.longitude, item.centerName);
} }
}, },

96
src/views/modules/communityService/sqzzz/cpts/edit.vue

@ -251,6 +251,7 @@ import { Loading } from "element-ui"; // 引入Loading服务
import { requestPost } from "@/js/dai/request"; import { requestPost } from "@/js/dai/request";
import formVltHelper from "dai-js/tools/formVltHelper"; import formVltHelper from "dai-js/tools/formVltHelper";
import nextTick from "dai-js/tools/nextTick"; import nextTick from "dai-js/tools/nextTick";
import daiMap from "@/utils/dai-map";
var map; var map;
var search; var search;
@ -390,100 +391,51 @@ export default {
organizationPersonnel.splice(index, 1); organizationPersonnel.splice(index, 1);
this.dataForm.organizationPersonnel = organizationPersonnel; this.dataForm.organizationPersonnel = organizationPersonnel;
}, },
// init // init
initMap() { initMap() {
let { latitude, longitude } = this.$store.state.user; let { latitude, longitude } = this.$store.state.user;
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821; map = new daiMap(
longitude = 116.39743841556731; document.getElementById("app"),
} { latitude, longitude },
// {
var center = new window.TMap.LatLng(latitude, longitude);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById("app"), {
center: center, //
zoom: 16.2, // zoom: 16.2, //
pitch: 43.5, // pitch: 43.5, //
rotation: 45, // rotation: 45, //
}); }
);
search = new window.TMap.service.Search({ pageSize: 10 });
//
markers = new TMap.MultiMarker({
map: map,
geometries: [],
});
infoWindowList = Array(10);
geocoder = new TMap.service.Geocoder(); //
// //
map.on("panend", (e) => { map.on("moveend", (e) => {
this.handleMoveCenter(e); this.handleMoveCenter(e);
}); });
// this.handleMoveCenter();
}, },
setMarker(lat, lng) { async handleSearchMap() {
markers.setGeometries([]); const { msg, data } = await map.searchNearby(this.dataForm.address);
markers.add([ if (msg == "success") {
{ const { lat, lng } = data;
id: "4", map.setCenter(lat, lng);
styleId: "marker", map.setMarker(lat, lng);
position: new TMap.LatLng(lat, lng),
properties: {
title: "marker4",
},
},
]);
},
handleSearchMap() {
infoWindowList.forEach((infoWindow) => {
infoWindow.close();
});
infoWindowList.length = 0;
markers.setGeometries([]);
//
search
.searchNearby({
keyword: this.dataForm.address,
radius: 1000,
autoExtend: true,
center: map.getCenter(),
})
.then((result) => {
let { data } = result;
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng },
} = data[0];
map.setCenter(new TMap.LatLng(lat, lng));
this.setMarker(lat, lng);
this.dataForm.latitude = lat; this.dataForm.latitude = lat;
this.dataForm.longitude = lng; this.dataForm.longitude = lng;
} else { } else {
this.$message.error("未检索到相关位置坐标"); this.$message.error("未检索到相关位置坐标");
} }
});
}, },
handleMoveCenter(e) { async handleMoveCenter(e) {
console.log(e); console.log("handleMoveCenter", e);
// //
const center = map.getCenter(); const { lat, lng } = map.getCenter();
const lat = center.getLat();
const lng = center.getLng();
this.dataForm.latitude = lat; this.dataForm.latitude = lat;
this.dataForm.longitude = lng; this.dataForm.longitude = lng;
this.setMarker(lat, lng); map.setMarker(lat, lng);
if (e && e.originalEvent) { let { msg, data } = await map.getAddress(lat, lng);
geocoder if (msg == "success") {
.getAddress({ location: new TMap.LatLng(lat, lng) }) // this.dataForm.address = data.address;
.then((result) => {
this.dataForm.address = result.result.address;
});
} }
}, },
@ -498,7 +450,7 @@ export default {
await nextTick(800); await nextTick(800);
if (map) { if (map) {
map.setCenter(new TMap.LatLng(row.latitude, row.longitude)); map.setCenter(row.latitude, row.longitude);
} }
} }
}, },

8
src/views/modules/cpts/base/cpts/edit.vue

@ -645,9 +645,8 @@ export default {
const { msg, data } = await map.searchNearby(this.fmData[item.keyName]); const { msg, data } = await map.searchNearby(this.fmData[item.keyName]);
if (msg == "success") { if (msg == "success") {
const { lat, lng } = data; const { lat, lng } = data;
// map.setCenter(lat, lng); map.setCenter(lat, lng);
// map.setMarker(lat, lng); map.setMarker(lat, lng);
this.fmData[item.supKeys[0]] = lng; this.fmData[item.supKeys[0]] = lng;
this.fmData[item.supKeys[1]] = lat; this.fmData[item.supKeys[1]] = lat;
} else { } else {
@ -659,8 +658,7 @@ export default {
console.log("handleMoveCenter", e); console.log("handleMoveCenter", e);
// //
const { lat, lng } = map.getCenter(); const { lat, lng } = map.getCenter();
// item.supValues[0] = lng;
// item.supValues[1] = lat;
this.fmData[item.supKeys[0]] = lng; this.fmData[item.supKeys[0]] = lng;
this.fmData[item.supKeys[1]] = lat; this.fmData[item.supKeys[1]] = lat;
map.setMarker(lat, lng); map.setMarker(lat, lng);

Loading…
Cancel
Save