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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:48:57+00:00 2026-05-26T21:48:57+00:00

I’m working on a location map which uses the Google Maps API. The desired

  • 0

I’m working on a location map which uses the Google Maps API. The desired result is:

  1. A map with multiple locations (completed, tested, working as desired).
  2. Custom pins (completed, tested, working as desired).

— Things I can’t figure out —

  1. Custom content within the info window (click pin, info window opens with name, address, that sort of thing.)
  2. A link within a the list of locations which positions the map and opens the info window.

JavaScript so far:

function initialize() {
  var myOptions = {
  zoom: 11,
  center: new google.maps.LatLng(-33.802544,151.20203),
  mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
  setMarkers(map, lianaraine);
}

var lianaLocations = [
  ['1', -33.750829,151.24086, 1],
  ['2', -33.846405,151.211677, 2],
  ['3', -33.876321,151.241171, 3],
  ['4', -33.871511,151.159599, 4],
  ['5', -33.901535,151.161743, 5],
  ['5', -33.676461,151.304244, 6]
];

function setMarkers(map, locations) {
  var image = new google.maps.MarkerImage('images/icon_mapPin.png',
    new google.maps.Size(30, 40),
    new google.maps.Point(0,0),
    new google.maps.Point(0, 40));
  var shadow = new google.maps.MarkerImage('images/icon_mapPin_shadow.png',
    new google.maps.Size(26, 20),
    new google.maps.Point(0,0),
    new google.maps.Point(-13,21));
  var shape = {
    coord: [1, 1, 1, 40, 30, 40, 30 , 1],
    type: 'poly'
  };
  for (var i = 0; i < locations.length; i++) {
  var liana = locations[i];
  var myLatLng = new google.maps.LatLng(liana[1], liana[2]);
  var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      shadow: shadow,
      icon: image,
      shape: shape,
      title: liana[0],
      zIndex: liana[3]
  });
  }
}

I’m using V3… If that matters?

I know I’m a fair way off. Any assistance or direction would be appreciated.

Thanks in advance.

@rrfive

  • 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-26T21:48:58+00:00Added an answer on May 26, 2026 at 9:48 pm

    So what you want to do is have one infowindow, but it gets different content for each marker. i.e. the content and its position changes in response to user clicks. So in the loop where you create your markers, you also want to create your infowindow. However you will need to separate this out to another function, otherwise you end up with the situation where every infowindow just contains the content of the last marker.

    function setMarkers(map, locations) {
      ...
      var infowindow =  new google.maps.InfoWindow({
        content: ''
      });
    
      for (var i = 0; i < locations.length; i++) {
        var liana = locations[i];
        var myLatLng = new google.maps.LatLng(liana[1], liana[2]);
        var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          shadow: shadow,
          icon: image,
          shape: shape,
          title: liana[0],
          zIndex: liana[3]
        });
    
        // add an event listener for this marker
        bindInfoWindow(marker, map, infowindow, "<p>" + liana[0] + "</p>");
      }
    }
    
    function bindInfoWindow(marker, map, infowindow, html) {
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.setContent(html);
            infowindow.open(map, marker);
        });
    } 
    

    I’m not sure where you’re getting the address details from – in my example I’m just using the same part of your array you’re passing to the ‘title’ attribute, which I then display in the infowindow. Probably you’ll have to use the Geocoder service to look up the addresses of each latLng, which could then be an additional column in the array.

    Update: If you then need to have a normal link trigger as if you’d clicked on the marker, what you need to do is have your markers in an array (make that a global variable, push markers into the array after creating them). Clicking a link calls a javascript function, passing in a number to identify which element in the array to use. Then you ‘trigger’ a click on that marker, e.g.

    <a href="#" onclick="showWindow(0); return false">One</a>
    <a href="#" onclick="showWindow(1); return false">Two</a>
    
    function showWindow(id) {
        google.maps.event.trigger(markersArray[id], 'click');
    }
    
    • 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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
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 have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.