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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:34:14+00:00 2026-05-28T04:34:14+00:00

hoping to get some help here. I have locations on a database that I

  • 0

hoping to get some help here. I have locations on a database that I have successfully managed to put into an array that successfully plots the markers on the map. The only drawback is i want to customise the look of the market infowindow, so im using infobox.

But when I echo the variable from my array it echo’s the last result into each infobox and im completly stumped on this one.

Could someone please look at my code and see where iv gone wrong or point me in the right direction?

<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox.js"></script>
<script type="text/javascript" language="javascript">
// -- Location API -- //
infos = [];

function initialize() {
  var myOptions = {
    zoom: 3,
    center: new google.maps.LatLng(54.57206165565852, 12.48046875),
    mapTypeControl: false,
    mapTypeId: google.maps.MapTypeId.TERRAIN
  }
/* now inside your initialise function */
infowindow = new google.maps.InfoWindow({
content: "holding..."
});

  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  setMarkers(map, beaches);

}

/**
 * Data for the markers consisting of a name, a LatLng and a zIndex for
 * the order in which these markers should display on top of each
 * other.
 */
var beaches = [
[1, 'Peterhead', 57.487044, -1.800417, 1, 'Building 1', 'Glenbank'],
[2, 'Cowdenbeath', 56.09946, -3.35909, 1, 'Building 22', 'The Paragon Works Station'],
[3, 'Norfolk', 52.595971, 1.728609, 1, 'Building 3', '39 Southgates Road']
];

function setMarkers(map, locations) {
  // Add markers to the map

  // Marker sizes are expressed as a Size of X,Y
  // where the origin of the image (0,0) is located
  // in the top left of the image.

  // Origins, anchor positions and coordinates of the marker
  // increase in the X direction to the right and in
  // the Y direction down.
  var image = new google.maps.MarkerImage('http://stlab.co.uk/group/assets/img/icons/map-pin.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(15, 22),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(5, 22));

  for (var i = 0; i < locations.length; i++) {
    var beach = locations[i];
    var html = '<div class="phoney">'+beach[4]+'<br>'+beach[5]+'</div>'
    var myLatLng = new google.maps.LatLng(beach[2], beach[3]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image,
        content:html,
        title: beach[1],
        zIndex: beach[4]
    });


     var boxText = document.createElement("div");
       boxText.style.cssText = "border: 1px solid black; margin-top: 8px;               background: yellow; padding: 5px;";
       boxText.innerHTML = beach[0]+"<br>"+beach[6];

    var myOptions = {
         content: boxText,
             disableAutoPan: false,
             maxWidth: 0,
             pixelOffset: new google.maps.Size(-140, 0),
             zIndex: null,
             boxStyle: { 
              background: "url('tipbox.gif') no-repeat",
              opacity: 0.75,
              width: "280px"
             },
             closeBoxMargin: "10px 2px 2px 2px",
             closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
             infoBoxClearance: new google.maps.Size(1, 1),
             isHidden: false,
             pane: "floatPane",
             enableEventPropagation: false
        };

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

    var ib = new InfoBox(myOptions);
  }
}
</script>
  • 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-28T04:34:15+00:00Added an answer on May 28, 2026 at 4:34 am

    here is the working example.

    <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox.js"></script>
    <script type="text/javascript">
    // -- Location API -- //
    var infos = [];
    var ib = new InfoBox(); 
    function initialize() {
      var myOptions = {
        zoom: 3,
        center: new google.maps.LatLng(54.57206165565852, 12.48046875),
        mapTypeControl: false,
        mapTypeId: google.maps.MapTypeId.TERRAIN
      }
    /* now inside your initialise function */
    var infowindow = new google.maps.InfoWindow({
    content: "holding..."
    });
    
      var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      var beaches = [
    [1, 'Peterhead', 57.487044, -1.800417, 1, 'Building 1', 'Glenbank'],
    [2, 'Cowdenbeath', 56.09946, -3.35909, 1, 'Building 22', 'The Paragon Works Station'],
    [3, 'Norfolk', 52.595971, 1.728609, 1, 'Building 3', '39 Southgates Road']
    ];
      for (var i = 0; i < beaches.length; i++) {
        setMarkers(map, beaches[i]);
      }
    }
    
    /**
     * Data for the markers consisting of a name, a LatLng and a zIndex for
     * the order in which these markers should display on top of each
     * other.
     */
    
    function setMarkers(map, beach) {
      // Add markers to the map
      // Marker sizes are expressed as a Size of X,Y
      // where the origin of the image (0,0) is located
      // in the top left of the image.
    
      // Origins, anchor positions and coordinates of the marker
      // increase in the X direction to the right and in
      // the Y direction down.
      var image = new google.maps.MarkerImage('http://stlab.co.uk/group/assets/img/icons/map-pin.png',
          // This marker is 20 pixels wide by 32 pixels tall.
          new google.maps.Size(15, 22),
          // The origin for this image is 0,0.
          new google.maps.Point(0,0),
          // The anchor for this image is the base of the flagpole at 0,32.
          new google.maps.Point(5, 22));
    
        //var beach = locations[i];
        var html = '<div class="phoney">'+beach[4]+'<br>'+beach[5]+'</div>'
        var myLatLng = new google.maps.LatLng(beach[2], beach[3]);
        var marker = new google.maps.Marker({
            position: myLatLng,
            map: map,
            icon: image,
            content:html,
            title: beach[1],
            zIndex: beach[4]
        });
    
    
           var boxText = document.createElement("div");   
           boxText.style.cssText = "border: 1px solid black; margin-top: 8px;background: yellow; padding: 5px;";
           boxText.innerHTML = beach[0]+"<br>"+beach[6];
    var myOptions = {
                 content:boxText,
                 disableAutoPan: false,
                 maxWidth: 0,
                 pixelOffset: new google.maps.Size(-140, 0),
                 zIndex: null,
                 boxStyle: { 
                  background: "url('tipbox.gif') no-repeat",
                  opacity: 0.75,
                  width: "280px"
                 },
                 closeBoxMargin: "10px 2px 2px 2px",
                 closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
                 infoBoxClearance: new google.maps.Size(1, 1),
                 isHidden: false,
                 pane: "floatPane",
                 enableEventPropagation: false
            };
            google.maps.event.addListener(marker, "click", function (e) {
                       ib.setOptions(myOptions);
                       ib.open(map, marker);
            });
      }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem that I am hoping to get some help with.
I was hoping I might get some help here so that I might finally
I have a problem that I'm hoping to get some direction in solving -
Hi guys I was hoping from some help here, please. I have a INSERT
I have a UI problem with some CSS that I was hoping to get
I am hoping to get some help solving a problem that I'm sure many
I was hoping I could get some help optimizing the following data retrieval. Here
I was hoping to get some advice on what to do. I have a
I'm hoping to get some help with this weird problem. We're running the Jacorb
I'm really hoping someone can help me out here. I have a DataGrid in

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.