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

上饶有哪些做网站的公司企业网站美工设计

上饶有哪些做网站的公司,企业网站美工设计,设计公司网页模板,wordpress rss插件在vue3中引入高德地图API要实现的功能 设置地图的显示样式实现点击地图添加标记、点击地图获取详细地址和经纬度输入框搜索获取相关地区提示#xff08;下拉框#xff0c;选中后进行标记#xff0c;视角移动到相对位置#xff09;输入框输入内容#xff0c;回车获取详细地…在vue3中引入高德地图API要实现的功能 设置地图的显示样式实现点击地图添加标记、点击地图获取详细地址和经纬度输入框搜索获取相关地区提示下拉框选中后进行标记视角移动到相对位置输入框输入内容回车获取详细地址和经纬度 1、准备工作 官方文档 V2.0https://lbs.amap.com/api/jsapi-v2/guide/abc/prepare 官方参考手册https://lbs.amap.com/api/jsapi-v2/documentation 先进入高德开放平台跟着步骤注册账号创建应用 创建时服务平台要选择【web端JS API】如果选其他服务有些功能用不了比如后面的地址逆解析。 官网示例地址地图的创建-生命周期-示例中心-JS API 示例 | 高德地图API (amap.com) 2、用npm/yarn下载包初始化地图 在Vue 3中引入高德地图你可以按照以下步骤进行操作 在项目目录中使用npm或yarn安装高德地图的JavaScript API库。你可以使用以下命令之一 npm install amap/amap-jsapi-loader yarn add amap/amap-jsapi-loader2.1、注意事项 1、必须要有安全密钥不然有的api调用返回为undefined window._AMapSecurityConfig {// 安全密钥securityJsCode: 95869xxxxxxxxxxxxxxxxx53df87dfb, };3、组件代码需要替换密钥和key templatediv idcontainer/div /templatescript setup langts import AMapLoader from amap/amap-jsapi-loader import { onMounted, watch, defineProps,defineEmits,onUnmounted,ref, reactive } from vue import { log } from console// 使用defineEmits创建名称接受一个数组 const emit defineEmits([clickChild]); const props defineProps({childValue: {default:},infos:{type:Object,default:{lng:undefined,lat:undefined}} }); let isTrueref(false) let isProductionref(true) let optionsref([]) let map:any null //标记点 let marker // 地址逆解析 let geoCoder:anynull // 位置信息 let form ref({lng: ,lat: ,address: ,//地区编码adcode: , }) let AutoComplete:anynull window._AMapSecurityConfig {securityJsCode: 95869xxxxxxxxxxxxxxxxx53df87dfb, } watch(() props.childValue,(newValue, oldValue) {if(isProduction.value){// 地理编码geoCode()}else{// 搜索提示remoteMethod(newValue)}} );watch(() isTrue.value,(newValue, oldValue) {if(newValueprops.infos.lng){// 获取经纬度form.value.lng props.infos.lng;form.value.lat props.infos.lat;// 清除点removeMarker();// 标记点setMapMarker();}} ); watch(() props.infos.lng,(newValue, oldValue) {if(newValueisTrue.value){// 获取经纬度form.value.lng props.infos.lng;form.value.lat props.infos.lat;// 清除点removeMarker();// 标记点setMapMarker();}} ); // 搜索 function remoteMethod(query:any) {if (query ! ) {AutoComplete.search(query, (status:any, result:any) {options.value result.tips;let obj{options:options.value}emit(clickChild, obj);} else {options.value [];} }// 标记点 function setMapMarker() {// 自动适应显示想显示的范围区域map.setFitView();marker new AMap.Marker({map: map,position: [form.value.lng, form.value.lat],});map.setFitView();// // 逆解析地址// toGeoCoder();map.add(marker); } // 清除点 function removeMarker() {if (marker) {map.remove(marker);} }//正解析地址 function geoCode(){let geocoder new AMap.Geocoder({// city: 010, //城市设为北京默认“全国”radius: 1000 //范围默认500});let address props.childValue;geocoder.getLocation(address, function(status:any, result:any) {if (status completeresult.geocodes.length) {var e result.geocodes[0].location// 获取经纬度form.value.lng e.lng;form.value.lat e.lat;// 清除点removeMarker();// 标记点setMapMarker();let obj{ParkLongitude:form.value.lng,ParkLatitude:form.value.lat,address:address}emit(clickChild, obj);}else{// log.error(根据地址查询位置失败);}}); } // 逆解析地址 function regeoCode() {let geocoder new AMap.Geocoder({// city: 010, //城市设为北京默认“全国”radius: 1000 //范围默认500});let lnglat [form.value.lng,form.value.lat];geocoder.getAddress(lnglat, function(status:any, result:any) {if (status completeresult.regeocode) {let address result.regeocode.formattedAddress;// 解析的地址address;let obj{ParkLongitude:form.value.lng,ParkLatitude:form.value.lat,address:address}emit(clickChild, obj);}else{// log.error(根据经纬度查询地址失败)}}); }//获取详细地址 function toGeoCoder() {AMap.plugin(AMap.Geolocation, function() {let geolocation new AMap.Geolocation({enableHighAccuracy: true,//是否使用高精度定位默认:truetimeout: 10000, //超过10秒后停止定位默认5sposition:RB, //定位按钮的停靠位置offset: [form.value.lng, form.value.lat], //定位按钮与设置的停靠位置的偏移量默认[10, 20]zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点needAddress:true,});map.addControl(geolocation);geolocation.getCurrentPosition(function(status:any, result:any){if(statuscomplete){// onComplete(result)}else{// onError(result)}});}); } onMounted(() {AMapLoader.load({key: 95869xxxxxxxxxxxxxxxxx53df87dfb,version: 2.0,// 需要用到的插件plugins: [AMap.Geocoder, AMap.AutoComplete,AMap.Geolocation],}).then((AMap) {map new AMap.Map(container, {viewMode: 3D,zoom: 11,mapStyle: amap://styles/grey, //设置地图的显示样式// center: [116.397428, 39.90923],})// 搜索提示插件AutoComplete new AMap.AutoComplete({ city: 全国 });//为地图注册click事件获取鼠标点击出的经纬度坐标map.on(click, function(e:any) {map.value e.lnglat.getLng() , e.lnglat.getLat()// 点击位置, e.lnglat;// 获取经纬度form.value.lng e.lnglat.lng;form.value.lat e.lnglat.lat;// 清除点removeMarker();// 标记点setMapMarker();regeoCode();});isTrue.valuetrue}).catch((e) {}) }) onUnmounted(() {map map.destroy(); }) /script script langts // 起名字否则每个组件在开发者工具中都为index export default {name: Maps, }; /script style scoped #container {width: 100%;height: 100%; } /style
http://www.yutouwan.com/news/383687/

