提交 bc0e29c8 作者: 18928357778

改-地图-显示点位

上级 994f35f6
import React, { Component, useEffect, useState } from "react"; import React, { Component, useEffect, useState } from "react";
import { Box } from "./styled"; import { Box } from "./styled";
import api from "./api"; import api from "./api";
let Map: any;
export default function MapComponent() { export default function MapComponent() {
const [mapItem, setMapItem] = useState(0); const [mapItem, setMapItem] = useState(0);
const [Map, setMap] = useState<any>(null!);
const init = async () => { const init = async () => {
try { try {
const AMapLoader = await import( const AMapLoader = await import(
...@@ -15,7 +15,7 @@ export default function MapComponent() { ...@@ -15,7 +15,7 @@ export default function MapComponent() {
plugins: [""], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 plugins: [""], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}) })
.then(async (AMap) => { .then(async (AMap) => {
const Map = new AMap.Map("container", { Map = new AMap.Map("container", {
// 设置地图容器id // 设置地图容器id
viewMode: "3D", // 是否为3D地图模式 viewMode: "3D", // 是否为3D地图模式
zoom: 9, // 初始化地图级别 zoom: 9, // 初始化地图级别
...@@ -23,7 +23,6 @@ export default function MapComponent() { ...@@ -23,7 +23,6 @@ export default function MapComponent() {
}); });
console.log(Map, "MapMapMapMapMapMapMapMapMapMapMap"); console.log(Map, "MapMapMapMapMapMapMapMapMapMapMap");
setMap(Map);
await mapEntiy(0, AMap); await mapEntiy(0, AMap);
}) })
.catch((e) => { .catch((e) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论