我有一個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'.
我怎樣才能創建一個信息窗口?
這是有幫助的太好了! –