相关文章:

  • nodejs做网站容易被攻击吗如何备份网站 整站
  • 延边网站建设网页制作免费教程
  • 沧州泊头纯设计网站制作wordpress 查询语句
  • 重庆装修设计网站网站开发诺亚科技
  • 护栏板销售网站怎么做照明灯企业网站织梦模板
  • 建设手机网站经验分享做衬衫的作业网站
  • 分类网站模板企业网站建设合同(一)
  • 龙岗平湖网站开发做一网站困难吗
  • 拖拽建站系统源码网站建设公司 北京
  • 关于加快信用平台网站建设通知网站建设的基本需求有哪些
  • 网站业务郑州优化网站收费标准
  • 余姚本地网站排名3322做网站
  • 怎么样新建一个网站应用商店关键词优化
  • 网站流量用完wordpress权限不能更新
  • 怎样做php网站腾讯企业邮箱登录登录入口
  • 视频网站 界面设计wordpress装多个博客
  • 如何用照片做模板下载网站wordpress++分页
  • 我想做个网站 详解怎么做网站怎么做边框
  • 打折网站运营思路nas怎么做自己的网站
  • 哪个网站做农产品外包公司设计完网站谁负责运营
  • 电子商务网站开发需求分析人与畜禽狗croproation
  • 服务器网站建设维护合同那里做直播网站
  • 昆山苏州网站建设wordpress 主题自定义
  • 网站改版 优势有那些网站可以做推广
  • 网站开发亿玛酷信赖迁移wordpress
  • dw怎么做网站标题图标网页设计与制作教程第三版答案
  • 春节网站怎么做高端网站源码
  • 免费网站用官微建站站长素材网app免费下载
  • 人才网网站方案网站制作中企动力优
  • 宜春网站建设公司联系方式wordpress下载视频