1

I'm at a total loss. 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>

1
  • try moving the map.addLayer inside the mapReady function as the first line Jan 22 '15 at 4:53
1

I think the first issue is the old references to Dojo. Rather than calling dijits using dojo.require() you should use:

require(["esri/map"], function(Map) { /* code goes here */ });

In the code above there is a combination of old (pre AMD) and current Dojo methods being used. Although the code will still work this is not best practice. You mentioned "landbasedlayer" was a cached layer? You are using "ArcGISDynamicMapServiceLayer" to call this when it should be "ArcGISTiledMapServiceLayer" (see code below).

require(["esri/layers/ArcGISTiledMapServiceLayer"], function(ArcGISTiledMapServiceLayer) {   /* code goes here */ }); 

See if this addresses your issue, if not we can work from there.

1
  • This solution should fix the problem, I copied and pasted the code into the sandbox and did the following in my answer. In all fairness, I recommend choosing @jeremythamm's answer. Mine just clarifies the steps needed but doesn't offer anything else that he did not suggest. Aug 31 '15 at 14:42
0
      // dojo.require("esri.map");
      // dojo.require("esri.dijit.Popup");

  require ([

    "esri/map",
    "esri/dijit/Popup"
    ], function (
    Map,
    Popup
  ) {

...

  dojo.ready(init);
  });

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.