8

It's possible to add a layer as a basemap in ArcGIS.com by checking the check box use as baselayer:

Use as base Layer

But when I consume the map using:

var mapDeferred = esri.arcgis.utils.createMap("<guid>", "map", {
                mapOptions: {
                    slider: true,
                    nav: false
                }
            });

the basemap don't show up, is there any rules that define what content can be used as a basemap?

1
  • one quick question, after u added the required Web Service as basemap, were you able to customize it and enable popups on it? In the same manner as we can do when we add a simple shapefile and then enable popups on it. I tried but it seems that if you want to add a shapefile as a basemap, the enable popup feature is no more available. This is the question that I posted, gis.stackexchange.com/questions/31825/…
    – Sam007
    Aug 20, 2012 at 21:58

1 Answer 1

7

Yes, this is definitely possible, here's an example:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title></title>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/tundra/tundra.css">
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/esri/dijit/css/Popup.css">
    <style>
      html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
      #map{ margin: 0; padding: 0; }
    </style>
    <script>var dojoConfig = { parseOnLoad: true };</script>
    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
    <script>
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("esri.map");
      dojo.require("esri.arcgis.utils");

      var map;
      esri.config.defaults.geometryService = new esri.tasks.GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');
      function init() {
        var agol_map = new esri.arcgis.utils.createMap("c11215b898ec46369f855c82b28fc65e", "map", {
          mapOptions: {
            slider: true,
            nav:false
          }
        });
        agol_map.addCallback(function(response) {
          // Keep a reference to the map
          map = response.map;

          dojo.connect(dijit.byId('map'), 'resize', function() { 
            dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
          });
        });
      }
      dojo.ready(init);
    </script>
  </head>

  <body class="tundra">
    <div data-dojo-type="dijit.layout.BorderContainer" 
         data-dojo-props="design:'headline',gutters:false" 
         style="width: 100%; height: 100%; margin: 0;">
      <div id="map" 
           data-dojo-type="dijit.layout.ContentPane" 
           data-dojo-props="region:'center'"> 
      </div>
    </div>
  </body>
</html>

Update: The key is to add a default geometry service:

esri.config.defaults.geometryService = new esri.tasks.GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');

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.