Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 9 of 9

C++ and passing Variant Arrays

This is a discussion on C++ and passing Variant Arrays within the MapPoint Desktop Discussion forums, part of the Map Forums category; Mappoint has a number of methods that require ArrayOfFields: These Include: ImportData LinkData ImportTerritories LinkTerritories SetFieldsVisibleInBalloon My problem is I ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    C++ and passing Variant Arrays

    Mappoint has a number of methods that require ArrayOfFields: These Include:

    ImportData
    LinkData
    ImportTerritories
    LinkTerritories
    SetFieldsVisibleInBalloon

    My problem is I don't seem to be able to create the Variant array properly
    Has anyone had any experience with this problem?

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Hi Garry,

    After our emails, I remembered a program I wrote that did work with fields. I've had a look at it, and it only queries the fields of existing pushpins. I don't use ArrayOfFields, but if you think it would help I could post it. (I use the getItem method on a Fields object)

    Could the polyline/polygon variant code be modified so that they pass "an array of Field" objects rather than "array of Location" objects?


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    C++ Variants

    Alas - that is precisely where I started - I've been trying to use the SafeArray code but I get nowhere.

  4. #4
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    C Builder and variants

    I have managed to get SetFieldsVisibleInBalloon working using C++.

    Deriving some code from Richard Marsden proved to be the solution.

    FieldsPtr pFields = pDataSet->Fields;
    long i;
    int count = pFields->Count;
    FieldPtr pField;
    Variant index = 0; // CBuilder variant
    HRESULT hr;

    VARIANT v;
    SAFEARRAY FAR* psa;
    SAFEARRAYBOUND saBound;

    saBound.cElements = count;
    saBound.lLbound = 0;
    psa = SafeArrayCreate( VT_DISPATCH, 1, &saBound );

    VariantInit( &v );
    V_VT( &v ) = VT_ARRAY + VT_DISPATCH;
    V_ARRAY( &v ) = psa;

    for ( i = 0; i < count; i++ )
    {
    index = i + 1;
    pField = pFields->get_Item( index );
    hr = SafeArrayPutElement( psa, &i, pField );
    }

    pDataSet->SetFieldsVisibleInBalloon( v );

  5. #5
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: C++ and passing Variant Arrays

    I realize this is from July '02, but I am trying to use this code and getting stuck with

    Code:
     
    Variant index = 0; // CBuilder variant
    I am using Visual C++. I really just want one Field passed to the DisplayDataMap method for the second parameter, I don't really need an array of fields.


  6. #6
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: C++ and passing Variant Arrays

    Here's my code below.

    See the second parameter, this is where I get hung up.

    It says it will default to the first valid field, so I put the column I want to map as the first field.

    How can I simply specify the default for the DataField parameter?

    Thanks,
    Eric


    Code:
     
    oDSPtr->DisplayDataMap(MapPoint::geoDataMapTypeMultipleSymbol, NULL, MapPoint::geoShowByDefault,
    MapPoint::geoCombineByNone, MapPoint::geoRangeTypeUniqueValues, 
    MapPoint::geoRangeOrderDefault, MapPoint::geoColorSchemeDefault, 5);
     
    // [ArrayOfCustomValues], [ArrayOfCustomNames], [DivideByField], [ArrayOfDataFieldLabels], [ArrayOfPushpinSymbols]);
    

  7. #7
    DrNobody is offline Junior Member White Belt
    Join Date
    Feb 2007
    Posts
    10

    Re: C++ and passing Variant Arrays

    Hi,
    perhaps it helps You:

    //from my program
    .....
    Code:
    void CMapPage::ShowParkPoints()
    {
    try
    {
    if(m_bShowPark)
    {
    m_dsParkPoints = m_DataSets.ImportData(m_strParkPointsPath, NULL, 
    geoCountryDefault, geoDelimiterDefault, NULL);
    m_dsParkPoints.SetSymbol(20);
    int nRecordCount = m_dsParkPoints.GetRecordCount ();
    if(nRecordCount == 0)
    {
    //AfxMessageBox (_T("There are no \"Park\" points"), MB_ICONINFORMATION);
    return;
    }
    COleSafeArray saFields;
    saFields.CreateOneDim (VT_DISPATCH, 4);
    long lIndex[1];
    CFields colFields = m_dsParkPoints.GetFields ();
    CField objField;
    for(int i = 0; i < 4; i ++)
    {
    lIndex[0] = i;
    objField = colFields.GetItem(COleVariant((long) (i + 2)));
    saFields.PutElement (lIndex, objField.m_lpDispatch);
    }
    m_dsParkPoints.SetFieldsVisibleInBalloon (saFields);
    m_DataSets.ZoomTo ();
    }
    else
    m_dsParkPoints.Delete();
    } //try
    catch (COleDispatchException * pExpn)
    {
    #ifdef _DEBUG
    pExpn->ReportError ();
    #endif
    pExpn->Delete ();
    }
    }
    ......

  8. #8
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: C++ and passing Variant Arrays

    Thank you Dr.!

  9. #9
    Pit Mueller is offline Junior Member White Belt
    Join Date
    Dec 2007
    Location
    Germany
    Posts
    9

    Re: C++ and passing Variant Arrays

    Hi Dr. Nobody!

    I'm still having the same problems. Have you suceeded in adding the fieldlist to ImportData?

    Pit

    Quote Originally Posted by DrNobody View Post
    Hi,
    perhaps it helps You:

    //from my program
    .....
    Code:
    void CMapPage::ShowParkPoints()
    {
    try
    {
    if(m_bShowPark)
    {
    m_dsParkPoints = m_DataSets.ImportData(m_strParkPointsPath, NULL, 
    geoCountryDefault, geoDelimiterDefault, NULL);
    m_dsParkPoints.SetSymbol(20);
    int nRecordCount = m_dsParkPoints.GetRecordCount ();
    if(nRecordCount == 0)
    {
    //AfxMessageBox (_T("There are no \"Park\" points"), MB_ICONINFORMATION);
    return;
    }
    COleSafeArray saFields;
    saFields.CreateOneDim (VT_DISPATCH, 4);
    long lIndex[1];
    CFields colFields = m_dsParkPoints.GetFields ();
    CField objField;
    for(int i = 0; i < 4; i ++)
    {
    lIndex[0] = i;
    objField = colFields.GetItem(COleVariant((long) (i + 2)));
    saFields.PutElement (lIndex, objField.m_lpDispatch);
    }
    m_dsParkPoints.SetFieldsVisibleInBalloon (saFields);
    m_DataSets.ZoomTo ();
    }
    else
    m_dsParkPoints.Delete();
    } //try
    catch (COleDispatchException * pExpn)
    {
    #ifdef _DEBUG
    pExpn->ReportError ();
    #endif
    pExpn->Delete ();
    }
    }
    ......

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Passing a VARIANT for LinkData() method using VC++
    By geouser in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-15-2006, 06:30 AM
  2. How can i find address by passing Lat/Lon as parameter?
    By joesebi in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-09-2003, 09:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94