Mixing Google Maps custom overlays with Backbone Views

后端 未结 2 1874
你的背包
你的背包 2021-01-01 01:04

TL;DR

Is PinView.prototype = _.extend(PinView.prototype, google.maps.OverlayView.prototype) the \"proper\" way to have a Backbone View

2条回答
  •  醉话见心
    2021-01-01 01:08

    Nice idea! I'm usually a bit sceptical about weather or not you're 'correct' when things work so if you haven't run into a showstopper and the overlays shows up and does what the're supposed to do I'd say you are.

    One thing to check out closer, though:

    This isn't (and can't) be "real" multiple inheritance - that concept isn't really relevant in a prototype based language: one implementation of a method will inevitable "win" and overwrite the other implementation, at least when using _.extend()

    This means that if there are members or methods with the same names in Backbone.View and google.maps.OverlayView the one last in your _.extend() call will be the one that takes over. But when I inspect them using Chrome's Developer Tools I didn't see any obvious collision of this kind.

    So my recommendation: continue using this, just test a lot. I'd love to see an example of this technique some time.

提交回复
热议问题