扩展 google.maps.Marker
我发现了这个关于在 v2 google 地图中扩展 GMarkers 的精彩教程:http://www .googlemapsbook.com/2007/01/22/extending-gmarker/
不幸的是,在 v3 中,标记的设置非常不同(例如,您必须传入地图,它将作为参数添加到其中) ,因此不能有一个独立的 google.maps.Marker 对象作为原型,或者至少在地图初始化之后)。
有谁知道如何扩展谷歌地图 v3 标记?
*编辑 - 事实证明我错误地将地图作为必需参数。我稍后会将我的 v3 扩展作为答案发布,并将其标记为社区问题
I found this great tutorial for extending GMarkers in v2 google maps: http://www.googlemapsbook.com/2007/01/22/extending-gmarker/
Unfortunately, in v3 the set-up of a marker is very different (eg you have to pass in the map it will be added to as a parameter, so can't have a standalone google.maps.Marker object to act as a prototype, or at least not until after your map has initialised).
Does anyone know how to extend a google maps v3 marker?
*edit - turns out I was wrong about the map being a required parameter. I'll post my v3 extension as an answer later and mark this as a community question
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是我最终使用的内容(我已经删除了用于自定义标记的大量代码,只留下了简单的框架,所以我可能在编辑中犯了错误)。 newObj() 是一个函数(基于 Douglas Crockford 的代码),用于从原型生成新对象,而不是使用构造函数。
Below is what I eventually used (I've stripped out a lot of code that I used for my custom marker to leave just the bare bones so I may have made a mistake in the editing). newObj() is a function (based on Douglas Crockford's code) for generating a new object from a prototype, rather than using a constructor function.