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. 110
      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";
export const mapType = typeof window.TMap !== "undefined" ? "qq" : "td";
// 封装了地图相关函数,兼容天地图、腾讯地图常用api
export default function init(ele, position, params) {
const mapType = typeof window.TMap !== "undefined" ? "qq" : "td";
this.mapType = mapType;
this.map = null;
this.marker = null;
@ -14,7 +15,7 @@ export default function init(ele, position, params) {
};
};
this.setCenter = function (lat, lng) {};
this.setMarker = function (lat, lng) {};
this.setMarker = function (lat, lng, title) {};
this.getAddress = async function (lat, lng) {};
this.searchNearby = async function (keyword) {};
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.setMarker = function (lat, lng) {
this.setMarker = function (lat, lng, title = "位置") {
this.markers.setGeometries([]);
this.markers.add([
{
@ -59,7 +60,7 @@ export default function init(ele, position, params) {
styleId: "marker",
position: new QQMap.LatLng(lat, lng),
properties: {
title: "marker4",
title,
},
},
]);
@ -103,8 +104,6 @@ export default function init(ele, position, params) {
const {
location: { lat, lng, address },
} = data[0];
this.setCenter(lat, lng);
this.setMarker(lat, lng);
reslove({
msg: "success",
data: {
@ -159,10 +158,12 @@ export default function init(ele, position, params) {
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);
if (!this.marker) {
this.marker = new TDMap.Marker(lnglat, {});
this.marker = new TDMap.Marker(lnglat, {
title,
});
this.map.addOverLay(this.marker);
} else {
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 orderForm from "./cpts/order";
import orderList from "./cpts/orderList";
import daiMap from "@/utils/dai-map";
var map;
var search;
var markers;
var infoWindowList;
let loading; //
export default {
components: { editForm, orderForm, orderList },
@ -207,49 +204,25 @@ export default {
methods: {
// init
initMap() {
//
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, //
});
let { latitude, longitude } = this.$store.state.user;
search = new window.TMap.service.Search({ pageSize: 10 });
//
markers = new TMap.MultiMarker({
map: map,
geometries: [],
});
infoWindowList = Array(10);
},
setMarker(lat, lng, centerName) {
markers.setGeometries([]);
markers.add([
map = new daiMap(
document.getElementById("centerIndexApp"),
{ latitude, longitude },
{
id: "911",
styleId: "marker",
position: new TMap.LatLng(lat, lng),
properties: {
title: centerName,
},
},
]);
},
setCenter(lat, lng) {
map.setCenter(new window.TMap.LatLng(lat, lng));
zoom: 16.2, //
pitch: 43.5, //
rotation: 45, //
}
);
},
setMap() {
const { tableData, currentIndex } = this;
let item = tableData[currentIndex];
if (item) {
this.setCenter(item.latitude, item.longitude);
this.setMarker(item.latitude, item.longitude, item.centerName);
map.setCenter(item.latitude, item.longitude);
map.setMarker(item.latitude, item.longitude, item.centerName);
}
},

110
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 formVltHelper from "dai-js/tools/formVltHelper";
import nextTick from "dai-js/tools/nextTick";
import daiMap from "@/utils/dai-map";
var map;
var search;
@ -390,100 +391,51 @@ export default {
organizationPersonnel.splice(index, 1);
this.dataForm.organizationPersonnel = organizationPersonnel;
},
// init
initMap() {
let { latitude, longitude } = this.$store.state.user;
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;
}
//
var center = new window.TMap.LatLng(latitude, longitude);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById("app"), {
center: center, //
zoom: 16.2, //
pitch: 43.5, //
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 = new daiMap(
document.getElementById("app"),
{ latitude, longitude },
{
zoom: 16.2, //
pitch: 43.5, //
rotation: 45, //
}
);
//
map.on("panend", (e) => {
map.on("moveend", (e) => {
this.handleMoveCenter(e);
});
// this.handleMoveCenter();
},
setMarker(lat, lng) {
markers.setGeometries([]);
markers.add([
{
id: "4",
styleId: "marker",
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.longitude = lng;
} else {
this.$message.error("未检索到相关位置坐标");
}
});
async handleSearchMap() {
const { msg, data } = await map.searchNearby(this.dataForm.address);
if (msg == "success") {
const { lat, lng } = data;
map.setCenter(lat, lng);
map.setMarker(lat, lng);
this.dataForm.latitude = lat;
this.dataForm.longitude = lng;
} else {
this.$message.error("未检索到相关位置坐标");
}
},
handleMoveCenter(e) {
console.log(e);
async handleMoveCenter(e) {
console.log("handleMoveCenter", e);
//
const center = map.getCenter();
const lat = center.getLat();
const lng = center.getLng();
const { lat, lng } = map.getCenter();
this.dataForm.latitude = lat;
this.dataForm.longitude = lng;
this.setMarker(lat, lng);
map.setMarker(lat, lng);
if (e && e.originalEvent) {
geocoder
.getAddress({ location: new TMap.LatLng(lat, lng) }) //
.then((result) => {
this.dataForm.address = result.result.address;
});
let { msg, data } = await map.getAddress(lat, lng);
if (msg == "success") {
this.dataForm.address = data.address;
}
},
@ -498,7 +450,7 @@ export default {
await nextTick(800);
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]);
if (msg == "success") {
const { lat, lng } = data;
// map.setCenter(lat, lng);
// map.setMarker(lat, lng);
map.setCenter(lat, lng);
map.setMarker(lat, lng);
this.fmData[item.supKeys[0]] = lng;
this.fmData[item.supKeys[1]] = lat;
} else {
@ -659,8 +658,7 @@ export default {
console.log("handleMoveCenter", e);
//
const { lat, lng } = map.getCenter();
// item.supValues[0] = lng;
// item.supValues[1] = lat;
this.fmData[item.supKeys[0]] = lng;
this.fmData[item.supKeys[1]] = lat;
map.setMarker(lat, lng);

Loading…
Cancel
Save