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 1001167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:37:36+00:00 2026-05-16T07:37:36+00:00

I am defining this class: function GMap(map, marker, geocoder) { this.map = map; this.marker

  • 0

I am defining this class:

function GMap(map, marker, geocoder) {
    this.map = map;
    this.marker = marker;
    this.geocoder = geocoder;

    this.setMarker = function(address) {
        this.geocoder.geocode({'address' : address}, function(results, status) {
            map.setCenter(results[0].geometry.location);
            marker.setPosition(results[0].geometry.location);
        });
    }
}

How can you access the map and marker properties of GMap from the callback function?

Thanks a lot.

  • 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-16T07:37:36+00:00Added an answer on May 16, 2026 at 7:37 am

    The Function object prototype has an “apply” method that you can use to set the context of “this” within a function. Check the API/code for whatever geocoder.code is, many libraries will handle this for you through an extra parameter, i.e.:

    this.someObj.someFn(params, callback, scope);
    

    Within someFn, it would use the callback similarly to this:

    callback.apply(scope || window, [callbackArg1, callbackArg2]);
    

    This would make the “this” context within “callback” whatever had been passed in as “scope”, or if nothing was passed in, “this” would be the global context of the window. Some javascript libraries also provide a way to create a callback function delegate that ensures the function is always called with the expected scope no matter where it ends up being called from. An example of this is ExtJS’s Function.createDelegate

    If the library you are using doesn’t provide this as built in functionality, then you can create a local var to reference within your callback closure, i.e.:

    this.setMarker = function(address) {
        var thisGMap = this;
        this.geocoder.geocode({'address' : address}, function(results, status) {
            thisGMap.map.setCenter(results[0].geometry.location);
            thisGMap.marker.setPosition(results[0].geometry.location);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That makes for a bug, which you should report to… May 16, 2026 at 1:56 pm
  • Editorial Team
    Editorial Team added an answer One of the best uses I've heard for Dynamic Data… May 16, 2026 at 1:56 pm
  • Editorial Team
    Editorial Team added an answer Try Open Game Art. Quoted: OpenGameArt.org is a community that… May 16, 2026 at 1:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Let's imagine something like this: class MyTable extends Doctrine_Table { public function construct() {
When defining a local inner class, is it safe to access local variables of
I'd like to override a class method without inheriting the base class because it'd
I have defined a class in C++ which holds an array of scalars of
I have a type class Atomic , which defines functions for converting certain types
I am playing around with Python, and I've created a class in a different
I've looked at this explanation on Wikipedia , specifically the C++ sample, and fail
I am coding a small Python module composed of two parts: some functions defining
How can I know which members module/package defines? By defining I mean: somemodule.py import
the following code compiles fine under gcc: class vec3 { private: float data[3]; public:

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.