ui设计网站,网站图片比例,一单一结手机兼职,做数学题的网站有吗下面代码兼容安卓APP和H5
高德地图官网#xff1a;我的应用 | 高德控制台 #xff0c;绑定服务选择《Web端(JS API)》
/utils/map.js 需要设置你自己的key和安全密钥 export function myAMap() {return new Promise(function(resolve, reject) {if (typeof window.onLoadM…下面代码兼容安卓APP和H5
高德地图官网我的应用 | 高德控制台 绑定服务选择《Web端(JS API)》
/utils/map.js 需要设置你自己的key和安全密钥 export function myAMap() {return new Promise(function(resolve, reject) {if (typeof window.onLoadMyAMap function) {resolve(window.onLoadMyAMap)return}window.onLoadMyAMap function() {resolve(window.onLoadMyAMap)}window._AMapSecurityConfig {securityJsCode: 你的安全密钥,};var script document.createElement(script)script.type text/javascriptscript.src https://webapi.amap.com/maps?v2.0key你的keycallbackonLoadMyAMappluginAMap.Geocoder,AMap.AutoComplete,AMap.PlaceSearchscript.onerror rejectdocument.head.appendChild(script)})
} 页面代码
templateview classgaodeMapview classmap v-bind:style{ height: windowHeight * 2 rpx} idcontainer/view/view
/templatescriptexport default {data() {return {windowHeight: ,}},methods: {},mounted() {//默认高度uni.getSystemInfo({success: res {this.windowHeight res.windowHeight;}});}}
/scriptscript moduleallmap langrenderjsimport {myAMap} from /utils/map.js;let amap;const _window window;export default {data() {return {latitude: 22.543648,longitude: 114.057923,zoom: 5,}},methods: {//获取地图信息initMap() {myAMap().then(() {// 创建地图实例amap new AMap.Map(container, {zoom: 5, // 地图缩放比例zooms: [4, 20], // 地图缩放区间center: [114.057923, 22.543648], //设置经纬度为地图中心resizeEnable: true, // 开启地图缩放});// 设置个性化地图// var styleName amap://styles/ darkblue// amap.setMapStyle(styleName);// 地图缩放事件amap.on(zoomend, (e) {});// 地图拖拽事件amap.on(dragend, (e) {});})},},mounted() {this.initMap()},beforeDestroy() {// 离开页面销毁地图amap amap.destroy();amap null}}
/scriptstyle langscss scoped
/style
效果图