Click or drag to resize

MapCtrlGetMap Method (Boolean, MapProgress, Boolean)

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Gets an Image of the current map.

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public Image GetMap(
	bool isAsync,
	MapProgress progressDelegate,
	out bool done
)

Parameters

isAsync
Type: SystemBoolean
True to request a map asynchronously (only useful for Geostream).
progressDelegate
Type: Telogis.GeoBaseMapProgress
When requesting an async map this will update the progress if done isn't returned as true.
done
Type: SystemBoolean
When using GeoStream done will be true if a complete map is returned to an asynchronous request.

Return Value

Type: Image
A 32bpp Image.

Implements

IMapGetMap(Boolean, MapProgress, Boolean)
Remarks
Note that the returned Image is not a copy. It is recommended to create a new copy from this Image if you are going to make changes to the copy.
Examples
C#
private static ManualResetEvent m_mre = new ManualResetEvent(false);

private static int m_imageId = 0;

public static void TestAsyncGSMap() {
    // asynchronous maps are only used when fetching from GeoStream
    Repository.Default = new GeoStreamRepository(...);

    int imageId = m_imageId++;
    bool done;

    // call GetMap with isAsync set to true. MapProgress is our callback
    Image image = new Bitmap(mapCtrl.GetMap(true, MapProgress, out done));

    // we are saving the map image, even if it is incomplete
    image.Save(string.Format(@"C:\Users\User\Documents\AsyncMap\{0}.bmp", imageId));

    // done indicates whether the entire map was returned.
    // Block the current thread if we do not have a complete map.
    if (!done) {
        m_mre.WaitOne();
    }
}

// MapProgress is our callback -- it is called whenever more tiles are available
public static void MapProgress(IMap caller, bool isComplete) {

    int imageId = m_imageId++;
    bool done;

    // Inside our callback, call GetMap again to fetch the updated map image.
    // Pass in this callback so that we can be called recursively 
    // when more tiles are available.
    Image image = new Bitmap(caller.GetMap(true, MapProgress, out done));

    image.Save(string.Format(@"C:\Users\User\Documents\AsyncMap\{0}.bmp", imageId));

    // When we are finally called with all tiles, set the ManualResetEvent
    // so that our waiting thread can continue.
    if (done) {
        m_mre.Set();
    }     
}
See Also