如何将自定义图标分配给 Mappoint 中的图钉?
我正在编写一个使用 MS Mappoint OCX 的 MFC 应用程序。 我需要在地图上显示人和车辆的位置,最好的方法似乎是使用图钉对象。 我可以毫无问题地显示带有一些文本的库存图钉图标,但想将该图标更改为自定义设计的图标。 从有限数量的 Mappoint 编程信息来看,执行此操作的方法似乎是从符号对象创建符号对象,然后将其分配给像这样的图钉。
CSymbols symbols;
CSymbol symbol;
symbol=symbols.Add("c:/temp/myicon.ico");
pushpin.put_Symbol(symbol.get_ID());
但是程序因符号上未处理的异常而崩溃。操作说明。
谁能告诉我我在这里做错了什么? 或者我完全走错了路?
感谢您抽出时间
伊恩
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己找到了解决这个问题的方法。 以下代码有效。
其中map是Mappoint控件。
I found the solution to this one myself. The following code works ..
Where map is the Mappoint control.
所以看起来你的错误是符号集合尚未创建:所以是的,它当然会抛出异常。
正如您所发现的,可以使用 MapPoint.Map 对象上的 Symbols 属性来访问符号集合。
所有这些都在 MapPoint 参考中,但主要是参考形式,很少有教程。 网站,例如 http://www.mp2kmag.com 、 http://www.mapforums.com 和 http://www.mapping-tools.com/howto/ 是了解更多信息的良好起点。
(完全披露:最后一个网站是我的,信息位于“howto”路径中,而网站的其余部分本质上是商业性的)
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)