part two of the code<script type="text/javascript">
var djConfig = {
parseOnLoad: true
};
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6"></script>
<script type="text/javascript">
dojo.require("dijit.dijit"); // optimize: load dijit layer
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.dijit.Popup");
var layer, map, visible = [];
var identifyTask,identifyParams;
function init() {
//Popup
esri.bundle.widgets.popup.NLS_searching = "Zoeken...";
esri.bundle.widgets.popup.NLS_noInfo = "Niets gevonden";
esri.bundle.widgets.popup.NLS_nextFeature = "Volgende";
esri.bundle.widgets.popup.NLS_prevFeature = "Vorige";
esri.bundle.widgets.popup.NLS_maximize = "Maximaliseren";
esri.bundle.widgets.popup.NLS_restore = "Vorig formaat";
esri.bundle.widgets.popup.NLS_close = "Sluiten";
esri.bundle.widgets.popup.NLS_zoomTo = "Zoom in op selectie";
var initialExtent = new esri.geometry.Extent({"xmin":157741,"ymin":378600,"xmax":181240,"ymax":394100,"spatialReference":{"wkid":28992}});
//setup the popup window
var popup = new esri.dijit.Popup({
fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,255,255]), 2), new dojo.Color([255,255,0,0]))
}, dojo.create("div"));
map = new esri.Map("map",{
infoWindow:popup,
extent: initialExtent,
logo: false});
dojo.addClass(map.infoWindow.domNode, "myTheme");//instellen dat de popup "myTheme" gebruikt
dojo.connect(map, 'onLoad', mapReady);
dojo.connect(map, "onLoad", function() {
map.disableDoubleClickZoom();
});
basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://atlas.sre.nl/ArcGIS/rest/services/TOPOGRAFIE/OSM_2011_ZW/MapServer");
map.addLayer(basemap);
layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://atlas.sre.nl/ArcGIS/rest/services/REGIO/lijst/MapServer", {opacity:.5});
if (layer.loaded) {
buildLayerList(layer);
}
else {
dojo.connect(layer, "onLoad", buildLayerList);
}
}
function buildLayerList(layer) {
var items = dojo.map(layer.layerInfos,function(info,index){
if (info.defaultVisibility) {
visible.push(info.id);
}
return "<input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id + "' onclick='updateLayerVisibility();' /><label for='" + info.id + "'>" + info.name + "</label><br>";
});
dojo.byId("layer_list").innerHTML = items.join("");
layer.setVisibleLayers(visible);
map.addLayer(layer);
}
function updateLayerVisibility() {
var inputs = dojo.query(".list_item"), input;
visible = [];
dojo.forEach(inputs,function(input){
if (input.checked) {
visible.push(input.id);
}
});
//if there aren't any layers visible set the array to be -1
if(visible.length === 0){
visible.push(-1);
}
layer.setVisibleLayers(visible);
}
function mapReady(map){
dojo.connect(map,"onClick",executeIdentifyTask);
//create identify tasks and setup parameters
identifyTask = new esri.tasks.IdentifyTask("http://atlas.sre.nl/ArcGIS/rest/services/REGIO/lijst/MapServer");
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 10;
identifyParams.returnGeometry = true;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParams.width = map.width;
identifyParams.height = map.height;
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
}
function executeIdentifyTask(evt) {
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function(response) {
// response is an array of identify result objects
// Let's return an array of features.
return dojo.map(response, function(result) {
var feature = result.feature;
feature.attributes.layerName = result.layerName;
if(result.layerName === 'Archeologie'){
console.log(feature.attributes.PARCELID);
var template = new esri.InfoTemplate("", "<p><strong>Monumentnummer:</strong> ${MONUMENTNR}<br><strong>Waarde:</strong> ${WAARDE}<br><strong>Type:</strong> ${COMPLEX}<br><strong>Toponiem:</strong> ${TOPONIEM}<br><strong>Begin periode:</strong> ${BEGIN_PERI}<br><strong>Eind periode:</strong> ${EIND_PERIO}</p><p><strong>Toelichting:</strong><br/>${TOELICHTING}</p>");
feature.setInfoTemplate(template);
}
else if(result.layerName === 'Monumenten'){
console.log(feature.attributes.PARCELID);
var template = new esri.InfoTemplate("", "<p><strong>Monumentstatus:</strong> ${Monumentstatus}<br/><strong>Monumentnummer:</strong> ${Monumentnummer}<br/><strong>Aanduiding:</strong> ${Aanduiding}<br><strong>Adres:</strong> ${Adres}<br><strong>Postcode:</strong> ${Postcode}<br><strong>Gemeente:</strong> ${Gemeente}<br><strong>Bouwjaar:</strong> ${Bouwjaar}<br><strong>Architect:</strong> ${Architect}</p><p><strong><a id=info href=${html} target=${target}>Meer informatie</a></strong></p>");
feature.setInfoTemplate(template);
}
else if (result.layerName === 'Rijksbeschermd stads/dorps-gezichten'){
var template = new esri.InfoTemplate("", "<p><strong>Monumentstatus:</strong> Rijksbeschemd stads/dorps-gezicht<br/><strong>Naam: </strong>${NAAM}</p><p><strong><a id=info href=${KICHLINK} target=${target}>Meer informatie</a></strong></p>");
feature.setInfoTemplate(template);
}
return feature;
});
});
// InfoWindow expects an array of features from each deferred
// object that you pass. If the response from the task execution
// above is not an array of features, then you need to add a callback
// like the one above to post-process the response and return an
// array of features.
map.infoWindow.setFeatures([ deferred ]);
map.infoWindow.show(evt.mapPoint);
}
//show map on load
dojo.addOnLoad(init);
</script>
</head>
<body class="soria">
<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false"
style="width: 100%; height: 100%; margin: 0;">
<div id="map" dojotype="dijit.layout.ContentPane" region="center">
<div style="position:absolute; top: 5px; text-align: left; right:5px; z-index:50" id="layerlist">
<strong>Kaartlagen:</strong><br>
<span id="layer_list" ></span>
<br>
<span style="font-size:x-small;">Ondergrond: © <a href="http://www.openstreetmap.org" title="OpenStreetMap" target="_blank">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/" title="Creative Commons Attribution-ShareAlike" target="_blank">CC-BY-SA</a></span></div>
</div>
</div>
</body>
</html>