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

  • Home
  • SEARCH
  • 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 8153275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:57:53+00:00 2026-06-06T15:57:53+00:00

I am using Google Maps API V2 (I know, but i am editing a

  • 0

I am using Google Maps API V2 (I know, but i am editing a current code so have to work with V2). All of my markers are pointing to the right place but there is only one problem that has brought me close to pulling my hair.

Problem is that only one all the markers are displaying correctly, but the info windows have only one content. i.e. Info windows are not being updated. They pop up right but they have same info in all of them.

I have seen this issue on some other forums and tried the solutions as well but to no avail.

Following is the code for fetching the json encoded PHP string from my php script and then looping it over for displaying the markers on the google map.

function showAddress(address) {

var response=$.ajax({
      type: "POST",
      url: "<?php echo WEBROOT; ?>/index/ajaxMaps",
      data: {address : escape(address)},
      cache: false,
      async:false,
      dataType: "json",
      success: function (html) {           

          for(i in html){

              if (geocoder) {
                  geocoder.getLatLng(
                    unescape(html[i].businessAddress),
                    function(point) {
                      if(!point) {

                        //alert(address + " not found");

                      } else {

                        map.setCenter(point, 11);

                          string='<div style="height:100px; background:green; color:white; padding:5px; border-radius:0.5em; width:auto"><strong>Company name : </strong>'+ html[i].businessName;
                          string+='<br/><strong>Adress : </strong>'+ html[i].businessAddress;
                          string+='<br/><strong>Website : </strong>'+'<a style="color:white !important" href="'+html[i].businessWebsite+'" >'+'Visit our website'+'</a></div>';

                        var marker = createMarker(point, string);

                        map.addOverlay(marker);

                        //map.addMapType(G_PHYSICAL_MAP);

                        map.addControl(new GLargeMapControl());

                        // As this is user-generated content, we display it as
                        // text rather than HTML to reduce XSS vulnerabilities.

                        marker.openInfoWindowHtml(string);

                        //$('.map_enlarged').trigger('click');
                      }
                    }
                  );
                }

            }           

      }

    });


 $('.map_enlarged').trigger('click');

}

Now the function for adding marker:

function createMarker(point,html) {

    // Create our "tiny" marker icon
   var blueIcon = new GIcon(G_DEFAULT_ICON);
   blueIcon.image = "<?php echo WEBROOT; ?>images/marker.png";

    // Set up our GMarkerOptions object
    markerOptions = { icon:blueIcon };

    var marker = new GMarker(point,markerOptions);

    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);

  });

  return marker;
}

I know that the variable names ‘string‘ is not being updated. But i don’t see the reason why. I have traced it back to the loop but see no reason why it should not update.

Please remember i have digged enough for most of the above code to be alright and point out the mistake in my code if you can. Providing other links might not be any use because i might have seen them already.

I will be grateful for the solution.

  • 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-06-06T15:57:55+00:00Added an answer on June 6, 2026 at 3:57 pm

    You need another function closure on “i” (that closes on the input parameters to the geocoder).

    This example solves that problem, but not the query limit problem (you really shouldn’t geocode large numbers of addresses on the fly, geocode them offline and store the resulting coordinates).

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

Sidebar

Related Questions

All the examples I've come across using Google Maps API seem to show a
I have created an infobox using google maps api v3 and infoBox from the
I'm using the Google Maps Javascript API so that I can have someone put
I have a page in my project that's using the google maps api along
Today is my first day using the Google Maps API. Now I have a
im using google maps api and im having this problem with showing the info
I've recently started using Google Maps API v3. I need to plot some locations
I'm using Google Maps API on my ASP.NET Web Application. Currently the center position
I just started working using Google Maps API yesterday, and trying to set up
I am using Google Maps API V3 to create a marker and the Infobox

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.