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
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

MapPoint Automation with C/C++ - Part 1

This is a discussion on MapPoint Automation with C/C++ - Part 1 within the MP2K Magazine Articles forums, part of the Map Forums category; MapPoint Automation with C/C++ - Part 1 This is the first of three articles by Sergey Kostrov on automating MapPoint ...

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

    MapPoint Automation with C/C++ - Part 1

    MapPoint Automation with C/C++ - Part 1

    This is the first of three articles by Sergey Kostrov on automating MapPoint Automation with C/C++ starting with a simple C/C++ application.

    Read the full article here --
    http://www.mp2kmag.com/a122--c-c++.a....mappoint.html

    To post a comment or question click "Post Reply"

  2. #2
    Hans W is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    1

    Great thanks and when it part #2 going to be ready

    Thanks for the code sample. Why Microsoft does not do a C++ or MFC example baffles me. !

    It would be great to get a code sample that allows true integration in my porgram. i.e. a map display within my UI.

    Hans W

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

    It would be great to get a code sample that allows true inte

    Hans W wrote some time ago:

    "...It would be great to get a code sample that allows true integration in my porgram. i.e. a map display within my UI..."

    You can integrate MapPoint functionality in two different ways and it's not difficult:

    - with ActiveX MapPoint control ( it can be used with VB, pure C++, MFC etc );
    - or, if your application is using only MFC, and you want to use MapPoint automation, try to use CHtmlEditView class.

    Best regards,
    Sergey

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

    MapPoint Automation with C/C++ - Part 1

    Thanks for the article.
    It is on track for what I wanted to do.

    But the problem I am having is that I can't get the code sample to run correctly. All works fine until the program exits (after the ConUninitialize()). At this time I get a trap in _Release() accessing m_pInterface. m_pInterface has a non-NULL value but appears to be invalid.

    I believe it may be due to not having a myMapPtr->Release(), as well as other object releases.
    I have tied this, but I have not found the right combination (if indeed this is the problem).

    Any insights as to what is happening or how to diagnose this problem?

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

    My response is related with COM exception ( 0xC0000005 )...

    My response is related with COM exception ( 0xC0000005 ) at the end of execution MapPoint test application described in article ( Part 1 )...

    Unhandled exception 0xC0000005 "Access Violation" happens because:

    - all your COM objects were released after g_pMapPoint->Quit() was executed;

    - but, pointers to COM objects you worked with are still NOT NULL.

    You can fix it in a very simple way:

    ...
    myMapPtr->Saved = true;

    try
    {
    if( g_pMapPoint != NULL )
    {
    g_pMapPoint->Quit();
    }
    }
    catch( ... ){}

    resultsPtr = NULL;
    locAddressPtr = NULL;
    pinAddressPtr = NULL;
    myMapPtr = NULL;
    g_pMapPoint = NULL;

    CoUninitialize();
    }

    I tested it and everything is fine now.

    Best regards,
    Sergey

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

    Don't forget to add this statement: using namespace MapPoint

    Don't forget to add this statement: using namespace MapPoint...

    So, it should look like:

    #include "ComInterfaces.h"

    using namespace MapPoint; // <<--

    MapPoint::_ApplicationPtr g_pMapPoint = NULL;

    void main(void)
    {
    CoInitialize(NULL);
    ...
    }

    Best regards,
    Sergey

  7. #7
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    Where can i find help?

    I receive this error while compiling the demo:

    error C2664: 'FindAddressResults' : cannot convert parameter 6 from 'enum MapPoint::GeoCountry' to 'const class _variant_t &'
    Reason: cannot convert from 'enum MapPoint::GeoCountry' to 'const class _variant_t'
    No constructor could take the source type, or constructor overload resolution was ambiguous

    I have european version so i load MPEU82.tlb instead of MPNA82.tlb, but i think this is not important.

    Where can i find help about the methods i can call with mapPoint? I mean, how can i know how to use the FindAddressResults method or anyone else? Is there any documentation about using this API?

    Thanks a lot

  8. #8
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    I forgot to say...

    I want to make an application that gets a list of nearby places in text mode (given a long/lat position) and also gets an image map of that point. I know it must be very simple but i'm new on this and i don't know where to begin..

    Thanks again!

  9. #9
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    And...

    I solved the problem mentioned above
    'FindAddressResults' : cannot convert parameter 6 from 'enum MapPoint::GeoCountry' to 'const class _variant_t &'
    by removing the geoCountryDefault argument in the example code leaving the code like this:

    FindResultsPtr resultsPtr = myMapPtr->FindAddressResults
    (
    “400 Coronado Dr”, “Denton”, "", “TX”, “76209”
    );

    So now it compiles, but when i hit the "Build MapPointApp.exe" option in Microsoft Visual c++ 6, it gives me lots of errors
    Code:
    Linking...
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; long __thiscall MapPoint&#58;&#58;_Application&#58;&#58;Quit&#40;void&#41;" &#40;?Quit@_Application@MapPoint@@QAEJXZ&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Map&#58;&#58;PutSaved&#40;short&#41;" &#40;?PutSaved@_Map@MapPoint@@QAEXF@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; long __thiscall MapPoint&#58;&#58;Pushpin&#58;&#58;Delete&#40;void&#41;" &#40;?Delete@Pushpin@MapPoint@@QAEJXZ&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; long __thiscall MapPoint&#58;&#58;_Map&#58;&#58;SaveAs&#40;class _bstr_t,enum MapPoint&#58;&#58;GeoSaveFormat,short&#41;" &#40;?SaveAs@_Map@MapPoint@@QAEJV_bstr_t@@W4GeoSaveFormat@2@F@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; long __thiscall MapPoint&#58;&#58;_Map&#58;&#58;ZoomIn&#40;void&#41;" &#40;?ZoomIn@_Map@MapPoint@@QAEJXZ&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; long __thiscall MapPoint&#58;&#58;Location&#58;&#58;GoTo&#40;void&#41;" &#40;?GoTo@Location@MapPoint@@QAEJXZ&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;Pushpin&#58;&#58;PutHighlight&#40;short&#41;" &#40;?PutHighlight@Pushpin@MapPoint@@QAEXF@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;Pushpin&#58;&#58;PutBalloonState&#40;enum MapPoint&#58;&#58;GeoBalloonState&#41;" &#40;?PutBalloonState@Pushpin@MapPoint@@QAEXW4GeoBalloonState@2@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;Pushpin&#58;&#58;PutSymbol&#40;short&#41;" &#40;?PutSymbol@Pushpin@MapPoint@@QAEXF@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct MapPoint&#58;&#58;Pushpin,&struct __s_GUID _GUID_34b0f619_37e1_4c76_a6da_69bf75a5d3de> > __thiscall MapPoint&#58;&#58;_Map&#58;&#58;AddPushpin&#40;struct MapPoint&#58;&#58;Loca
    tion *,class _bstr_t&#41;" &#40;?AddPushpin@_Map@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@UPushpin@MapPoint@@$1?_GUID_34b0f619_37e1_4c76_a6da_69bf75a5d3de@@3U__s_GUID@@A@@@@PAULocation@2@V_bstr_t@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct IDispatch,&struct __s_GUID _GUID_00020400_0000_0000_c000_000000000046> > __thiscall MapPoint&#58;&#58;FindResults&#58;&#58;GetItem&#40;struct tagVARIANT *&#41;" &#40;?G
    etItem@FindResults@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@UIDispatch@@$1?_GUID_00020400_0000_0000_c000_000000000046@@3U__s_GUID@@A@@@@PAUtagVARIANT@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct MapPoint&#58;&#58;FindResults,&struct __s_GUID _GUID_188084cf_db96_482b_97a6_2571df9bef81> > __thiscall MapPoint&#58;&#58;_Map&#58;&#58;FindAddressResults&#40;class _bs
    tr_t,class _bstr_t,class _bstr_t,class _bstr_t,class _bstr_t,class _variant_t const &&#41;" &#40;?FindAddressResults@_Map@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@UFindResults@MapPoint@@$1?_GUID_188084cf_db96_482b_97a6_2571df9bef81@@3U__s_GUID@@A@@@@V_bstr
    _t@@0000ABV_variant_t@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct MapPoint&#58;&#58;_Map,&struct __s_GUID _GUID_90b167c0_923d_4b65_aee2_66938491c916> > __thiscall MapPoint&#58;&#58;_Application&#58;&#58;GetActiveMap&#40;void&#41;" &#40;?GetAc
    tiveMap@_Application@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@U_Map@MapPoint@@$1?_GUID_90b167c0_923d_4b65_aee2_66938491c916@@3U__s_GUID@@A@@@@XZ&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutUnits&#40;enum MapPoint&#58;&#58;GeoUnits&#41;" &#40;?PutUnits@_Application@MapPoint@@QAEXW4GeoUnits@2@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutCaption&#40;class _bstr_t&#41;" &#40;?PutCaption@_Application@MapPoint@@QAEXV_bstr_t@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutWindowState&#40;enum MapPoint&#58;&#58;GeoWindowState&#41;" &#40;?PutWindowState@_Application@MapPoint@@QAEXW4GeoWindowState@2@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutVisible&#40;short&#41;" &#40;?PutVisible@_Application@MapPoint@@QAEXF@Z&#41;
    Debug/MapPointApp.exe &#58; fatal error LNK1120&#58; 17 unresolved externals
    Error executing link.exe.
    
    MapPointApp.exe - 18 error&#40;s&#41;, 0 warning&#40;s&#41;
    Please, can anyone help me? I know if i get this code to work i could do my own but damn Murphy's Law, DAMN IT!!

  10. #10
    frankliu is offline Junior Member White Belt
    Join Date
    Sep 2005
    Posts
    1

    Compiling error in mpna82.tli

    Hi, Sergey,
    I tried to integrate your example to my CDialog derived class, but always get compiling error like this:
    ...\source\debug\mpna82.tli(16) : error C2653: '_Application' : is not a class or namespace name

    Any idea what's going on with my application?
    I alsoe tried to insert a MapPointControl OCX object into my class, but it crashed when I tried to call the OpenMap() method.
    Appreciate your help.
    Frank

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using Python to control MapPoint, Part 1
    By Eric Frost in forum MP2K Magazine Articles
    Replies: 2
    Last Post: 02-01-2010, 01:09 AM
  2. MapPoint Automation with C/C++ - Part 2
    By Eric Frost in forum MP2K Magazine Articles
    Replies: 1
    Last Post: 09-20-2005, 11:00 AM
  3. Automation -- Unable to kill mappoint.exe
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 02-03-2004, 11:12 PM
  4. Error in VBA automation of MapPoint when PO BOX is found
    By JPeters in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-09-2003, 10:40 AM
  5. I am using Mappoint with Visual C++ via automation....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 07-08-2002, 02:07 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