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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:58:37+00:00 2026-05-17T22:58:37+00:00

I have a v3 Google map being loaded exactly as I expect and the

  • 0

I have a v3 Google map being loaded exactly as I expect and the marker does what I intend. However when I change the zoom, the zoom_changed event that I have added does not appear to fire. Would anyone be able to shed any light on why? My code is below.

function map_initialise() {
    var mapCentre = new google.maps.LatLng(53.75, -1.50);
    var mapOptions = {
        zoom: 6,
        center: mapCentre,
        mapTypeId: google.maps.MapTypeId.HYBRID
    }

    var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

    var latlong1 = new google.maps.LatLng(52.456550,1.680182);
    var windowtext1 = 'Some text';
    var popup1 = new google.maps.InfoWindow({
        content: windowtext1
    });
    var marker1 = new google.maps.Marker({
        position: latlong1,
        title: "Some text"
    });
    google.maps.event.addListener(marker1, 'click', function() { 
        popup1.open(map,marker1);
    });
    marker1.setMap(map);
}

google.maps.event.addDomListener(window, 'load', map_initialise);

google.maps.event.addListener(map, 'zoom_changed', function() {
    setTimeout(reCentre, 3000);
});

function reCentre() {
    var newcentre = new google.maps.LatLng(53.000,0.000);
    map.panTo(newcentre);
}
  • 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-17T22:58:38+00:00Added an answer on May 17, 2026 at 10:58 pm

    2 things…

    1. Right now your zoom_changed listener isn’t being added becuase it’s called before the map is initialized. Javascript executes the map_initialise() function then immediately tries and add the listener before the map is finished loading. So put the addListener into the initialize function at the end.

    2. Your map variable is private to the map_initialise() function so when reCentre() is called it can’t see your map object. If you remove var from in front of map it will become global and reCentre() will be able to see it. I recommend adding var map; above the map_initialise() function so readers of the code will see map is global.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Google Map, and I am adding event listeners to different things.
I have a Google Map on one web page where I want to disable
I'm coding a map app for iPhone , like Google Maps but with my
I really hope someone can advise on displaying a google map from a hidden
I have a Django application being served of (say) example.com . It contains a
In our ASP.NET MVC project, we have an HtmlHelper extension method to generate a
I am trying to get the locations of devices per project. I have a
I seem to have something odd with either my Mac 10.6 terminal or my
I've have started my foray into C#.NET and NHibernate and I'm finally stuck on
I have a CSV file consists of thousand of data (columns are address1 address2

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.