Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uniapp中部署h5的时候,无法通过this.mapContext.addMarkers方法来添加标点,还有什么其他办法,通过高德地图这样? #5237

Open
KKJava1 opened this issue Dec 2, 2024 · 0 comments

Comments

@KKJava1
Copy link

KKJava1 commented Dec 2, 2024

			addMarkerCircle(latitude, longitude) {
				const marker = {
					id: this.markLength, // 确保 ID 唯一
					latitude: latitude,
					longitude: longitude,
					width: 20,
					height: 25
				};

				// 动态更新 markerList
				this.markerList.push(marker);

				this.mapContext.addMarkers({
					markers: [marker],
					clear: true,
					success: () => {
					   uni.showToast({
						   title: `添加标记成功`,
						   icon: 'none'
					   });
						this.typeDetail = true;
						this.djDetail.lng = longitude;
						this.djDetail.lat = latitude;
						this.djDetail.shape = 0;
					},
					fail: (err) => {
						console.error("Failed to add marker:", err);
					}
				});
			},

        	onShow() {
				this.initForm()
				//获取当前定位
				this.getLocation()
				this.mapContext = uni.createMapContext('map', this);

			},
		<map  style="width:100%;height:100%;" id="map" ref="mapRef" :latitude="latitude" :longitude="longitude" :scale="scale"
				:show-location="true" :markers="markerList" :polygons="polygons" :circles="circles" @updated="bindtap()">
			</map>

还有什么其他办法,能够调用后,标记成一个点markerList,在地图上展示就好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant