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();
}
}