private void mapService_Fault(object sender, SmMapService.MapServiceFaultEventArgs args) { if (((args.Error is SecurityException) && !Application.Current.Host.Source.Scheme.Equals(Uri.UriSchemeHttp)) && !Application.Current.Host.Source.Scheme.Equals(Uri.UriSchemeHttps)) { base.Error = new SecurityException(SuperMap.Web.Resources.ExceptionStrings.InvalidURISchemeHost, args.Error); } else { base.Error = args.Error; } base.Initialize(); }
private void mapService_Initialized(object sender, SmMapService.MapServiceInitalizeArgs e) { if (e.MapService.MapServiceUrl == this.Url.Trim()) { if (base.Error != null) { base.Initialize(); } else { if (CRS == null) { CRS = new CoordinateReferenceSystem { }; if (this.mapService.MapServiceInfo != null) { CRS.Unit = this.mapService.MapServiceInfo.CoordUnit; if (this.mapService.MapServiceInfo.PrjCoordSys != null) { CRS.WKID = this.mapService.MapServiceInfo.PrjCoordSys.EpsgCode; if (this.mapService.MapServiceInfo.PrjCoordSys.CoordSystem != null && this.mapService.MapServiceInfo.PrjCoordSys.CoordSystem.Datum != null && this.mapService.MapServiceInfo.PrjCoordSys.CoordSystem.Datum.Spheroid != null) { CRS.DatumAxis = this.mapService.MapServiceInfo.PrjCoordSys.CoordSystem.Datum.Spheroid.Axis; } } } } Bounds = this.mapService.MapServiceInfo.Bounds; Dpi = ScaleHelper.GetSmDpi(this.mapService.MapServiceInfo.ViewBounds, this.mapService.MapServiceInfo.Viewer, this.mapService.MapServiceInfo.Scale, CRS.Unit, CRS.DatumAxis); Dpi *= AdjustFactor; this.ReferScale = this.mapService.MapServiceInfo.Scale; this.ReferViewBounds = this.mapService.MapServiceInfo.ViewBounds; this.ReferViewer = this.mapService.MapServiceInfo.Viewer; base.Initialize(); } } }
/// <summary>${Mapping_TiledDynamicRESTLayer_method_Initialize_D}</summary> public override void Initialize() { _randomKey = DateTime.Now.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture); if (!this.isInitializing && !base.IsInitialized) { if (string.IsNullOrEmpty(this.Url)) { Error = new ArgumentNullException(SuperMap.Web.iServerJava6R.Resources.ExceptionStrings.InvalidUrl); Initialize(); return; } if (IsSkipGetSMMapServiceInfo) { if (Bounds.IsEmpty) { Error = new ArgumentNullException("Bounds"); } if (this.CRS != null) { Dpi = ScaleHelper.GetSmDpi(ReferViewBounds, ReferViewer, ReferScale, this.CRS.Unit, this.CRS.DatumAxis); } Dpi *= AdjustFactor; this.isInitializing = true; base.Initialize(); return; } if (!Url.Contains("http://")) //相对地址 { var pageUrl = System.Windows.Browser.HtmlPage.Document.DocumentUri; var localUrl = pageUrl.AbsoluteUri.Substring(0, pageUrl.AbsoluteUri.IndexOf(pageUrl.AbsolutePath)); Url = localUrl + Url; } this.isInitializing = true; this._mapServiceDefault = new SmMapService(this.Url.Trim()); this._mapServiceDefault.Initialized += (o, e) => { this.mapService = new SmMapService(this.Url.Trim()); this.mapService.Initialized += new EventHandler<SmMapService.MapServiceInitalizeArgs>(mapService_Initialized); this.mapService.Failed += new SmMapService.MapServiceFaultEventHandler(mapService_Fault); if (this.CRS != null && this.CRS.WKID > 0) { this.mapService.Initialize(this.CRS.WKID); } else { this.mapService.Initialize(); } }; this._mapServiceDefault.Initialize(); } }