AnsweredAssumed Answered

imageryPrime' is undefined

Question asked by cliveswan on Mar 8, 2012
Latest reply on Mar 13, 2012 by cliveswan
Hi,

I am building the default solution, getting an error "imagePrime is not defined".
I referenced imagePrime in the code, any suggestions what is causing this error??

error occurs in anonymous code:

function anonymous() {
changeMap([imageryPrime]);  /// Error occurs here
}

function anonymous() {
dojo._ieDispatcher(arguments, this)
}

function anonymous(item, index, array) {
item.unselectable = 'on'
}

function anonymous() {
changeMap ([streetMap]);
}



///
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>JavaScript Application</title>
    <link rel="Stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.4/js/dojo/dijit/themes/tundra/tundra.css" />
    <script type="text/javascript"> djConfig = { parseOnLoad: true }</script>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.4"> </script>

    <script type="text/javascript">
        dojo.require("esri.map");
        dojo.require("dijit.form.Button");

        Var map;
        var streetMap; imageryPrime, shadedRelief, ngsTopoUS, boundariesWorld;

        function init(){
        map = new esri.Map("map");

       imageryPrime = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer", {id:"imageryPrime"});
        map.addLayer(imageryPrime);
  /// imageryPrime is defined here
        }

        function initLayer(url, id){
        var layer = new esri.layers.ArcGISTiledMapServiceLayer (url, {id:id, visible:false});
        map.addLayer(layer);
        return layer;
        }

        function changeMap(layers){
        hideImageTiledLayers(layers);
        for (var i=0; i<layers.length; i++
            {
             layers[i].show();
            }
        }
       
        function hideImageTiledLayers(layers){
            for (var j=0, jl=map.layersIds.length; j<jl; j++)
                {
                 var layer = map.getLayer(map.layersIds[j] );
                 if (dojo.indexOf(layers, layer) == -1)
                    {
                     layer.hide();
                    }

                }
       
        }
   
    dojo.addOnLoad(init);
    </script>
</head>
<body class="tundra">
<div style="position:relative;">
<div id="map" style="width:1100px; height:600px; border:1px solid #000;> </div>
   <div style="position:absolute; right:175px; top:10px; z-Index:999;">
    <button dojoType="dijit.form.Button" onClick="changeMap([imageryPrime]);">Imagery</button>
    <button dojoType="dijit.form.Button" onClick="changeMap ([streetMap]);">Street Map</button>
    </div>
</div>

Map navigation using mouse:
<ul>
<li>Drag to pan</li>
<li>SHIFT + Click to recenter</li>
<li>Mouse Scroll Forward to zoom in</li>
<li>Mouse Scroll Backward to zoom out</li>
<li>Use Arrow key to pan</li>
<li>+key to zoom in</li>
<li>-key to zoom out</li>
<li>Double click to center and Zoom in</li>
</ul>

   
</body>
</html>

Outcomes