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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:00:15+00:00 2026-05-23T11:00:15+00:00

I have a simple Google map v3 code. It creates the map and adds

  • 0

I have a simple Google map v3 code. It creates the map and adds a marker to the markerCluster. It is all working fine, except for setting content to the infoWindow and opening it.
The function getSupplierDetails() simply returns a short string (i.e. “Red Supply”).

Here is the problem: If I hard code the text “Red Supply” to the setContent line like infoWindow.setContent("Red Supply"); then the infowindow open fine with the content.

But if I leave it as it is as in the code below the infowindow does not open at all, although the getSupplierDetails() function returns “Red Supply”.

getSupplierDetails() function returns this JSON string: {"popupContent": "Red Suppplier"} from Firebug.

Spent so long on it without any solution. Any help appreciated.

Thanks

var map;
var markerCluster;
var infoWindow;

$(document).ready(function() {

  if (mapElem != null) {
        var latlng = new google.maps.LatLng(54.664936, -2.706299);
        var myOptions = {
            zoom: 5,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
        };

        map = new google.maps.Map(mapElem, myOptions);
        markerCluster = new MarkerClusterer(map);
        infoWindow = new google.maps.InfoWindow();

    AddMarkers();
  }
});

function AddMarkers(){
    markerCluster.clearMarkers();
    var marker = new google.maps.marker({position:latLng, map:map, title:"title"});

    google.maps.event.addListener(marker, 'click', function() {
      var res = getSupplierDetails();
      infoWindow.setContent(res);
      infoWindow.open(map, this);
    });

    markers.push(marker);
    markerCluster.addMarkers(markers);
}


function getSupplierDetails() { //returns {"popupContent": "Red Suppplier"}
    $.ajax({
        type: 'POST',
        url: "sitedetail.aspx",
        dataType: 'json',
        timeout: 30000,
        success: function(data) {
            return data.popupContent;
        },
        error: function(xhr, textStatus, thrownError) {
            var resp = JSON.parse(xhr.responseText);
            alert(resp.message);

        }
    });
}
  • 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-23T11:00:15+00:00Added an answer on May 23, 2026 at 11:00 am
    function getSupplierDetails() { // returns "Red Suppplier" or ""
        var content = '';
        $.ajax({
            type: 'POST',
            url: "sitedetail.aspx",
            dataType: 'json',
            timeout: 30000,
            success: function(data) {
                content = data.popupContent;
            },
            error: function(xhr, textStatus, thrownError) {
                var resp = JSON.parse(xhr.responseText);
                alert(resp.message);
    
            }
        });
        return content;
    }
    
    • 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 (API 2) that used to work fine as a
I have a custom google map. It seems very simple. <!DOCTYPE html PUBLIC -//W3C//DTD
I have this simple hello world version of a google map api javascript v3
I have a Google Map with some simple buttons added to pan to different
I have a simple Google App Engine app, that I wrote using ordinary strings.
I have a simple object that get's geocoding data from the Google Maps API
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a problem with a Javascript request to the Google Map Api Web
I have a custom info window over a google map, sometimes these info windows

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.