My initial problem was an issue with the layer not loading at all when the page was set to the full extent, despite having changed the Min/Max Scale settings generously when publishing the map service. I corrected this by rectifying the Scale settings in JavaScript:landBaseLayer.on("load", function() { landBaseLayer.minScale = 0; landBaseLayer.maxScale = 0; });
I now have a problem with the layer not loading when entering the page. It loads when I zoom in, and the loaded subset will remain visible when I zoom back out, but everything around it will remain blank. What am I doing wrong? Sorry, I'm totally new to this. I'm using a cached map service, with a Max Record Count of 10,000 (the layer contains just over 7,000 points). The following is the entire code.<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Identify with Popup</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css">
<style>
html, body, #map {
height:100%;
width:100%;
margin:0;
padding:0;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://js.arcgis.com/3.8/"></script>
<script>
dojo.require("esri.map");
dojo.require("esri.dijit.Popup");
var map;
var identifyTask, identifyParams;
function init() {
//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([255,0,0]), 2), new dojo.Color([255,255,0,0.25]))
}, dojo.create("div"));
map = new esri.Map("map", {
basemap: "satellite",
center: [-89.211, 39.977],
zoom: 7,
infoWindow: popup
});
dojo.connect(map, "onLoad", mapReady);
var landBaseLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/WeekSample/MapServer",{opacity:.55});
landBaseLayer.on("load", function() { landBaseLayer.minScale = 0; landBaseLayer.maxScale = 0; });
map.addLayer(landBaseLayer);
}
function mapReady(map){
dojo.connect(map,"onClick",executeIdentifyTask);
//create identify tasks and setup parameters
identifyTask = new esri.tasks.IdentifyTask("http://localhost:6080/arcgis/rest/services/WeekSample/MapServer");
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
identifyParams.layerIds = [0];
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.width = map.width;
identifyParams.height = map.height;
}
function executeIdentifyTask(evt) {
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function(response) {
return dojo.map(response, function(result) {
var feature = result.feature;
feature.attributes.layerName = result.layerName;
if(result.layerName === 'Bloomingdale_Parcel'){
//console.log(feature.attributes.PARCELID);
console.log(feature.attributes.UNIQUEID);
var template = new esri.InfoTemplate("", "<b>Unique ID:</b> <br/> ${UNIQUEID} <br/><br/> <b>Address:</b> <br/> ${PROP_LOC} <br/><br/> <b>Owner of record:</b> <br/> ${OWNER_NAME} <br/><br/> <b>Block ID:</b> <br/> ${BLOCK} <br/><br/> <b>Lot ID:</b> <br/> ${LOT}");
feature.setInfoTemplate(template);
}
//else if (result.layerName === 'Building Footprints'){
//var template = new esri.InfoTemplate("", "Parcel ID: ${PARCELID}");
//feature.setInfoTemplate(template);
//}
return feature;
});
});
map.infoWindow.setFeatures([ deferred ]);
map.infoWindow.show(evt.mapPoint);
}
dojo.ready(init);
</script>