安装
npm i @amap/amap-jsapi-loader --save
使用
import * as style from "ol/style";
import * as format from "ol/format";
import * as source from "ol/source";
import * as layer from "ol/layer";
//获取数据及绘制
let vectorLayer = ref<layer.Vector | null>(null);
function getDistrictInfoWithPromise(
keyword: string,//地区名称
level: string,//级别
): Promise<any> {
return new Promise((resolve, reject) => {
removeCurrentVectorLayer();
window._AMapSecurityConfig = {
securityJsCode: "密钥",
};
AMapLoader.load({
key: "你的key",
version: "2.0",
plugins: ["AMap.DistrictSearch"],
})
.then((AMap) => {
const opts = {
subdistrict: 0,
extensions: "all",
level: "distric