MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




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 ...


Go Back   MapPoint Forums > Map Forums > MP2K Magazine Articles

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2005
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,480
Blog Entries: 1
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"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2005
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 04-23-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 04-27-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 05-12-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 05-12-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 08-31-2005
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 08-31-2005
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 08-31-2005
Junior Member
White Belt
 
Join Date: Aug 2005
Posts: 8
And...

I solved the problem mentioned above
Quote:
'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 : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::_Application::Quit(void)" (?Quit@_Application@MapPoint@@QAEJXZ)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::_Map::PutSaved(short)" (?PutSaved@_Map@MapPoint@@QAEXF@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::Pushpin::Delete(void)" (?Delete@Pushpin@MapPoint@@QAEJXZ)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::_Map::SaveAs(class _bstr_t,enum MapPoint::GeoSaveFormat,short)" (?SaveAs@_Map@MapPoint@@QAEJV_bstr_t@@W4GeoSaveFormat@2@F@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::_Map::ZoomIn(void)" (?ZoomIn@_Map@MapPoint@@QAEJXZ)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::Location::GoTo(void)" (?GoTo@Location@MapPoint@@QAEJXZ)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::Pushpin::PutHighlight(short)" (?PutHighlight@Pushpin@MapPoint@@QAEXF@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::Pushpin::PutBalloonState(enum MapPoint::GeoBalloonState)" (?PutBalloonState@Pushpin@MapPoint@@QAEXW4GeoBalloonState@2@@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::Pushpin::PutSymbol(short)" (?PutSymbol@Pushpin@MapPoint@@QAEXF@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: class _com_ptr_t<class _com_IIID<struct MapPoint::Pushpin,&struct __s_GUID _GUID_34b0f619_37e1_4c76_a6da_69bf75a5d3de> > __thiscall MapPoint::_Map::AddPushpin(struct MapPoint::Loca
tion *,class _bstr_t)" (?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)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: class _com_ptr_t<class _com_IIID<struct IDispatch,&struct __s_GUID _GUID_00020400_0000_0000_c000_000000000046> > __thiscall MapPoint::FindResults::GetItem(struct tagVARIANT *)" (?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)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: class _com_ptr_t<class _com_IIID<struct MapPoint::FindResults,&struct __s_GUID _GUID_188084cf_db96_482b_97a6_2571df9bef81> > __thiscall MapPoint::_Map::FindAddressResults(class _bs
tr_t,class _bstr_t,class _bstr_t,class _bstr_t,class _bstr_t,class _variant_t const &)" (?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)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: class _com_ptr_t<class _com_IIID<struct MapPoint::_Map,&struct __s_GUID _GUID_90b167c0_923d_4b65_aee2_66938491c916> > __thiscall MapPoint::_Application::GetActiveMap(void)" (?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)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::_Application::PutUnits(enum MapPoint::GeoUnits)" (?PutUnits@_Application@MapPoint@@QAEXW4GeoUnits@2@@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::_Application::PutCaption(class _bstr_t)" (?PutCaption@_Application@MapPoint@@QAEXV_bstr_t@@@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::_Application::PutWindowState(enum MapPoint::GeoWindowState)" (?PutWindowState@_Application@MapPoint@@QAEXW4GeoWindowState@2@@Z)
MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::_Application::PutVisible(short)" (?PutVisible@_Application@MapPoint@@QAEXF@Z)
Debug/MapPointApp.exe : fatal error LNK1120: 17 unresolved externals
Error executing link.exe.

MapPointApp.exe - 18 error(s), 0 warning(s)
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!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 09-12-2005
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
automation, c or c, mappoint, part


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Using Python to control MapPoint, Part 1 Eric Frost MP2K Magazine Articles 0 03-26-2006 11:29 PM
MapPoint Automation with C/C++ - Part 2 Eric Frost MP2K Magazine Articles 1 09-20-2005 11:00 AM
Automation -- Unable to kill mappoint.exe Anonymous MapPoint 2006/2009 Discussion 0 02-03-2004 11:12 PM
Error in VBA automation of MapPoint when PO BOX is found JPeters MapPoint 2006/2009 Discussion 2 01-09-2003 10:40 AM
I am using Mappoint with Visual C++ via automation.... Anonymous MapPoint 2006/2009 Discussion 2 07-08-2002 02:07 AM


All times are GMT -5. The time now is 06:37 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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