您的位置:首页 > Web前端 > JavaScript

arcgis api for javascript IdentifyTask使用

2015-01-21 17:15 267 查看
直接上代码

map.on("load", initFunctionality);
function initFunctionality() {
	map.on("click", doIdentify);
	identifyTask = new IdentifyTask(dynamicLayerUrl);//查询
	identifyParams = new IdentifyParameters();//查询参数
	identifyParams.tolerance = 10;//容差范围
	identifyParams.returnGeometry = true;//是否返回图形
	identifyParams.layerIds = [ 0 ];//查询图层 
	identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE;//设置查询的图层
	//查询范围
	identifyParams.width = map.width;
	identifyParams.height = map.height;
}
function doIdentify(event) {
	map.graphics.clear();
	identifyParams.geometry = event.mapPoint;
	identifyParams.mapExtent = map.extent;
	identifyTask
			.execute(
					identifyParams,
					function(results) {
						var feature;
						var sGeometry;
						if (results.length > 0) {
							for ( var i = 0; i < results.length; i++) {
								feature = results[i].feature;
								map.infoWindow.setTitle("标注信息");
								map.infoWindow
										.setContent("<span>地区:</span>"
												+ feature.attributes.NAME_
												+ "<br>"
												+ "<span>机构:</span>"
												+ feature.attributes.TYPENAME_
												+ "<br>"
												+ "<span>站点:</span>"
												+ feature.attributes.NOTES_
												+ "<br>"
												+ "<span>地址:</span>"
												+ feature.attributes.LOCATION_);
								attachmentEditor
										.showAttachments(
												feature,
												dynamicLayer);
								map.infoWindow
										.show(
												feature.geometry,
												map
														.getInfoWindowAnchor(feature.geometry));
								map.infoWindow.show();
							}
						}
					});
}


一点点积累怕忘了都是官网的例子其实
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