在vue2-google-map中填充标记的方法如下:
import { GoogleMapLoader, MapMarker } from 'vue2-google-map'
<template>
<div>
<google-map-loader :api-key="YOUR_API_KEY" :config="mapConfig">
<template slot-scope="{ google }">
<div class="map-container">
<google-map :center="mapCenter" :zoom="mapZoom" :options="mapOptions" :google="google">
<map-marker :position="markerPosition" :google="google"></map-marker>
</google-map>
</div>
</template>
</google-map-loader>
</div>
</template>
data() {
return {
mapCenter: { lat: 37.7749, lng: -122.4194 }, // 地图中心点的经纬度
mapZoom: 12, // 地图的缩放级别
mapOptions: {
// 地图的其他配置,例如地图类型、控件等
},
markerPosition: { lat: 37.7749, lng: -122.4194 } // 标记的位置的经纬度
}
}
<style scoped>
.map-container {
width: 100%;
height: 400px;
}
</style>
以上就是在vue2-google-map中填充标记的基本步骤。通过设置地图的中心点、缩放级别和标记的位置,可以在地图上显示一个标记。你可以根据实际需求,调整地图的配置和标记的位置。如果需要更多的功能,可以参考vue2-google-map的官方文档。
推荐的腾讯云相关产品:腾讯云地图服务(https://cloud.tencent.com/product/tianditu)
领取专属 10元无门槛券
手把手带您无忧上云