Vue-Baidu-Map百度地图使用
<template>
<baidu-map class="map" :center="center" :zoom="zoom">
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
<bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation>
<bm-marker :position="center" :dragging="true" animation="BMAP_ANIMATION_BOUNCE"></bm-marker>
</baidu-map>
</template>
<script>
import Vue from 'vue';
import BaiduMap from 'vue-baidu-map/components/Map/Map.vue';
import BmNavigation from 'vue-baidu-map/components/Navigation/Navigation.vue';
import BmGeolocation from 'vue-baidu-map/components/Geolocation/Geolocation.vue';
import BmMarker from 'vue-baidu-map/components/Overlays/Marker.vue';
export default {
components: {
'baidu-map': BaiduMap,
'bm-navigation': BmNavigation,
'bm-geolocation': BmGeolocation,
'bm-marker': BmMarker
},
data() {
return {
center: { lng: 116.404, lat: 39.915 },
zoom: 15
};
}
};
</script>
<style>
.map {
width: 100%;
height: 500px;
}
</style>
这段代码展示了如何在Vue应用中集成百度地图,并添加了导航组件、地理位置定位组件和标记点组件。代码简洁明了,注释也有助于理解每个部分的功能。
评论已关闭