Implementation of Google map class instances in class inheritance

Source: Internet
Author: User
Tags map class

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.