私は、ユーザーがいくつかの160-ishレイヤーを切り替えることができるWebアプリケーションを持っています。それらのほとんどはフィーチャーレイヤーですが、一部のタイプはArcGISDynamicMapServiceLayer
です。レイヤクエリーが成功した直後にインフォウィンドウを表示
フィーチャレイヤーと同じようにこれらのレイヤーをクエリできるようにする必要があります。マップ上の任意のポイントをクリックし、インフォウィンドウを表示する必要があります。
これは(明確にするためにいくつかのビットを削除し)、これまで自分のコードである:
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);
});
});
},
キーポイントはqueryTask.execute
コールバックinsiseあります。コメントを外してgraphic.setInfoTemplate(infoTemplate);
を使用した場合、結果は着色され、2回目のクリックでインフォウインドウがポップアップします。 このアプローチには2つの問題があります。
- 2回のクリックが
- を必要としているが、私は二回ポリラインとポイントをクリックすることができませんので、何の情報ウィンドウがここにポップアップしません。
この理由から、半径を100mにするために円を追加しました。今すぐinfoWindowをすぐに返したいと思います。 この時点で、すぐに表示される情報ウィンドウを正常に作成するために苦労しています。
は、現在の行scope.map.infoWindow.setContent(graphic.attributes);
はFailed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
がどのように情報ウィンドウことを作成することができ、エラーがスローされますか?
お役に立ちましたか? –