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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:16:59+00:00 2026-05-31T21:16:59+00:00

I am generating a map from meta data from a series of posts in

  • 0

I am generating a map from meta data from a series of posts in WordPress. The map and points generate fine but when I click on the points the infowindow always generates in the same place and not on the point I click. Can someone please help with this, I had it working ok in v2 but I cant figure it out for 3.

The map is generated in the loop with this :

function initialize(){
    var myLatlng = new google.maps.LatLng(45, -123);
     var myOptions = {
            zoom: 3,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
    var map = new google.maps.Map(document.getElementById('travel_map'), myOptions);
    <?php if ( have_posts() ) :  while ( have_posts() ) : the_post();
        $my_post = get_post($post_id);
        $mapTitle  = $my_post->post_title;
        $lat = get_post_meta($post->ID, 'latitude', true); 
        $long = get_post_meta($post->ID, 'longitude', true);
        ?>

    var contentString = 'test';

    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });

     var marker = new google.maps.Marker({
        position: new google.maps.LatLng(<?php echo $lat . ", " . $long ?>),
        map: map
     });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    }); 

<?php endwhile;  ?>
<?php endif; ?>
}
  • 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-31T21:17:00+00:00Added an answer on May 31, 2026 at 9:17 pm

    http://you.arenot.me/2010/06/29/google-maps-api-v3-0-multiple-markers-multiple-infowindows/

    Here describes how to use multiple markers and multiple infowindows on your page.

    And here’s the implementation:

    <script type="text/javascript">
    
        var infowindow = null;
        var markers = [];
        function initialize(){
        var myLatlng = new google.maps.LatLng(45, -123);
         var myOptions = {
                zoom: 3,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
    
        var map = new google.maps.Map(document.getElementById('travel_map'), myOptions);
    
        infowindow = new google.maps.InfoWindow({
            content: "holding..."
        });
    
        <?php if ( have_posts() ) :  while ( have_posts() ) : the_post();
            $my_post = get_post($post_id);
            $mapTitle  = $my_post->post_title;
            $lat = get_post_meta($post->ID, 'latitude', true); 
            $long = get_post_meta($post->ID, 'longitude', true);
            ?>
    
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(<?php echo $lat . ", " . $long ?>),
            map: map,
            html: "<b><?php echo $mapTitle; ?></b><br><br><?php echo $my_post; ?>"
        });
    
        markers.push(marker);
    
        google.maps.event.addListener(marker, 'click', function () {
            infowindow.setContent(this.html);
            infowindow.open(map, this);
        });
    
    
    <?php endwhile;  ?>
    <?php endif; ?>
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Generating normal columnar data in excel file is quite easy but does any one
Im generating a file to present to the user for download, but the server
When generating models from postgresql with ColdFusion Illudium Code generator the boolean values get
I need to display multiple markers on a map, each with their own infowindow.
I'm actually trying to render an encoded polyline obtained from the Google Map Directions
I'm generating Google map by using the code below. What I am doing here
I'm using Google's GeoChart to display some activity data I've gathered from an outside
I'm very new to Scala, but from what I've read it seems the ideal
I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe
I'm working on a little project, the aim being to generate a report from

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.