Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6148855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:21:06+00:00 2026-05-23T19:21:06+00:00

Basically, I wanted to add a few custom methods to google.maps.Map and Rectangle classes.

  • 0

Basically, I wanted to add a few custom methods to google.maps.Map and Rectangle classes.
I could not do it, so I decided to make wrapper classes, but I ran into one problem

function MyClass() {

  this.redraw_map = function() {draw something};
  this.current_map = new google.maps.Map();  

  google.maps.event.addListener(this.current_map, 'bounds_changed', function() {
    redraw_map();
  });
}

My redraw_map() method is not seen in the event handling function, unless I put the redraw method outside MyClass.
I have in plans to switch to more advanced way writing JS apps like Backbone, but first I need to understand how to overcome such problems.

Thanks for reading.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:21:07+00:00Added an answer on May 23, 2026 at 7:21 pm

    This happens because the callback function that you’re passing to addListener does not have a function defined redraw_map() in its current scope. A workaround is to keep a reference to your MyClass scope outside of your callback, allowing you to call it from inside the callback.

    This will fix your problem:

    function MyClass() {
    
        this.redraw_map = function() {draw something};
        this.current_map = new google.maps.Map();  
    
        // Reference to current scope
        var self = this;
    
        google.maps.event.addListener(this.current_map, 'bounds_changed', function() {
            // This will call the function that you defined in your scope above
            self.redraw_map();
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to add a new property to one of my model (table). Basically
I am new to jqwicket. Basically I wanted to know how to add animation
I wanted to add a new table in my database, and not change the
Basically I wanted to do something like git push mybranch to repo1, repo2, repo3
I wanted to create a new property on a table in my model.. Basically
I have created a 3D structure(basically an image) dynamically using kit3D.However,I wanted to zoom
Basically I'm going to go a bit broad here and ask a few questions
I created a function in my controller called addToPlaylist($songName). I wanted to add these
So basically I just wanted to create an enemy class with pygames.sprite.Sprite as the
I've got a few tables that all have the same column domainID which basically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.