Exemple #1
0
        /// <summary>
        /// Initialize map spatial reference and map scalebar units from server
        /// </summary>
        /// <param name="isInitializationInProgress">True if initialization is in progress,
        /// otherwise false..</param>
        private void _GetMapLayerProperties(bool isInitializationInProgress)
        {
            if (_layers.Count > 0)
            {
                // TODO: check spatial references from other layers and remove hardcode
                // Create client
                MapLayer mapLayer = _layers[0];
                _mapServer = ((AgsMapLayer)mapLayer).Server;

                if (_mapServer.State == AgsServerState.Authorized)
                {
                    MapServiceClient mapservice = new MapServiceClient(
                        mapLayer.Url,
                        _mapServer.OpenConnection());

                    // Get map service info
                    ESRI.ArcLogistics.MapService.MapServerInfo serverInfo =
                        mapservice.GetServerInfo(mapservice.GetDefaultMapName());

                    // Get spatial reference ID
                    _spatialReferenceId = serverInfo.SpatialReference.WKID;
                    _scaleBarUnits      = _ConvertScalebarUnits(serverInfo.Units);

                    // Now map is initialized.
                    _inited = true;
                }
                else
                {
                    // Subscribe on server state changed in case of Map is not inited
                    if (isInitializationInProgress)
                    {
                        _mapServer.StateChanged += new EventHandler(_Server_StateChanged);
                    }
                }
            }
        }
Exemple #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes routine (support reinit).
        /// </summary>
        /// <param name="mapLayer">Layer for creating images.</param>
        public void Init(MapLayer mapLayer)
        {
            Debug.Assert(null != mapLayer);
            Debug.Assert(!_serviceInWorkedState); // only once

            AgsServer server = ((AgsMapLayer)mapLayer).Server;

            ServiceHelper.ValidateServerState(server);

            _mapService = new MapServiceClient(mapLayer.Url, server.OpenConnection());

            _mapInfo        = _mapService.GetServerInfo(_mapService.GetDefaultMapName());
            _mapDescription = _mapInfo.DefaultMapDescription;

            var imgType = new ImageType();

            imgType.ImageFormat     = esriImageFormat.esriImagePNG;
            imgType.ImageReturnType = esriImageReturnType.esriImageReturnMimeData;

            _imgDescription           = new ImageDescription();
            _imgDescription.ImageType = imgType;

            _serviceInWorkedState = true;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes routine (support reinit).
        /// </summary>
        /// <param name="mapLayer">Layer for creating images.</param>
        public void Init(MapLayer mapLayer)
        {
            Debug.Assert(null != mapLayer);
            Debug.Assert(!_serviceInWorkedState); // only once

            AgsServer server = ((AgsMapLayer)mapLayer).Server;
            ServiceHelper.ValidateServerState(server);

            _mapService = new MapServiceClient(mapLayer.Url, server.OpenConnection());

            _mapInfo = _mapService.GetServerInfo(_mapService.GetDefaultMapName());
            _mapDescription = _mapInfo.DefaultMapDescription;

            var imgType = new ImageType();
            imgType.ImageFormat = esriImageFormat.esriImagePNG;
            imgType.ImageReturnType = esriImageReturnType.esriImageReturnMimeData;

            _imgDescription = new ImageDescription();
            _imgDescription.ImageType = imgType;

            _serviceInWorkedState = true;
        }
Exemple #4
0
 private void _SetSelectedBaseMap()
 {
     foreach (MapLayer layer in _layers)
     {
         if (layer.IsBaseMap && layer.IsVisible)
         {
             if (_baseMapLayer == null)
                 _baseMapLayer = layer;
             else
                 layer.IsVisible = false;
         }
     }
 }