base map loading problem?

665
1
06-01-2012 12:53 PM
akpagaakpaga
New Contributor
Hi friends,


I am using the below code to load a base map of esri and to it  i am trying to add an dynamic map service layer but my base map does not load completely and leaves blank tiles in between when I try to add my dynamic map service.
What could be the reasons..Is it related to projections or something else?Please check my code below and give me suggestions...Thank you in advance

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--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>Set Map Extent Using Second Service</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.8/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.8"></script>
    <script type="text/javascript">
     dojo.require("esri.map");
     var myMap, myService1, myService2;

     function initLayers() {
      esri.config.defaults.io.proxyUrl = "proxy.ashx";
      esri.config.defaults.io.alwaysUseProxy = true;


      var primaryMapServiceURL = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
      myService1 = new esri.layers.ArcGISTiledMapServiceLayer(primaryMapServiceURL);

      var secondaryMapServiceURL = "http://test.com/ArcGIS/rest/services/Houston/ParcelsTest/MapServer";
      myService2 = new esri.layers.ArcGISDynamicMapServiceLayer(secondaryMapServiceURL, { opacity: 0.75 });

      var layerLoadCount = 0;
      //When both layers have loaded, run createMapAddLayers

      if (myService1.loaded) {
       layerLoadCount += 1;
       if (layerLoadCount === 2) {
        createMapAddLayers(myService1, myService2);
       }
      } else {
       dojo.connect(myService1, "onLoad", function (service) {
        layerLoadCount += 1;
        if (layerLoadCount === 2) {
         createMapAddLayers(myService1, myService2);
        }
       });
      }

      if (myService2.loaded) {
       layerLoadCount += 1;
       if (layerLoadCount === 2) {
        createMapAddLayers(myService1, myService2);
       }
      } else {
       dojo.connect(myService2, "onLoad", function (service) {
        layerLoadCount += 1;
        if (layerLoadCount === 2) {
         createMapAddLayers(myService1, myService2);
        }
       });
      }
     }

     //Create a map, set the extent, and add the services to the map.
     function createMapAddLayers(myService1, myService2) {
      //create map
      //convert the extent to Web Mercator
      myMap = new esri.Map("mapDiv", { extent:(myService2.fullExtent) });
      myMap.addLayer(myService1);
      myMap.addLayer(myService2);
     }

     dojo.addOnLoad(initLayers);
    </script>
  </head>
  <body class="claro">
    <div id="mapDiv" style="width:600px; height:400px; border:1px solid #000;"></div>
    <br/>
    This map shows two services:
    <ul>
    <li>An ArcGIS Online tiled service that has a world extent.</li>
    <li>A second dynamic service with an extent of the State of Kansas.  This is the extent used when the maps are first displayed. </li>
    </ul>

    Note that if you want to combine to tiled services in the same map, they must have the same tile configuration.
  </body>
</html>
0 Kudos
1 Reply
akpagaakpaga
New Contributor
Hi friends,

When I changes this code
esri.config.defaults.io.alwaysUseProxy = true;   to

esri.config.defaults.io.alwaysUseProxy = false;

I am not having any problems in loading the base map but i need the setting to be true in order for the user to avoid entering username password ...Someone please give me some insight?

Thank you
0 Kudos