<template>
<native-view :id="fixedId" @init="onViewInit" @ready="onReady" @mapclick="mapClick" @camerachange="onCameraChange"
@camerafinish="onCameraChangeFinish" @markertap="onMarkerClick"></native-view>
</template>
<script setup lang="uts">
import { NativeAmap } from "@/uni_modules/jiannor-harmony-amap";
let amap : NativeAmap | null = null
const fixedId = ref('')
function updateOption(amap : NativeAmap | null) {
let options : UTSJSONObject = {
id: fixedId.value,
appKey: props.appKey,
showLocation: props.showLocation,
// width: normalizeLength(props.width),
// height: normalizeLength(props.height),
// name: props.name
}
amap?.updateOptions(options)
}
function onViewInit(e : UniNativeViewInitEvent) {
amap = new NativeAmap(e.detail.element);
updateOption(amap)
}
onUnload(()=>{
amap?.destroy()
})
</script>
<style>
</style>
import {MAMapView} from "MAMapKit"
import { ComponentPublicInstance } from 'vue'
import {
AddCircleOptions, AddMarkerOptions, AddPolygonOptions, AddPolylineOptions, CreateNativeAmapContext, ICameraPosition, ICircleItem, IMarkerItem, INativeAmapContext, IPolygonItem, IPolylineItem, NativeAmapOptions, UniAmapCircle,
UniAmapMarker, UniAmapPolygon, UniAmapPolyline,, UniCalculateZoom, UniCalculateZoomToSpanLevel
} from "../interface.uts"
export * from "../interface.uts"
export class NativeAmap {
$element : UniNativeViewElement
mapView : MAMapView | null = null
constructor(element : UniNativeViewElement) {
this.$element = element
super.init()
this.bindView()
}
bindView() {
this.mapView = new MAMapView()
this.$element.bindIOSView(this.mapView!);
}
updateOptions(item : UTSJSONObject) : void {
let options = JSON.parseObject<NativeAmapOptions>(JSON.stringify(item)!)!
}
destroy(){
UTSiOS.destroyInstance(this.mapView!)
}
}
他出现了[plugin:uts] "NativeAmap" is not exported by "../../../../../../Users/jiannor/uniappProject/xmap/uni_modules/jiannor-harmony-amap?uts-proxy", imported by "../../../../../../Users/jiannor/uniappProject/xmap/uni_modules/jiannor-harmony-amap/components/jiannor-harmony-amap/jiannor-harmony-amap.uvue?vue&type=script&setup=true&lang.uts".
16:13:07.026 at uni_modules/jiannor-harmony-amap/components/jiannor-harmony-amap/jiannor-harmony-amap.uvue:2:9
16:13:07.026 1: import { defineComponent as _defineComponent } from 'vue'
16:13:07.026 2: import { NativeAmap } from "@/uni_modules/jiannor-harmony-amap";
16:13:07.026 ^
16:13:07.026 3:
16:13:07.026 4: export type NativeAmapOptions= {,
打自定义基座出现
[uts] ../../../../../../Users/jiannor/uniappProject/xmap/uni_modules/jiannor-harmony-amap/components/jiannor-harmony-amap/jiannor-harmony-amap.uvue?vue&type=script&setup=true&lang.uts (3:9): "NativeAmap" is not exported by "../../../../../../Users/jiannor/uniappProject/xmap/uni_modules/jiannor-harmony-amap?uts-proxy", imported by "../../../../../../Users/jiannor/uniappProject/xmap/uni_modules/jiannor-harmony-amap/components/jiannor-harmony-amap/jiannor-harmony-amap.uvue?vue&type=script&setup=true&lang.uts".
[HBuilder] 16:17:14.309 file: /Users/jiannor/uniappProject/xmap/uni_modules/jiannor-harmony-amap/components/jiannor-harmony-amap/jiannor-harmony-amap.uvue?vue&type=script&setup=true&lang.uts:3:9
[HBuilder] 16:17:14.309 1: import { defineComponent as _defineComponent } from 'vue';
[HBuilder] 16:17:14.309 2: import { unref as _unref, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
[HBuilder] 16:17:14.309 3: import { NativeAmap } from "@/uni_modules/jiannor-harmony-amap";
[HBuilder] 16:17:14.309 ^
[HBuilder] 16:17:14.309 4:
[HBuilder] 16:17:14.309 5: import { ref, watchEffect, onUnload } from 'vue';
我的依赖配置如下:
{
"frameworks": [
"libz.1.2.5.tbd"
],
"deploymentTarget": "12",
"dependencies-pods": [{
"name": "AMap3DMap-NO-IDFA",
"version": "10.1.600"
},
{
"name": "AMapSearch-NO-IDFA",
"version": "9.7.4"
},
{
"name": "AMapLocation-NO-IDFA",
"version": "2.11.0"
}
]
},请各位帮助,demo已传附件