高德地图 常见问题

多边形查询,有的点标记跑到多边形外面去了

1、问题描述

2、原因分析

原因是查询时的配置选项不是点坐标,而是区域查询什么的。

3、解决方法


被圆覆盖物覆盖的云图的点标记,点击不能弹出信息窗

1、问题描述

     1)被圆覆盖物覆盖的云图的点标记,点击不能弹出信息窗——调试的时候,点击回调函数没有被执行。没有被覆盖的点标记,则点击可以正常弹出信息窗口。
    2)我试了一下,先绘制圆,再上云图的数据,点击点标记还是一样不能弹出信息窗口。


2、原因分析
点击没有弹出信息窗口的原因是,此时的点击事件监听器无效。


3、解决方法
虽然云图的点标记的点击事件监听器无效,但是点击列表里的点标记是可以正常弹出信息窗口的。




点击点标记,重新设置地图的中心点

1、问题描述

2、原因分析

3、解决方法
1)设置中心点。
2)禁止信息窗口自动移动。

/**
 * 添加点标记和信息窗口
 * 
 * @param resourceType
 *            应急资源类型
 * @param iconUrl
 *            图标路径
 */
function addMarkerAndInfoWindowImplAnalyze(iconUrl) {
	markerCoordinates[eventType] = [];
	infoWindows[eventType] = [];

	for ( var j = 0; j < dataTypeNumbers[eventType]; j++) {
		var d = dataTypeDatas[eventType][j]; // 获取当前标记
		lastMarkerIndex++;

		// 获取当前地址(即点标记)的坐标、名字和地址
		if (d.location) {
			lngX = d.location.getLng();
			latY = d.location.getLat();
		} else {
			lngX = d._location.getLng();
			latY = d._location.getLat();
		}
		if (d.name) {
			iName = d.name;
		} else {
			iName = d._name;
		}
		if (d.name) {
			iAddress = d.address;
		} else {
			iAddress = d._address;
		}

		// 创建标记,并且添加到标记数组
		var markerOption = {
			id: "marker" + lastMarkerIndex,
			title: d._name,
			map : mapObj,
			icon : iconUrl,
			position : new AMap.LngLat(lngX, latY)
		};
		var marker = new AMap.Marker(markerOption);
		markerCoordinates[eventType].push(new AMap.LngLat(lngX, latY)); // 添加到标记数组

		// 创建信息窗口,并且添加到信息窗口数组
		var infoWindow = new AMap.InfoWindow({
			id : "infoWindow" + lastMarkerIndex,
			content : "<h3><font color=\"#00a6ac\">" + iName + "</font></h3>"
					+ "<br/>地址:" + iAddress 
					+ "<br/>创建时间::" + d.createtime
					+ "<br/>更新时间:" + d.updatetime
					+ "<input type='button' value='分析' οnclick='analyze(\""
					+ new AMap.LngLat(lngX, latY) + "\");'>"
					+ "</td></tr></table></div>",
			size : new AMap.Size(300, 0),
			autoMove : false, //禁止信息窗口自动定位
			offset : new AMap.Pixel(0, -30)
		});
		marker.infoWindow = infoWindow;
		infoWindows[eventType].push(infoWindow); // 添加到信息窗口数组

		// 点击标记,弹出信息窗口
		var openInfoWindow = function(e) {
			this.infoWindow.open(mapObj, this.getPosition());
			mapObj.setCenter(this.getPosition()); // 设置地图的中心点
		};
		AMap.event.addListener(marker, "click", openInfoWindow);
	}
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值