Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Baidu Map display in vuejs Project

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report