Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to display 2 fields from the POIData layer. What i get now is ${ToegangsNr} ${Baanvak} in text. Does anyone know how to do this in an DynamicMapServiceLayer. Thanks in advance

POIData = new esri.layers.ArcGISDynamicMapServiceLayer("https://gis.strukton.com/ArcGIS/rest/services/POI_Data/MapServer", { id: "POI", "visible":false });
        map.addLayer(POIData);







                dojo.connect(map, "onClick", function(evt) {
                                map.infoWindow.resize(175, 125);
                                    var symbol = new esri.symbol.SimpleMarkerSymbol().setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_X).setSize(12);
                                    symbol.outline.setWidth(4).setColor("blue");

                                    dojo.connect(map, "onClick", function(evt) {
                                            map.graphics.clear();
                                            var graphic = new esri.Graphic(evt.mapPoint, symbol);
                                            map.graphics.add(graphic);

                                            map.infoWindow.setTitle("<b>${ToegangsNr}</b>");
                                            map.infoWindow.setContent("<tr>Baanvak: <td>${Baanvak}</tr></td>");


                                            map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
                                    });

                                    dojo.connect(map.infoWindow, "onHide", function() {
                                            map.graphics.clear();
                                    });
                                                                    });
share|improve this question
add comment

1 Answer 1

To show the substituted data, you'll need to set the graphic's InfoTemplate, instead of setting the InfoWindow directly. Here's an example using your code.

var POITemplate = new esri.InfoTemplate();
POITemplate.setTitle("<b>${ToegangsNr}</b>");
POITemplate.setContent("<tr>Baanvak: <td>${Baanvak}</tr></td>");

// a little further down in your code.

dojo.connect(map, "onClick", function(evt) {
    map.graphics.clear();
    var graphic = new esri.Graphic(evt.mapPoint, symbol);

    graphic.setInfoTemplate(POITemplate);

    map.graphics.add(graphic);

    map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
});
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.