uniapp 谷歌地图 nvue

问题集合

安卓App端,开启点聚合

  1. 会导致@markertap和@labeltap的点击事件失效(未解决)
  2. 标记点Label属性失效(未解决)
html 复制代码
<view class="content">
		<map id="map" class="map" :show-location="true" :latitude="latitude" :longitude="longitude"
			@markertap="markertap" @labeltap="labeltap"></map>
	</view>
javascript 复制代码
const img = '/static/logo.png';

	export default {
		data() {
			return {
				latitude: 32.715738,
				longitude: -117.1610838,
			}
		},
		onReady() {
			this._mapContext = uni.createMapContext("map", this);
			// this.clusterEvent()
			this.addMarkers();
		},
		methods: {
			// 开启聚合
			clusterEvent(){
				// 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})
				this._mapContext.initMarkerCluster({
					enableDefaultStyle: false,
					zoomOnClick: true,
					gridSize: 60,
					complete(res) {
						console.log('initMarkerCluster', res)
					}
				});
				// 缩放或拖动导致新的聚合簇产生时触发,仅返回新创建的聚合簇信息。
				this._mapContext.on("markerClusterCreate", (e) => {
					// console.log("markerClusterCreate", e);
				});
				// 聚合点击事件
				this._mapContext.on("markerClusterClick", (e) => {
					// console.log("markerClusterClick", e);
				})
			},
			// 添加标记点
			addMarkers() {
				const positions = [{
					latitude: 32.715738,
					longitude: -117.1610838,
				}, {
					latitude: 32.715180,
					longitude: -117.1610838,
				}, {
					latitude: 32.715180,
					longitude: -117.16217638,
				}]

				const markers = []

				positions.forEach((p, i) => {
					markers.push(
						Object.assign({}, {
							id: i + 1, // markertap点击事件必须指定id
							iconPath: img,
							width: 50,
							height: 50,
							// joinCluster: true, // 指定了该参数才会参与聚合
							label: { // 点聚合开启,label失效
								width: 50,
								height: 30,
								borderWidth: 1,
								borderRadius: 10,
								fontSize: 14,
								color: '#fff',
								textAlign: 'center',
								bgColor: '#1bff18',
								content: `label ${i + 1}`
							}
						}, p)
					)
				})
				this._mapContext.addMarkers({
					markers,
					clear: false,
					complete(res) {
						console.log('addMarkers', res)
					}
				})
			},
			// 标记点点击事件(注:安卓app,点聚合开启,标记点点击失效)
			markertap(evt) {
				console.log("Marker点击", evt);
			},
			// Label标签点击事件(注:安卓app,点聚合开启,Label标签点击失效)
			labeltap(evt) {
				console.log("Label点击", evt);
			},
		}
	}
相关推荐
q***31891 天前
Spring Boot--@PathVariable、@RequestParam、@RequestBody
java·spring boot·后端
Macbethad1 天前
如何用WPF做工控设置界面
java·开发语言·wpf
CodeAmaz1 天前
使用责任链模式设计电商下单流程(Java 实战)
java·后端·设计模式·责任链模式·下单
喝养乐多长不高1 天前
Rabbit MQ:概述
java·rabbitmq·mq·amqp
毕设十刻1 天前
基于Vue的鲜花销售系统33n62(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js
IT_陈寒1 天前
Spring Boot 3.2震撼发布:5个必知的新特性让你开发效率提升50%
前端·人工智能·后端
拾忆,想起1 天前
Dubbo异步调用实战指南:提升微服务并发性能
java·服务器·网络协议·微服务·云原生·架构·dubbo
初遇你时动了情1 天前
前端使用TensorFlow.js reactjs调用本地模型 实现图像、文本、音频/声音、视频相关识别
前端·javascript·tensorflow
广州华水科技1 天前
单北斗GNSS变形监测系统安装与应用解析,提升位移监测精度
前端
J***Q2921 天前
前端微前端框架原理,qiankun源码分析
前端·前端框架