fix(amap):core
This commit is contained in:
parent
bc690dfcc4
commit
c1db08709f
47
src/App.tsx
47
src/App.tsx
|
@ -1,42 +1,35 @@
|
||||||
import { Outlet } from "react-router";
|
import { Outlet } from "react-router";
|
||||||
import MyComponent from "./components/errorComp";
|
import MapUtl from "./components/map/mapUtil";
|
||||||
// import MapUtl from "./components/map/mapUtil";
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
// const SocketService = require("./util/socket");
|
|
||||||
import SocketService from "./util/socket";
|
import SocketService from "./util/socket";
|
||||||
const socketService = SocketService.getInstance();
|
const socketService = SocketService.getInstance();
|
||||||
const onMessage = (data: any) => {
|
const onMessage = (e: any) => {
|
||||||
// console.log("message", data);
|
let data = JSON.parse(e);
|
||||||
|
if (data.type === "accpt") {
|
||||||
|
let body = JSON.parse(data.content.body);
|
||||||
|
console.log(body);
|
||||||
|
MapUtl.addMaker({
|
||||||
|
lng: 103.55,
|
||||||
|
lat: 30.342,
|
||||||
|
title: body?.user_name,
|
||||||
|
users: body,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
socketService.on("message", onMessage);
|
console.log("init");
|
||||||
const onConnected = () => {
|
|
||||||
console.log("connected");
|
|
||||||
};
|
|
||||||
socketService.on("connected", onConnected);
|
|
||||||
|
|
||||||
// socketService.
|
socketService.on("message", onMessage);
|
||||||
// socket.onmessage((e) => {
|
|
||||||
// const data = JSON.parse(e.data);
|
|
||||||
// if (data.type === "heartbeat") {
|
|
||||||
// MapUtl.makerList[0].setPosition([103.55, 30.342]);
|
|
||||||
// var m = MapUtl.amap;
|
|
||||||
// var newIcon = new m.Icon({
|
|
||||||
// image: "//a.amap.com/jsapi_demos/static/demo-center/icons/dir-marker.png", //Icon 的图像
|
|
||||||
// size: new m.Size(25, 34), // 图标大小
|
|
||||||
// anchor: new m.Pixel(12, 32), // 图标锚点
|
|
||||||
// });
|
|
||||||
// MapUtl.makerList[0].setIcon(newIcon);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("app mounted");
|
return () => {
|
||||||
|
console.log("uninstall");
|
||||||
|
|
||||||
|
socketService.off("message", onMessage);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MyComponent>
|
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</MyComponent>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,9 @@ export default function MapContainer() {
|
||||||
resizeEnable: true,
|
resizeEnable: true,
|
||||||
});
|
});
|
||||||
setmaps(amap);
|
setmaps(amap);
|
||||||
addMaket(Amap,amap);
|
// addMaket(Amap,amap);
|
||||||
|
MapUtl.loadMap = Amap;
|
||||||
|
MapUtl.amap = amap;
|
||||||
amap.setFitView();
|
amap.setFitView();
|
||||||
};
|
};
|
||||||
const addMaket = (m,mp) => {
|
const addMaket = (m,mp) => {
|
||||||
|
|
|
@ -1,6 +1,41 @@
|
||||||
class MapUtl {
|
class MapUtl {
|
||||||
static makerList: any[] = [];
|
static makerList: any[] = [];
|
||||||
static amap: any = null;
|
static amap: any = null;
|
||||||
|
static loadMap: any = null;
|
||||||
|
|
||||||
|
static addMaker(data: any) {
|
||||||
|
const { lng, lat, title, users } = data;
|
||||||
|
const marker = new MapUtl.loadMap.Marker({
|
||||||
|
position: new MapUtl.loadMap.LngLat(lng, lat),
|
||||||
|
title: title,
|
||||||
|
});
|
||||||
|
var content = [
|
||||||
|
"<div><b>姓名 :" + users?.user_name + "</b>",
|
||||||
|
"职位 : " + users.pos_held,
|
||||||
|
"电话 : " + users.tel,
|
||||||
|
"</div>",
|
||||||
|
];
|
||||||
|
var infoWindow = new MapUtl.loadMap.InfoWindow({
|
||||||
|
offset: new MapUtl.loadMap.Pixel(0, -30),
|
||||||
|
autoMove: true,
|
||||||
|
content: content.join("<br/>"),
|
||||||
|
});
|
||||||
|
marker.on("click", (e) => {
|
||||||
|
infoWindow.open(MapUtl.amap, e.target.getPosition());
|
||||||
|
});
|
||||||
|
MapUtl.amap?.add(marker);
|
||||||
|
}
|
||||||
|
static setMakericon = (maker) => {
|
||||||
|
maker.setPosition([103.55, 30.342]);
|
||||||
|
var m = MapUtl.amap;
|
||||||
|
var newIcon = new m.Icon({
|
||||||
|
image: "//a.amap.com/jsapi_demos/static/demo-center/icons/dir-marker.png", //Icon 的图像
|
||||||
|
size: new m.Size(25, 34), // 图标大小
|
||||||
|
anchor: new m.Pixel(12, 32), // 图标锚点
|
||||||
|
});
|
||||||
|
maker.setIcon(newIcon);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MapUtl;
|
export default MapUtl;
|
|
@ -3,10 +3,10 @@ class Config {
|
||||||
// static uploadUrl = "https://rw.quwanya.cn/";
|
// static uploadUrl = "https://rw.quwanya.cn/";
|
||||||
// static ws = "wss://rw.quwanya.cn/ws";
|
// static ws = "wss://rw.quwanya.cn/ws";
|
||||||
|
|
||||||
// static ws = "wss://rw.quwanya.cn/ws?id=admin";
|
static ws = "ws://127.0.0.1:12214/ws?id=admin";
|
||||||
static baseUrl = "http://127.0.0.1:12214/";
|
static baseUrl = "http://127.0.0.1:12214/";
|
||||||
static uploadUrl = "http://127.0.0.1:12214/";
|
static uploadUrl = "http://127.0.0.1:12214/";
|
||||||
static ws = "wss://rw.quwanya.cn/ws";
|
// static ws = "wss://rw.quwanya.cn/ws";
|
||||||
|
|
||||||
}
|
}
|
||||||
export default Config;
|
export default Config;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// import SocketService from "./socket";
|
|
||||||
|
|
||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
|
|
||||||
// const socketService = SocketService.getInstance();
|
|
||||||
class WebRtc {
|
class WebRtc {
|
||||||
private mediaStream: MediaStream | Blob | null = null;
|
private mediaStream: MediaStream | Blob | null = null;
|
||||||
private pee: RTCPeerConnection | null = null;
|
private pee: RTCPeerConnection | null = null;
|
||||||
|
|
Loading…
Reference in New Issue