引入百度地图api不显示地图

来源:8-1 (上)销售大盘地图组件开发

慕神4213171

2024-08-16

https://img1.sycdn.imooc.com/szimg/66ce9e5c091664ed28480950.jpg

https://img1.sycdn.imooc.com/szimg/66ce9e5d09076d2925920950.jpg

index.html

<!DOCTYPE html>

<html lang="">

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width,initial-scale=1.0">

<link rel="icon" href="<%= BASE_URL %>favicon.ico">

<title><%= htmlWebpackPlugin.options.title %></title>

</head>

<body>

<noscript>

<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>

</noscript>

<div id="app"></div>

<!-- built files will be auto injected -->

<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=1XjLLEhZhQNUzd93EjU5nOGQ"></script>

</body>

</html>


BMap.vue

<template>

<v-chart :options="options" style="width: 500px; height: 500px;"></v-chart>

</template>


<script>

import 'echarts/extension/bmap/bmap'


export default {

data() {

return {

options: {}

}

},

mounted() {

/* eslint-disable */

this.options = {

bmap: {

key: 'G1LFyjrNGIkns5OfpZnrCGAKxpycPLwb',

center: [104.114129, 37.550339],

zoom: 5,

roam: false,

mapStyle: {

styleJson: [{

'featureType': 'water',

'elementType': 'all',

'stylers': {

'color': '#d1d1d1'

}

}, {

'featureType': 'land',

'elementType': 'all',

'stylers': {

'color': '#f3f3f3'

}

}, {

'featureType': 'railway',

'elementType': 'all',

'stylers': {

'visibility': 'off'

}

}, {

'featureType': 'highway',

'elementType': 'all',

'stylers': {

'color': '#fdfdfd'

}

}, {

'featureType': 'highway',

'elementType': 'labels',

'stylers': {

'visibility': 'off'

}

}, {

'featureType': 'arterial',

'elementType': 'geometry',

'stylers': {

'color': '#fefefe'

}

}, {

'featureType': 'arterial',

'elementType': 'geometry.fill',

'stylers': {

'color': '#fefefe'

}

}, {

'featureType': 'poi',

'elementType': 'all',

'stylers': {

'visibility': 'off'

}

}, {

'featureType': 'green',

'elementType': 'all',

'stylers': {

'visibility': 'off'

}

}, {

'featureType': 'subway',

'elementType': 'all',

'stylers': {

'visibility': 'off'

}

}, {

'featureType': 'manmade',

'elementType': 'all',

'stylers': {

'color': '#d1d1d1'

}

}, {

'featureType': 'local',

'elementType': 'all',

'stylers': {

'color': '#d1d1d1'

}

}, {

'featureType': 'arterial',

'elementType': 'labels',

'stylers': {

'visibility': 'off'

}

}, {

'featureType': 'boundary',

'elementType': 'all',

'stylers': {

'color': '#fefefe'

}

}, {

'featureType': 'building',

'elementType': 'all',

'stylers': {

'color': '#d1d1d1'

}

}, {

'featureType': 'label',

'elementType': 'labels.text.fill',

'stylers': {

'color': '#999999'

}

}]

}

}

}

}

}

</script>


<style lang="scss">

</style>



写回答

1回答

扬_灵

2024-08-25

同学你好,麻烦提供下完整的测试代码或者是错误截图,这样好帮你测试定位问题。

0
4
扬_灵
回复
慕神4213171
回复 慕神4213171:同学你好,非常抱歉,之前没有刷出问题,已经再你提问的另外一个问题回复了
2024-09-17
共4条回复

数据可视化入门到精通-打造前端差异化竞争力

同级别前端,掌握数据可视化薪资更高

1525 学习 · 1043 问题

查看课程