tencent-map.vue 683 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <div ref="domRef" class="w-full h-full"></div>
  3. </template>
  4. <script setup lang="ts">
  5. import { onMounted, ref } from 'vue';
  6. import { useScriptTag } from '@vueuse/core';
  7. import { TENCENT_MAP_SDK_URL } from '@/config';
  8. defineOptions({ name: 'TencentMap' });
  9. const { load } = useScriptTag(TENCENT_MAP_SDK_URL);
  10. const domRef = ref<HTMLDivElement | null>(null);
  11. async function renderMap() {
  12. await load(true);
  13. if (!domRef.value) return;
  14. // eslint-disable-next-line no-new
  15. new TMap.Map(domRef.value, {
  16. center: new TMap.LatLng(39.98412, 116.307484),
  17. zoom: 11,
  18. viewMode: '3D'
  19. });
  20. }
  21. onMounted(() => {
  22. renderMap();
  23. });
  24. </script>
  25. <style scoped></style>