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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:09:46+00:00 2026-05-23T21:09:46+00:00

I am pulling my latlng object from a database and when I loop through

  • 0

I am pulling my latlng object from a database and when I loop through the query in the javascript the markers all populate just fine, but when ever I click on one they all open the same infoWindow object on a different marker. I assume this is some sort of naming issue, but I am having trouble finding out why because it all looks right to me. the following code is in a cfoutput tag creating the loop.

var latlng_#get_latlng.recordcount# = new google.maps.LatLng(#get_latlng.mlat#,#get_latlng.mlong#); 
var marker_#get_latlng.recordcount# = new google.maps.Marker({
    position: latlng_#get_latlng.recordcount#,
    map: map,
    title: "test"
});

var contentString_#get_latlng.recordcount# = "test" + #get_latlng.recordcount#;

var infowindow_#get_latlng.recordcount# = new google.maps.InfoWindow({
    content: contentString_#get_latlng.recordcount#
});

google.maps.event.addListener(marker_#get_latlng.recordcount#, 'click', function() {
    infowindow_#get_latlng.recordcount#.open(map,marker_#get_latlng.recordcount#);
});
  • 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-23T21:09:47+00:00Added an answer on May 23, 2026 at 9:09 pm

    Rather than producing so much redundant JS, I’d create a function that adds the markers.

    function addMarker(lat, lng, title, content) {
        var latlng = new google.maps.LatLng(lat, lng);
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            title: title
        });
        var infowindow = new google.maps.InfoWindow({ content: content });
        google.maps.event.addListener(marker, "click", function() {
            infowindow.open(map, marker);
        });
    }
    

    Then in your loop:

    addMarker(#get_latlng.mlat#,#get_latlng.mlong#,"#get_latlng.title#","#get_latlng.content#");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im pulling information from a database and ive got the query working fine except
I am pulling a long timestamp from a database, but want to present it
I'm pulling back a Date and a Time from a database. They are stored
I'm pulling a row from a database and there is a date field (y-m-d).
Im pulling a date from a database which is formatted like dd-mm-YYYY. What I
I am pulling from a JSON feed and I just want to display a
I'm pulling a razor view's markup from the database, as detailed in this question:
I have cgi script pulling search terms from an HTML form through CGI::Ajax .
I am pulling a date value from my database: Dim qfresho = From p
I am pulling back some data from the twitter query API, and parsing it

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.