我有一个Web应用程序时,用户可以在其中某些160肥胖型层之间进行切换。其中大多数是功能层,但有些是ArcGISDynamicMapServiceLayer
类型。一第二层的查询后立即显示信息窗口成功
我需要能够查询这些层一样我FeatureLayers做:通过点击地图上的任意点和显示信息窗口。
这是到目前为止我的代码(去掉了一些位为清楚起见):
executeQueryTask: function(evt, scope) {
//"this" is the map object in this context, so we pass in the scope from the caller,
//which will enable us to call the layer and map object and all the other precious widget properties
scope.map.graphics.clear();
scope.map.infoWindow.hide();
//we create a new Circle and set its center at the mappoint. The radius will be 20 meters
//default unit is meters.
var circle = new Circle({
/*...*/
});
// draw the circle to the map:
var circleGraphic = new Graphic(circle, /*...*/));
scope.map.graphics.add(circleGraphic);
var queryTask = new QueryTask(scope.layer.layer.url + "/" + scope.layer.layer.visibleLayers[0]);
var query = new Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.geometry = circle.getExtent();
var infoTemplate = new InfoTemplate().setTitle("");
queryTask.execute(query, function(resultSet) {
array.forEach(resultSet.features, function(feature) {
var graphic = feature;
graphic.setSymbol(/*...*/));
//Set the infoTemplate.
// graphic.setInfoTemplate(infoTemplate);
//Add graphic to the map graphics layer.
scope.map.infoWindow.setContent(graphic.attributes);
scope.map.infoWindow.show(evt.mapPoint, scope.map.getInfoWindowAnchor(evt.screenPoint));
scope.map.graphics.add(graphic);
});
});
},
的关键点是insise的queryTask.execute
回调。如果我取消注释并使用graphic.setInfoTemplate(infoTemplate);
,则结果会变为彩色,并在第二次单击时弹出一个infoWindow。 有2个问题,这种方法:
- 2点击需要
- 我无法对折线和点单击两次,所以没有在这里信息窗口弹出。
这就是为什么我添加了一个圆来获得半径为100米的缓冲区来点击我。现在我想立即返回一个infoWindow。 在这一点上,我努力成功地创建了一个立即显示的信息窗口。
目前该行scope.map.infoWindow.setContent(graphic.attributes);
引发错误Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
我怎样才能创建一个信息窗口?
这是有帮助的太好了! –