1 Reply Latest reply on Mar 16, 2012 5:23 AM by NFurness-esristaff

    Is validation required before adding a Map Layer to MapView?

      The first layer you add to a map is considered to be the basemap layer.  It dictates the overall spatial reference of a map. Any tiled layers  you  subsequently add to a map must also be in this spatial reference,  otherwise their content will not be displayed. Dynamic layers, on the  other hand, can be in any spatial reference. They will automatically  re-project their content, if necessary, into the map's spatial  reference.

      I have been consuming GIS resources for a while, so far I could get things done without knowing too much of GIS tech data. Please be easy on me if its so obvious.

      Some mapservices dont have a spatial reference Example . As of now when user tries to add a map layer, I was validating if it has a spatial reference. Is that the proper way of validation?

      Please give a proper explanation.

        • Re: Is validation required before adding a Map Layer to MapView?
          Hi Anoop,

          In short, since everything used by the web and mobile SDKs is being projected onto a flat (2D) surface, it will need to have a spatial reference (essentially a set of rules describing that projection). Many web/mobile maps use spatial reference 102100 (Web Mercator Auxiliary Sphere). This is good for display. It's what consumers have come to expect (hence why many of our basemaps use that spatial reference). But it's probably not best way to store geodata in most parts of the world, so you may encounter various spatial references across the data you use.

          In the documentation you quote, the gist is this: The first layer you add to the map will define the map's spatial reference. Once the map's spatial reference is set, all data will display in that spatial reference.

          Because Tiled Layers are cached in a predefined spatial reference, they cannot be re-projected on the fly (re-projecting takes effort, so it would defeat the purpose of caching them!). That is why the spatial reference of tiled layers must match the spatial reference of the map.

          Because Dynamic Layers are not cached, they may be projected on-the-fly. So while they must have a spatial reference describing the stored data, they can be re-projected to the map's spatial reference on request. Again, this can take effort on the server or client, so it's a balancing act, but in practice in most cases you'll be OK.

          See also here and here to learn more about Tiled and Dynamic layers.

          As for your example, the service is a GlobeServer service. You cannot use this with the mobile or web SDKs. Instead, here is the 2D equivalent. Note the type is Feature Layer. Because it's for use in 2D, it has a spatial reference. [Note also, it's in extended support and you should really use this.]

          Hope this clears things up a little.