1

I'm writing a MFC app that uses the MS Mappoint OCX. I need to display the locations of people and vehicles on the map and the best of doing this appears to be with Pushpin objects. I have no problem displaying a stock pushpin icon with some text but want to change the icon to a custom designed one. From the limited amount of Mappoint programming info out there it appears the way to do this is to create a symbol object from a symbols object then assign this to a pushpin like this ..

CSymbols symbols;
CSymbol symbol;

symbol=symbols.Add("c:/temp/myicon.ico");
pushpin.put_Symbol(symbol.get_ID());

But the program crashes with a unhandled exception on the symbols.add instruction.

Can anyone tell me what I am doing wrong here ? or am I on totally the wrong track ?

Thanks for your time

Ian

Aardvark
  • 8,474
  • 7
  • 46
  • 64
IanW
  • 1,304
  • 2
  • 17
  • 26

2 Answers2

2

I found the solution to this one myself. The following code works ..

CSymbols symbols;
CSymbol symbol;

symbols=map.get_Symbols();
symbol=symbols.Add("c:/temp/myicon.ico");
pushpin.put_Symbol(symbol.get_ID());

Where map is the Mappoint control.

IanW
  • 1,304
  • 2
  • 17
  • 26
0

So it looks like your error was that the symbols collection had not been created: so yes of course it will throw an exception.

As you have found, the symbols collection can be accessed using the Symbols property on your MapPoint.Map object.

All this is in the MapPoint reference, but it is primarily in the reference form with few tutorials. Websites such as http://www.mp2kmag.com , http://www.mapforums.com , and http://www.mapping-tools.com/howto/ are a good start to find out more.

(Full Disclosure: the last site is mine, information is in the "howto" path, whilst the rest of the site is commercial in nature)

winwaed
  • 7,645
  • 6
  • 36
  • 81