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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:51:50+00:00 2026-06-12T10:51:50+00:00

This is probably a ridiculously simple question. I am trying to show a map,

  • 0

This is probably a ridiculously simple question.

I am trying to show a map, where marker infowindow will show the following content:

Name

Address

About (ie, description)

URL

Markers are queried from a mySQL database using PHP. The code is currently mapping all markers correctly, but only shows the “name” attribute in the infowindow. What is the missing code necessary to add the 3 other attributes? (Address, About, URL?) My guess is that there’s something at this point in the code that needs adjustment:

          google.maps.event.addListener(marker, 'click', (function(marker, i) {
                    return function() {
                        infowindow.setContent(markers[i].getAttribute("name"));
                        infowindow.open(map, marker);
                    }
                })(marker, i));   

If possible, please answer with the necessary script!

-Live link to database output: http://www.oaktonjapan.com/testmap/testcode3.php

**Note that the 1st (PAX Coworking) and last (Venture Generation) are populated with “address, about, and URL content.

-Live link to existing output: http://oaktonjapan.com/testmap/testmap5.html

*
*Click on the red sumo wrestler marker. This marker should show all 4 attributes if coded correctly…

Current Code:

 function load() {
  var cluster = [];
  var map = new google.maps.Map(document.getElementById("map"), {
    center: new google.maps.LatLng(35.681382,139.766084),
    zoom: 14,
    mapTypeId: 'roadmap'
  });
  var infowindow = new google.maps.InfoWindow();
    var min = .999999;
    var max = 1.000001;

  // Change this depending on the name of your PHP file
  downloadUrl("testcode3.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      var name = markers[i].getAttribute("name");
      var address = markers[i].getAttribute("address");
      var type = markers[i].getAttribute("type");
      var about = markers[i].getAttribute("about");
      var url = markers[i].getAttribute("url");
      var offsetLat = markers[i].getAttribute("lat") * (Math.random() * (max - min) + min);
      var offsetLng = markers[i].getAttribute("lng") * (Math.random() * (max - min) + min);
      var point = new google.maps.LatLng(offsetLat, offsetLng);
      var html = "<b>" + name + "</b> <br/>" + address;
      var icon = customIcons[type] || {};
      var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon.icon,
        content: html
      });
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
                    return function() {
                        infowindow.setContent(markers[i].getAttribute("name"));
                        infowindow.open(map, marker);
                    }
                })(marker, i));   
      cluster.push(marker);
    }
    var mc = new MarkerClusterer(map,cluster);
  });
}


function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}

function doNothing() {}

Thanks in advance for helping out!

  • 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-12T10:51:52+00:00Added an answer on June 12, 2026 at 10:51 am

    I would have thought you would be getting a variable not defined error on “html”.

    This is where you get the data out of the xml:

      var name = markers[i].getAttribute("name");
      var address = markers[i].getAttribute("address");
      var type = markers[i].getAttribute("type");
      var about = markers[i].getAttribute("about");
    

    This would combine it into the list you specified above:

      var html = name + "<br>" + address + "<br>"+ about + "<br>" + url;
    

    This would display it in the infowindow (don’t know why you have the “content: html” there, but at least now it won’t cause an error):

      var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon.icon,
        content: html
      });
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
                    return function() {
                        infowindow.setContent(html);
                        infowindow.open(map, marker);
                    }
                })(marker, i));  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

constant <- function(x){1} integrate(constant,lower=1,upper=10) this is probably more than ridiculously simple, but any reason
This is probably a ridiculously easy question, but I've been searching around for the
This one is stupid, and there's probably a ridiculously simple answer I'm just not
I have a really quick question which is probably ridiculously simple. I currently have
This probably is a dummy question but I cannot find a clear indication. I
I know this probably really simple but Im not sure what im doing wrong...
Im sorry for this probably dumm question, but I want to simply open modals
I am using this probably ugly javascript to show a text box (in a
This probably sounds like a silly question to seasoned Rails developer. Do I need
This probably sounds harder than it is. I'm actually trying to chain some animations

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.