Can't Include a Basemap Service in another Service--Not Supported

411
4
05-08-2013 08:48 AM
StephenBenzek
New Contributor
I'm trying to create a map service with points on a nice basemap (like ArcGIS Online's World Topo).  When I analyze the MXD, I get error "Layer Type Not Supported".

Any suggestions on how to put a basemap service inside another service?

Why do I need to do this?  I want to use the REST service "Export Map" operation to create a URL that calls a JPEG map for use in a web page.  I need my points and a background in this JPEG which has a URL of the form:
SERVERname/arcgis/rest/services/Test/MapServer/export?bbox=-10.834349864539245%2C12.61618408778323%2C-3.362842306232165%2C14.74580168800133&bboxSR=&layers=&layerdefs=&size=&imageSR=&format=jpg&transparent=false&dpi=&time=&layerTimeOptions=&f=image

My sucky workaround was to make a background from the ArcGIS DVD data and Maps and add it to the MXD/SD...but it's not nearly as good as the World Street map and Topo services.

Another thought was to put 9GB worth of cached ESRI data on my server (see http://resources.arcgis.com/en/help/data-maps-server/10.1/index.html#/Overview/00v90000000z000000/), but that might not help me either.

Thanks!
Tags (2)
0 Kudos
4 Replies
nicogis
MVP Frequent Contributor
In 10.1 you cannot put a basemap service inside another service.

You can get two images via rest and fuse them server side.

you can write code kind this one (I haven't tested):

static void Main(string[] args)
        {
            FuseTwoImages("http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/export?dpi=96&transparent=true&format=png8&bbox=633494.6405943877%2C5612180.331083226%2C1416209.810234554%2C6152742.995115967&bboxSR=102100&imageSR=102100&size=1280%2C884&f=image", 100.0f, "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer/export?dpi=96&transparent=true&format=png8&bbox=633494.6405943877%2C5612180.331083226%2C1416209.810234554%2C6152742.995115967&bboxSR=102100&imageSR=102100&size=1280%2C884&f=image", 50.0f);
        }
         public static void FuseTwoImages(string baseImageUrl, float baseImageOpacity, string topImageUrl, float topImageOpacity)
        {
            Graphics graphics = null;
            try
            {
                Bitmap imageBaseMap = new Bitmap(WebRequest.Create(baseImageUrl).GetResponse().GetResponseStream());
                SetImageOpacity(imageBaseMap, (float)topImageOpacity);
                Bitmap bitmapFirst = new Bitmap(new Bitmap(imageBaseMap));
                graphics = Graphics.FromImage(bitmapFirst);
                Bitmap bitmapSecond = new Bitmap(WebRequest.Create(topImageUrl).GetResponse().GetResponseStream());
                Image image = SetImageOpacity(bitmapSecond, (float)topImageOpacity);
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                graphics.DrawImage(image, new Point(0, 0));
                bitmapFirst.Save(@"c:\temp\_ags_" + Guid.NewGuid().ToString() + ".png", ImageFormat.Png);
            }
            catch (Exception)
            {
                
            }
            finally
            {
                graphics.Dispose();
            }
        }

        public static Image SetImageOpacity(Image image, float opacity)
        {
            try
            {
                //create a Bitmap the size of the image provided  
                Bitmap bmp = new Bitmap(image.Width, image.Height);
                //create a graphics object from the image  
                using (Graphics gfx = Graphics.FromImage(bmp))
                {
                    //create a color matrix object  
                    ColorMatrix matrix = new ColorMatrix();

                    //set the opacity  
                    matrix.Matrix33 = opacity;

                    //create image attributes  
                    ImageAttributes attributes = new ImageAttributes();

                    //set the color(opacity) of the image  
                    attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                    //now draw the image  
                    gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes);
                }
                return bmp;
            }
            catch
            {
                return null;
            }
        }

0 Kudos
StephenBenzek
New Contributor
Thanks Domenico, for the response!

I wonder why Esri took out the capability in 10.1?  We have our own ArcGIS Server that we paid for and should be able to put a basemap service  in a service, even if it is inefficient.  Esri--if your listening--please put that capability back in 10.1!

My Solution:  What I did for now was to create an asp:panel with the basemap service as a background and then overlaid the point service image (png and transparent=true) .
0 Kudos
nicogis
MVP Frequent Contributor
IMO now in ags there are more check for create efficient services so users avoid add service in services, also why you can overlay image via api, rest ect but user can also think that Esri avoid that user cache service Esri, Bing ect.
0 Kudos
JonathanQuinn
Esri Notable Contributor
Cascading services, (services within another service), is, as mentioned, unsupported at 10.1.  The primary reason is that services at 10.1 are MSD based, and there are rules that MSD based services need to follow.  Cascading services causes unforeseen issues that sometimes can't be resolved, as well as performance issues, along with the reason Domenico mentioned about caching Esri or Bing basemaps.
0 Kudos