Select to view content in your preferred language

Map control content is disappearing

1038
2
08-14-2013 11:09 AM
Labels (1)
ClayGinn
Emerging Contributor
In order to speed up subsequent loading of the form that contains my map file, I load the form in memory and then hide it. When it is called again, it makes the form visible. When the user is done with the form then clicking the Close button hides it.

The problem I'm running into is that when it initially loads the form it displays the map just fine. However, after it has been hidden the map control goes away and the base map doesn't appear anymore. I can put graphics on it and I know the control is there because I can see the "powered by ESRI" bug at the bottom right.

If what I'm doing is a bad idea, is there a way to speed up the loading of the map? I need the form to display in less than one second, and the map loading sometimes takes two or three seconds.

Any ideas?
0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

Typically it is better to have the Map initialize the layers, but alternatively you could take a look at explicitly setting the spatial reference on the Map, then loading all the layers in code:

1. Create the Layer
2. Set any required Layer properties
3. Register handler for initialize completed
4. Call Initialize
5. Add the layer in the initialize completed handler

Note for some layers, such as FeatureLayers, when they're initialized they don't necessarily contain any data, since that's the result of a subsequent query often based on the map extent. For that layer type there's an UpdateCompleted event.

Cheers

Mike
0 Kudos
ClayGinn
Emerging Contributor
Loading the layers individually is not an option. Our customers use ArcMap to make all the formatting, layout, and annotations. Our primary users are not GIS professionals, so it needs to be simple to make changes. I don't think that's the problem anyway.

It looks like it's something related to when the graphic is drawn on the layer, but I can't figure out what it is. Here is what I'm using to draw a graphic on the map.

GraphicsLayer graphicsLayer = this._map.Layers["CallsLayer"] as GraphicsLayer;

                if (graphicsLayer != null)
                {
                    graphicsLayer.Graphics.Clear();

                    ESRI.ArcGIS.Client.Geometry.MapPoint point = new ESRI.ArcGIS.Client.Geometry.MapPoint(longitude, latitude);
                    point.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326);

                    ESRI.ArcGIS.Client.Symbols.PictureMarkerSymbol ms = new ESRI.ArcGIS.Client.Symbols.PictureMarkerSymbol();

                    Graphic g = new Graphic();
                    g.Geometry = this.ConvertToMapCoordinates(point);

                    ms.Source = imageSource;
                    g.Attributes.Add("Name", name);
                    g.Symbol = ms;
                    g.Attributes.Add("Object", itemObject);
                    graphicsLayer.Graphics.Add(g);
                }
0 Kudos