Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Baidu Map display in vuejs Project

Shulou Source: shulou.com Published: 2022-06-03 10:14:00 11月15日 Update

This article introduces how the vuejs project to achieve Baidu map display, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Implementation methods: 1, in the "Baidu Map Development platform" to apply for the key; 2, in the "index.html" in the use of script tags to introduce map links; 3, in the "APP.vue" into the relevant js code to achieve Baidu map.

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Vue uses Baidu Maps in the project

The first step is to go to Baidu map development platform http://lbsyun.baidu.com/ to apply for the key.

The second step is introduced into the project, as follows

Index.html stores the map link, and the code is as follows

Then implement it in APP.vue. The code is as follows

Export default {name: 'App', methods: {map () {let map = new BMap.Map (this.$refs.allmap); / / create Map instance map.centerAndZoom (new BMap.Point (116.404, 39.915), 11) / / initialize the map, set the center point coordinates and map level map.addControl (new BMap.MapTypeControl ({/ / add map type control mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP]}); map.setCurrentCity ("Beijing"); / / set the city displayed on the map. This is the map.enableScrollWheelZoom (true) that must be set. / / enable mouse wheel zoom}, mounted () {this.map ()} # app {font-family: 'Avenir', Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale; text-align: center; color: # 2c3e50; margin-top: 60px;} # allmap {height: 500px; overflow: hidden } about the vuejs project how to achieve Baidu map display to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Maps projects code content platforms development platforms more links help development good center center interests coordinates cities examples guys buddies controls Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Docker Redmi Shulou Tech Info