CreateMap()

There are several variations of the CreateMap Method (Two of these are on the deprecated IMap_Server interface. These should no longer be used by new programs. Instead the wiki:IMap interface should be used. Similar functionality with different control over the size and area of the map can obtained with the following variants:

   CreateFixedSizeMapFromGeoBounds(
      double southern_lat, double western_lon,
      double northern_lat, double eastern_lon,
      long category, long map_handle,
      double brightness, short draw_overlays,
      short draw_map_if_no_data,
      long pixmap_width, long pixmap_height,
      short''' no_data, VARIANT''' dib,
      VARIANT* corners);
       

   * CreateMap(
      double center_lat, double center_lon, 
      long category,
      long map_handle, double rotation_angle, long zoom_percent,
      long projection_type, double brightness, short draw_overlays,
      long pixmap_width, long pixmap_height,
      short draw_map_if_no_data, short* no_data,
      VARIANT''' dib, VARIANT''' corners);

   *CreateMapFromGeoBounds(double southern_lat, double western_lon,
      double northern_lat, double eastern_lon,
      long category, long map_handle,
      double brightness, short draw_overlays,
      short draw_map_if_no_data, short* no_data,
      long''' pixmap_width, long''' pixmap_height,
      VARIANT''' dib, VARIANT''' corners)

A common mistake of many users is to use the old IMap_Server enumeration for the value of the map handle. The IMap version of the function requires that users use QueryMapTypes() to find the desired scale. This allows new scales and types of maps to be added through plug-in Map Handlers.

The following C# code queries for all the Raster Map types (CADRG, CIB, GeoTIFF, MrSID) and display the names and scales of each map handle.

    object MapList = null; 
    object MapDegPerPixelList = null;
    mMap = new fvw.MapClass();
    int numOfMaps = 0; 
      
    const int CLIENT_RASTER_CATEGORY = 2;
      
    falconServer.QueryMapTypes(CLIENT_RASTER_CATEGORY, ref MapList, ref MapDegPerPixelList, ref numOfMaps, 1); 
      
    // now unpack the array
    Array MapHandles = (Array)MapList; 
    Array DegPix = (Array)MapDegPerPixelList;
    for (int i=0; i<MapHandles.Length; i++)
    {
   System.Console.WriteLine(MapHandles.GetValue(i).ToString()+ " "+ DegPix.GetValue(i).ToString());

Another simple way to obtain a valid map handle is to query FalconView for the current map scale using IMap::GetMapDisplay() then use that value in the call to CreateMap.

Once you successfully retrieve the map you need to unpack the DIB form the varient.

This code shows how to work with the DIB in Visual Basic fvw_ctrl.zip Download

-- ChrisBailey - 16 Sep 2005

Q) I am attempting to write a plugin to FalconView that will overlay an image on top of the map over specific coordinates. I was going to use CalcPixmapSizeFromGeoBounds and CreateMapFromGeoBounds (to project images with transparencies) to get the correct scaling for images, but the function always returns -1 (FAILURE). Have these functions become depreciated in version 4.0, or am I perhaps missing some precondition for calling these functions that is not listed here or in the SDK documentation? Any help would be appreciated.

The error log text is: 06/28/06 15:21:09 ERROR: d:\SourceTrees\Fvw 4.0.0\fvw_core\fvw_exe\IMap.cpp line 618. variant not cleared

-- WilliamMorrell - 27 Jun 2006

A) This means that the corner parameter you are passing in is either i) NULL or ii) the type of the variant is not VT_EMPTY which means you are passing in a VARIANT that is already initialized. FalconView will create the variant for you.


Q) We are trying to call the CreateMap function to retrieve a bitmap. It always returns -1 and the no_data flag is always 1 for all map handles. All other parameters are passed in with default value. We are using FalconView 3.3. What causes it to always fail?

-- EmilyHoang - 15 Sep 2005

A) It is only a guess, but I suspect you are not passing the right ID For the MapType.

Back to IMap

Attachments