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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:39:18+00:00 2026-06-16T19:39:18+00:00

I have a createMarker() function that is used to place multiple markers on the

  • 0

I have a createMarker() function that is used to place multiple markers on the google map. The following is the code:

     function createMarker(point,custid,streetadd,city,state,zip,address,phone,website,co) 
    {   
        var infowindowHover,infowindowClick;

        var marker = new google.maps.Marker({                
            position: point,                
            map: map,
            icon: image, 
        });

        var boxClickText = document.createElement("div");            
        boxClickText.className = "infoBackground";

        var markerMarkup = "<div id='infobox'><TABLE class='test'><TR><TD colspan='2'><B class='title'>";
            markerMarkup = markerMarkup + co + "</B></TD></TR><TR><TD colspan='2'>";
            markerMarkup = markerMarkup + streetadd + "</TD></TR><TR><TD colspan='2'>";
            markerMarkup = markerMarkup + city + "," + state + " " + zip + "</TD></TR><TR><TD colspan='2'>";
            markerMarkup = markerMarkup + phone + "</TD></TR><TR><TD colspan='2'>";
            if(website.indexOf("http://")>0) { markerMarkup = markerMarkup +"<a href="; }
            else{  markerMarkup = markerMarkup +"<a href=http://"; }
            markerMarkup = markerMarkup + website + " target=_blank>" + website + "</a></TD></TR><TR><TD class='availableStyle'>";                
            markerMarkup = markerMarkup +'<a href="javascript:;" onclick="setstyles('+ custid +',\'' + streetadd + '\'' + ',\'' + city + '\'' + ',\'' + state + '\'' + ',\'' + zip + '\'' + ',\'' + address + '\''+ ',\'' + phone + '\''+ ',\'' + website + '\''+ ',\'' + co + '\'' + ')";">see available styles</a>';

            //markerMarkup = markerMarkup + '<input type="button" value="see available styles" onclick="setstyles('+ custid +',\'' + streetadd + '\'' + ',\'' + city + '\'' + ',\'' + state + '\'' + ',\'' + zip + '\'' + ',\'' + address + '\''+ ',\'' + phone + '\''+ ',\'' + website + '\''+ ',\'' + co + '\'' + ')" />';
markerMarkup = markerMarkup + "</TD></TR></TABLE></div>";

        boxClickText.innerHTML = markerMarkup;


        var myOptions_click = {
            content: boxClickText
        //,disableAutoPan: true
        ,disableAutoPan: false
        ,maxWidth: 0
        ,pixelOffset: new google.maps.Size(-140, 0)
        ,zIndex: null
        ,boxStyle: {                 
            //opacity: 0.75
            //,width: "280px"
            margin:"-58px 0px 0px 148px"
            }
        ,closeBoxMargin: "10px 2px 2px 2px"
        ,closeBoxURL: "http://mansi:2525/pc-new/images/mapclosebutton.gif"
        ,infoBoxClearance: new google.maps.Size(1, 1)
        ,isHidden: false
        ,pane: "floatPane"
        ,id: "infoWindowClick"
        ,enableEventPropagation: false
        };

        var ib = new InfoBox();

        google.maps.event.addListener(marker, "click", function (e) {
            ib.close();
            ib.setOptions(myOptions_click);
            ib.open(map, this);
        });

        return marker;

    }  

I have referred similar question from Google Map V3 – Allow only one infobox to be displayed at a time and applied the code in the same way but I am not getting the desired result.

Google Map V3 – Allow only one infobox to be displayed at a time

  • 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-16T19:39:22+00:00Added an answer on June 16, 2026 at 7:39 pm

    You declare a new infobox every time you create a marker. So ‘ib’ refers to the infobox created for that marker and not the others.

    You need to set the infobox variable outside the createMarker function scope. Then inside your event listener, close the old infobox and then create a new one.

    var ib;
    
    function createMarker(<params>) {
         google.maps.event.addListener(marker, "click", function (e) {
            if (typeof ib === 'object') {
                ib.close();
            }
            ib = new Infobox();
            ib.setOptions(myOptions_click);
            ib.open(map, this);
        });
    }
    

    If you need a new infobox for each marker, then you could store an array of infoboxes.

    var ibs = [];
    
    var closeInfoBox = function() {
        for (var i in ibs) {
            ibs[i].close();
        }
    }
    
    function createMarker(<params>) {
        var ibIndex = ibs.push(new Infobox()) - 1,
            ib = ibs[ibIndex];
    
        google.maps.event.addListener(marker, "click", function (e) {
            closeInfoBox();
            ib.setOptions(myOptions_click);
            ib.open(map, this);
        });
    
    }
    
    • 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 on our site that has a list of markers
I have a Google map that is showing a number of markers. When the
I have the following function to display the infowindow with tabs on google map
I have a function that creates Google maps markers. I pass in data from
Currently I have JavaScript that displays markers on a Google map using the Google
I have the following code: function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(start,showError); } else{
Good morning. I have the next code which put some markers in a map
I am using a google map with markers and I have a search form
All, I have the following bit of code: function addPoints() { newpoints[0] = new
All, I have the following code to add a marker: function addPoints( points )

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.