当前位置: 首页 > news >正文

关于天地图新手使用

1分钟带你了解学习天地图 适用新手 

天地图API (tianditu.gov.cn) 文档api  先去注册key

把脚本放到index.html文件里面

<!-- 天地图的官网申请的tk -->
<script src="http://api.tianditu.gov.cn/api?v=4.0&tk=申请的key" type="text/javascript"></script>

废话不多说 直接来代码

vue3写法

<template><div id="mapDiv" class="map"></div>
</template><script setup>
import { ref, watch, onMounted, nextTick } from "vue"
import axios from 'axios';
const props = defineProps({data: {type: Object,default: () => {return {longitude: "113.762375",latitude: "39.761003"}}},title: {type: String,default: "北京天安门"}
})const map = ref(null)
const zoom = ref(16)
let longitude = ref("")
let latitude = ref("")const marker = ref(null);
const label = ref(null);watch(() => props.data,(newValue, oldValue) => {initLoad()}
)
const initLoad = () => {// 获取经纬度及名称longitude.value = props.data.longitudelatitude.value = props.data.latitudeif (!map.value) {const T = window.Tmap.value = new T.Map("mapDiv", {// projection: "EPSG:4326",zoom: zoom.value, //设置默认放大缩小center: new T.LngLat(longitude.value, latitude.value) //设置当
http://www.lryc.cn/news/423047.html

相关文章:

  • STM32与Arduino和ESP32对比分析
  • 125. 验证回文串【 力扣(LeetCode) 】
  • 3年经验,面试测试岗20k都拿不到了吗?
  • 【ML】强化学习(Reinforcement Learning)及其拆解
  • 在宝塔面板下安装WordPress
  • 纷享销客CRM AI产品架构概览、产品特色
  • 【文件IO】文件系统操作
  • Spring Cloud Alibaba 集成分布式定时任务调度功能
  • 中职云计算实训室
  • 【python制作一个小程序作为七夕礼物】
  • 一篇文章教会你如何使用Haproxy,内含大量实战案例
  • PythonStudio 控件使用常用方式(二十二)TFlowPanel
  • 培训第二十七天(lvs_nat模式与lvs_dr模式配置)
  • JAVA中DateFormat详解
  • uniapp——列表选择样式
  • 解决客户访问超时1s问题
  • Linux命令(基础面试可用,都是自己觉得平时使用多的)
  • opencv-python图像增强一:传统图像去噪方法整理
  • Canal单机部署
  • java,每日练习02
  • C# TreeView
  • 通过xshell使用密钥连接阿里云服务器
  • <数据集>路面坑洼识别数据集<目标检测>
  • 几个常用脚本
  • gtest中TEST和TEST_F和TEST_P的区别是什么
  • VS2022如何调出输出窗口,并在输出窗口打印日志
  • 【全国大学生电子设计竞赛】2021年I题
  • 【项目】基于Vue2+Router+Vant 前端面经项目
  • 【论文阅读】YOLOv10: Real-Time End-to-End Object Detection
  • 计算资源消耗