As we all know,ProgramIs not perfect. The following is the method of Google map class inheritance implementation. First, copy the class inheritance in Javascript design patterns:
Function extend (subclass, superclass) {function f () {} f. prototype = superclass. prototype; subclass. prototype = new F (); subclass. prototype. constructor = subclass; subclass. superclass = superclass. prototype; If (superclass. prototype. constructor = object. prototype. constructor) {superclass. prototype. constructor = superclass;} function submap (ELM, config) {console. log (submap. superclass. constructor); submap. superclass. constructor. call (this, elm, config);} extend (submap, Google. maps. map); var mapobj1 = new submap ($ ('# map_box') [0], {ZOOM: 13, center: new Google. maps. latlng (31.227, 121.519), maptypeid: Google. maps. maptypeid. roadmap });
The above Google map cannot be displayed on the page.CodeThere is a problem. The above implementation is rewritten as follows:
Function extend (subclass, superclass) {function f () {} f. prototype = superclass. prototype; subclass. prototype = new F (); subclass. prototype. constructor = subclass; subclass. superclass = superclass;} function submap (ELM, config) {submap. superclass. call (this, elm, config);} extend (submap, Google. maps. map); var mapobj1 = new submap ($ ('# map_box') [0], {ZOOM: 13, center: new Google. maps. latlng (31.227, 121.519), maptypeid: Google. maps. maptypeid. roadmap });
Well, Google Maps display well on the page.
(End)