AnsweredAssumed Answered

Not able to export Map service to KML/KMZ. Help!

Question asked by kirti_vasdev on Aug 8, 2016

Hi,

I have published a map service on ArcGIS Server 10.4 and created a web application(ASP.net) where i am exporting the data data, using the Map service.

I have exported the Map service to SHP file, FGDB, EXCEL. But i am not able to export it to KML/KMZ. its downloading as Empty.

 

The layer is secured. Can anyone Please help me with the code. Here is the code i have written :

 

  public Stream GetKML(string value, string token)

        {

            string exportoKMLUrl = "http://xxx/servername/rest/services/Folder/MapserviceName/MapServer/generateKml";

            var wc = new WebClient();

            string queryString = string.Format("?docName={0}&layers={1}&layerOptions={2}", value, "0", "separateImage");

            var respBytes = wc.DownloadData(string.Format("{0}?{1}", exportoKMLUrl, queryString));

            String headerInfo = "attachment; filename=" + value + "." + "kmz";

            WebOperationContext.Current.OutgoingResponse.Headers["Content-Disposition"] = headerInfo;

            WebOperationContext.Current.OutgoingResponse.ContentType = "application/octet-stream";

            return new MemoryStream(respBytes);

        }

 

Please help me with it.

 

Thanks!!

Outcomes