private void Layers_LayersInitialized(object sender, EventArgs args)
{
if (this.panHelper != null)
{
hasChanged = true;
if (Point2D.IsNullOrEmpty(origin))
{
Rectangle2D bounds = this.Bounds;
if (Rectangle2D.IsNullOrEmpty(bounds))
{
return;//只有一个图层的时候,要求必需有bounds
}
if (!Rectangle2D.IsNullOrEmpty(ViewBounds))
{
bounds = ViewBounds;
}
cacheViewBounds = bounds;//赋给cacheVB
if ((currentSize.Width == 0.0) || (currentSize.Height == 0.0))
{
base.Dispatcher.BeginInvoke(delegate { this.Layers_LayersInitialized(sender, args); });
return;
}
}
//比如用TiledDynamicLayer 也没设置scalse,却只设置了MaxScale和MinScale,那么也设下最大最小吧
if (isMaxScaleSet && !isMinResolutionSet)
{
this.MinResolution = ScaleHelper.ScaleConversion(this.MaxScale, this.Dpi, this.CRS);
}
if (isMinScaleSet && !isMaxResolutionSet)
{
this.MaxResolution = ScaleHelper.ScaleConversion(this.MinScale, this.Dpi, this.CRS);
}
//放到scales的Set里? 在那里时,dpi基本为0,所以这里还得设置
if (this.Scales != null)//不是后设的时候,优先级高
{
fromLayers = false;//用了scales说明肯定不是从layer获取
if (this.Dpi != 0.0) //TieldWMS用SuperMap时无法知道dpi,所以即便设置了scales也没用
{
this.Resolutions = ScaleHelper.ConversionBetweenScalesAndResulotions(this.Scales, this.Dpi, this.CRS);
if (isMaxScaleSet)
{
this.MinResolution = ScaleHelper.ScaleConversion(this.MaxScale, this.Dpi, this.CRS); ;
}
if (isMinScaleSet)
{
this.MaxResolution = ScaleHelper.ScaleConversion(this.MinScale, this.Dpi, this.CRS); ;
}
}
}
if (this.Resolutions != null)
{
if (!this.isMinResolutionSet)
{
this.MinResolution = this.Resolutions[this.Resolutions.Length - 1];
}
if (!this.isMaxResolutionSet)
{
this.MaxResolution = this.Resolutions[0];
}
}
this.CalculateStartViewBounds(currentSize);
foreach (Layer layer in this.Layers)
{
this.AssignLayerContainer(layer);
}
if ((this.Resolutions != null) && (((this.Resolution < this.MinResolution) || (this.Resolution > this.MaxResolution))))
{
double res = MathUtil.GetNearest(this.mapResolution, this.Resolutions, MinResolution, MaxResolution);
if (res != this.mapResolution)
{
this.ZoomToResolution(res);
}
}
else
{
this.LoadLayersInView(false, this.GetFullViewBounds());
}
oldScales = this.Scales;
oldResolutions = this.Resolutions;
}
}
//旋转时,panning时,用到该函数,并不需要重新全部载入图片,有的tile可重用