高德地图Marker增加自定义vue组件

this.content = '';
this.component && this.component.$destroy();
let _com = `<自定义组件></自定义组件>`;
let contentStr = `<div>` + _com +`</div>`

this.content = Vue.extend({
    template: contentStr,
    name: 'Com',
    components: {
        '自定义组件': 自定义组件
    },
});
this.component = new this.content().$mount();

this.marker=  new AMap.Marker({
    map: this.aMap,
    zIndex:135,
    content: this.component.$el,
    anchor: 'bottom-left',
    offset: [0, -this.$fontSize(0.08)],
    position:this.position,
});
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!对于Vue项目中使用高德地图marker点击跳转页面的需求,您可以按照以下步骤进行操作: 1. 首先,确保您已经成功引入了高德地图相关的 JavaScript API,并在Vue项目中初始化地图组件。 2. 在Vue组件中,您可以通过创建一个`InfoWindow`组件来实现marker的点击事件。 ```vue <template> <div> <el-button @click="showInfoWindow">显示Marker</el-button> <el-dialog v-if="showDialog" :visible.sync="showDialog"> <!-- 在此处添加您自定义的内容,可以是跳转链接或其他操作 --> <a href="your-link">跳转页面</a> </el-dialog> </div> </template> <script> export default { data() { return { showDialog: false }; }, methods: { showInfoWindow() { this.showDialog = true; } } }; </script> ``` 3. 在地图初始化后,创建并添加Marker时,您可以通过监听marker的`click`事件来触发`showInfoWindow`方法,显示弹窗。 ```vue // 在合适的钩子函数中初始化地图,并添加Marker mounted() { // 初始化地图 // ... // 创建并添加Marker const marker = new AMap.Marker({ position: [longitude, latitude], map: mapInstance // mapInstance为地图实例 }); // 监听marker的click事件 marker.on('click', () => { this.showInfoWindow(); }); }, ``` 在上述示例中,点击"显示Marker"按钮将会弹出对话框,您可以在对话框中添加自定义的内容,如跳转链接或其他操作。请注意,在`<a href="your-link">跳转页面</a>`处,将"your-link"替换为您想要跳转的链接。 希望能对您有所帮助!如果有任何问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值