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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:10:00+00:00 2026-06-08T22:10:00+00:00

I’m quite new to Google Maps API 3 and can’t figure out the following

  • 0

I’m quite new to Google Maps API 3 and can’t figure out the following error: All clicks on my markers open the infowindow on the same marker (bad), but with different text (good).
I’m pulling the data out of wordpress custom meta data into an xml, which i then parse; What makes me wondering is the fact that generating the markers works this way, but adding the listener for the infowindow obviously fails.

Any ideas what’s happening here?

Live demo at:
http://goo.gl/9seK9

Code

$(document).ready(function(){

    var infowindow;
    var latlng = new google.maps.LatLng(47.580231,13.771362);
    var settings = {
        zoom: 8,
        center: latlng,
        panControl: true,
        zoomControl: true,
        mapTypeControl: true,
        disableDefaultUI:true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), settings);


    jQuery.get("http://rundumadum.eu/de/wp-content/themes/rud/rundumadumMap.xml", {}, function(data) {
        var xmllength = $(data).find("mymarkers").children().size();
        var supermarkers = [];

        jQuery(data).find("mymarker").each(function() {
                var myid = $(this).find("id").text();
                var mytitle = $(this).find("title").text();
                var mylink = $(this).find("link").text();
                var mylocation = $(this).find("location").text();

                var mysplits = mylocation.split(",");
                var mylat = mysplits[0];
                var mylng = mysplits[1];
                var mylatlng = new google.maps.LatLng(parseFloat(mylat), parseFloat(mylng));  
                var myinfo = "<a href="+mylink+">"+mytitle+"</a>";
                var marker = createMyMarker(mytitle, myinfo, mylink, mylatlng);
        });
    });


    function createMyMarker(mytitle, myinfo, mylink, mylatlng) {
        marker = new google.maps.Marker({
            position: mylatlng, 
            map: map,
            clickable:true,
            icon:'http://rundumadum.eu/de/wp-content/themes/rud/static/img/markerTest.png',
            html: '<a href="'+mylink+'">'+mytitle+'</a>'
        });

        google.maps.event.addListener(marker, "click", function() {
            if (infowindow) infowindow.close();
            infowindow = new google.maps.InfoWindow({content: myinfo});
            infowindow.open(map, marker);
        });
    }
    return marker;

});

Would be grateful for any ideas …

  • 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-08T22:10:02+00:00Added an answer on June 8, 2026 at 10:10 pm

    One thing I notice is that the marker you are creating in createMyMarker is not declared using var marker, so it looks like you are inadvertently creating a global marker reference. Also, it appears that the statement: return marker is actually after the end of your createMyMarker function, although that may just be a typo that was introduced when you set up your code sample in your question.

    At any rate, I believe if you change the code in createMyMarker to declare the marker using var marker within that function, it will give you better results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this

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.