1

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

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();
    });
});
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));
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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