|
@@ -13,7 +13,9 @@ export const Component = defineComponent({
|
|
|
compId: string().isRequired,
|
|
|
},
|
|
|
setup(props) {
|
|
|
- const { controls, actions, store } = useEditor();
|
|
|
+ const { controls, store } = useEditor();
|
|
|
+
|
|
|
+ const mapContainerRef = ref();
|
|
|
|
|
|
const comp = useCompData(props.compId);
|
|
|
const { value } = comp;
|
|
@@ -33,7 +35,7 @@ export const Component = defineComponent({
|
|
|
// })
|
|
|
// .then((res) => {
|
|
|
// AMap.value = res;
|
|
|
- map.value = new AMap.Map(props.compId, {
|
|
|
+ map.value = new AMap.Map(mapContainerRef.value, {
|
|
|
// viewMode: "3D",
|
|
|
zoom: 11,
|
|
|
center: value.addressInfo.lnglat,
|
|
@@ -44,10 +46,9 @@ export const Component = defineComponent({
|
|
|
position: value.addressInfo.lnglat,
|
|
|
});
|
|
|
map.value.add(marker.value);
|
|
|
- if (!store.isEditMode) {
|
|
|
- const toolbar = new AMap.ToolBar({ position: "LT" }); // 缩放工具条实例化
|
|
|
- map.value.addControl(toolbar);
|
|
|
- }
|
|
|
+
|
|
|
+ const toolbar = new AMap.ToolBar({ position: "LT" }); // 缩放工具条实例化
|
|
|
+ map.value.addControl(toolbar);
|
|
|
});
|
|
|
// })
|
|
|
// .catch((e: any) => {
|
|
@@ -61,11 +62,8 @@ export const Component = defineComponent({
|
|
|
map.value.setZoomAndCenter(11, value.addressInfo.lnglat);
|
|
|
}
|
|
|
|
|
|
- // openMap(options) {
|
|
|
- // this.controls.wxCtrl.openMap(options);
|
|
|
- // },
|
|
|
-
|
|
|
function openMap() {
|
|
|
+ if (store.isEditMode) return;
|
|
|
const options = {
|
|
|
latitude: value.addressInfo.lnglat[1], // 纬度,浮点数,范围为90 ~ -90
|
|
|
longitude: value.addressInfo.lnglat[0], // 经度,浮点数,范围为180 ~ -180。
|
|
@@ -87,22 +85,18 @@ export const Component = defineComponent({
|
|
|
return () => (
|
|
|
<View compId={props.compId}>
|
|
|
<div
|
|
|
- id={props.compId}
|
|
|
+ ref={mapContainerRef}
|
|
|
class="w-1/1"
|
|
|
- // style={{ aspectRatio: 1 }}
|
|
|
style={{
|
|
|
height: "calc(100% - 44px)",
|
|
|
}}
|
|
|
></div>
|
|
|
- {!store.isEditMode && (
|
|
|
- <div
|
|
|
- class="absolute right-20px bottom-50px rounded-1/2 w-40px h-40px flex items-center justify-center bg-[#0085fe]"
|
|
|
- onClick={openMap}
|
|
|
- >
|
|
|
- <IconAirPlain class="text-20px" />
|
|
|
- </div>
|
|
|
- )}
|
|
|
-
|
|
|
+ <div
|
|
|
+ class="absolute right-20px bottom-50px rounded-1/2 w-40px h-40px flex items-center justify-center bg-[#0085fe]"
|
|
|
+ onClick={openMap}
|
|
|
+ >
|
|
|
+ <IconAirPlain class="text-20px" />
|
|
|
+ </div>
|
|
|
<div class="text-14px text-[#666] py-15px text-center bg-light-50">
|
|
|
{value.addressInfo.address}
|
|
|
</div>
|