public override void GetUrl(Client.Geometry.Envelope extent, int width, int height, DynamicMapServiceLayer.OnUrlComplete onComplete) { if (ArcGISDynamicMapServiceLayer != null) { if (!_initialized) { ArcGISDynamicMapServiceLayer.Initialize(); _initialized = true; } ArcGISDynamicMapServiceLayer.GetUrl(extent, width, height, onComplete); } }
/// <summary> /// Gets the URL. /// </summary> /// <param name="extent">The extent.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="onComplete">The on complete.</param> public override void GetUrl(ESRI.ArcGIS.Client.Geometry.Envelope extent, int width, int height, DynamicMapServiceLayer.OnUrlComplete onComplete) { string sAXL = AxlHelper.GetRequestAxl(extent.XMin, extent.YMin, extent.XMax, extent.YMax, _backgroundColor, _backgroundTranscolor, _imageFormat, width, height); //ARCIMS CAN RETURN ERROR WHEN HEIGHT AND WIDTH DON'T MATCH THE LIMITED SETTINGS - HAVE SEEN WHERE THIS DOESN'T OCCUR WITH FLEX AND DOES IN SILVERLIGHT - OUR MAP SEEMS TO //BE LARGER - ACCORDING TO DOCUMENTATION, THIS CAN ONLY BE FIXED ON THE ARCIMS SERVER BY CHANGING THE SETTINGS _width = width; _height = height; // Builds the url string sUrl = AxlHelper.BuildURL(ServiceHost, ServiceName, ProxyUrl); MakeRequest(sUrl, sAXL, onComplete); }
/// <summary> /// Gets the URL. Override from DynamicMapServiceLayer /// </summary> /// <param name="properties">The image export properties.</param> /// <param name="onComplete">OnUrlComplete delegate.</param> /// <remarks> /// The Map has a private method loadLayerInView which calls Layer.Draw. /// The DynamicMapServiceLayer abstract class overrides the Draw method and calls /// DynamicMapServiceLayer.GetUrl which must be implemented in a subclass. /// The last parameter is the OnUrlComplete delegate, which is used to pass the appropriate values /// (url, width, height, envelope) to the private DynamicMapServiceLayer.getUrlComplete method. /// </remarks> public override void GetUrl(DynamicLayer.ImageParameters properties, DynamicMapServiceLayer.OnUrlComplete onComplete) { Envelope extent = properties.Extent; int width = properties.Width; int height = properties.Height; int extentWKID = (extent.SpatialReference != null) ? extent.SpatialReference.WKID : 0; string baseUrl = MapUrl ?? Url; if (baseUrl == null) { onComplete(null, null); return; } StringBuilder mapURL = new StringBuilder(baseUrl); if (!baseUrl.Contains("?")) mapURL.Append("?"); else if (!baseUrl.EndsWith("&")) mapURL.Append("&"); mapURL.Append("SERVICE=WMS&REQUEST=GetMap"); mapURL.AppendFormat("&WIDTH={0}", width); mapURL.AppendFormat("&HEIGHT={0}", height); mapURL.AppendFormat("&FORMAT={0}", ImageFormat); mapURL.AppendFormat("&LAYERS={0}", Layers == null ? "" : String.Join(",", Layers)); mapURL.Append("&STYLES="); mapURL.AppendFormat("&BGCOLOR={0}", "0xFFFFFF"); mapURL.AppendFormat("&TRANSPARENT={0}", "TRUE"); mapURL.AppendFormat("&VERSION={0}", GetValidVersionNumber()); //If one of the WebMercator codes, change to a WKID supported by the service if (SupportedSpatialReferenceIDs != null && (extentWKID == 102100 || extentWKID == 102113 || extentWKID == 3857 || extentWKID == 900913)) { if (!SupportedSpatialReferenceIDs.Contains(extentWKID)) { if (SupportedSpatialReferenceIDs.Contains(3857)) extentWKID = 3857; else if (SupportedSpatialReferenceIDs.Contains(102100)) extentWKID = 102100; else if (SupportedSpatialReferenceIDs.Contains(102113)) extentWKID = 102113; else if (SupportedSpatialReferenceIDs.Contains(900913)) extentWKID = 900913; } } bool useCrsFormat = _useCrsFormat != null && _useCrsFormat.Contains(extentWKID); // Need to use CRS:xx format ==> x,y order if (LowerThan13Version()) { mapURL.AppendFormat("&SRS={0}", useCrsFormat ? CrsFromSR(extentWKID) : string.Format("EPSG:{0}", extentWKID)); mapURL.AppendFormat(CultureInfo.InvariantCulture, "&bbox={0},{1},{2},{3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax); } else { mapURL.AppendFormat("&CRS={0}", useCrsFormat ? CrsFromSR(extentWKID) : string.Format("EPSG:{0}", extentWKID)); if (!useCrsFormat && !LowerThan13Version() && UseLatLon(extentWKID)) mapURL.AppendFormat(CultureInfo.InvariantCulture, "&BBOX={0},{1},{2},{3}", extent.YMin, extent.XMin, extent.YMax, extent.XMax); else mapURL.AppendFormat(CultureInfo.InvariantCulture, "&BBOX={0},{1},{2},{3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax); } onComplete(Utilities.PrefixProxy(ProxyUrl, mapURL.ToString()).AbsoluteUri, new ImageResult(new ESRI.ArcGIS.Client.Geometry.Envelope() { XMin = extent.XMin, YMin = extent.YMin, XMax = extent.XMax, YMax = extent.YMax })); }
/// <summary> /// Gets the URL. Override from DynamicMapServiceLayer /// </summary> /// <param name="extent">The extent.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="onComplete">OnUrlComplete delegate.</param> /// <remarks> /// The Map has a private method loadLayerInView which calls Layer.Draw. /// The DynamicMapServiceLayer abstract class overrides the Draw method and calls /// DynamicMapServiceLayer.GetUrl which must be implemented in a subclass. /// The last parameter is the OnUrlComplete delegate, which is used to pass the appropriate values /// (url, width, height, envelope) to the private DynamicMapServiceLayer.getUrlComplete method. /// </remarks> public override void GetUrl(ESRI.ArcGIS.Client.Geometry.Envelope extent, int width, int height, DynamicMapServiceLayer.OnUrlComplete onComplete) { int extentWKID = (extent.SpatialReference != null) ? extent.SpatialReference.WKID : 0; string baseUrl = httpGetResource ?? Url; StringBuilder mapURL = new StringBuilder(baseUrl); if (!baseUrl.Contains("?")) mapURL.Append("?"); else if (!baseUrl.EndsWith("&")) mapURL.Append("&"); mapURL.Append("SERVICE=WMS&REQUEST=GetMap"); mapURL.AppendFormat("&WIDTH={0}", width); mapURL.AppendFormat("&HEIGHT={0}", height); mapURL.AppendFormat("&FORMAT={0}", ImageFormat); mapURL.AppendFormat("&LAYERS={0}", Layers == null ? "" : String.Join(",", Layers)); mapURL.Append("&STYLES="); mapURL.AppendFormat("&BGCOLOR={0}", "0xFFFFFF"); mapURL.AppendFormat("&TRANSPARENT={0}", "TRUE"); mapURL.AppendFormat("&VERSION={0}", GetValidVersionNumber()); mapURL.Append("&" + UrlToken); //If one of the WebMercator codes, change to a WKID supported by the service if (SupportedSpatialReferenceIDs != null && (extentWKID == 102100 || extentWKID == 102113 || extentWKID == 3857 || extentWKID == 900913)) { if (!SupportedSpatialReferenceIDs.Contains(extentWKID)) { if (SupportedSpatialReferenceIDs.Contains(3857)) extentWKID = 3857; else if (SupportedSpatialReferenceIDs.Contains(102100)) extentWKID = 102100; else if (SupportedSpatialReferenceIDs.Contains(102113)) extentWKID = 102113; else if (SupportedSpatialReferenceIDs.Contains(900913)) extentWKID = 900913; } } if (LowerThan13Version()) { mapURL.AppendFormat("&SRS=EPSG:{0}", extentWKID); mapURL.AppendFormat(CultureInfo.InvariantCulture, "&bbox={0},{1},{2},{3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax); } else { mapURL.AppendFormat("&CRS=EPSG:{0}", extentWKID); if (UseLatLon(extentWKID)) mapURL.AppendFormat(CultureInfo.InvariantCulture, "&BBOX={0},{1},{2},{3}", extent.YMin, extent.XMin, extent.YMax, extent.XMax); else mapURL.AppendFormat(CultureInfo.InvariantCulture, "&BBOX={0},{1},{2},{3}", extent.XMin, extent.YMin, extent.XMax, extent.YMax); } onComplete(Utilities.PrefixProxy(ProxyUrl, mapURL.ToString()).AbsoluteUri, width, height, new ESRI.ArcGIS.Client.Geometry.Envelope() { XMin = extent.XMin, YMin = extent.YMin, XMax = extent.XMax, YMax = extent.YMax }); }