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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:35:06+00:00 2026-06-14T06:35:06+00:00

I want to display a map and then 3 text links in a sidebar

  • 0

I want to display a map and then 3 text links in a sidebar that onclick will change the location on the map.

The map won’t display as a result of trying to port over code from V2 to V3.

I’m sure just a small error.. my code is as follows:

<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script> 
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
</head>
<body>
    <div id="map" style="width: 459px; height: 200px"></div>
    <div id="side_bar"></div>

    <script type="text/javascript">
    //<![CDATA[

    if (GBrowserIsCompatible()) {

      // this variable will collect the html which will eventually be placed in the side_bar
      var side_bar_html = "";

      // arrays to hold copies of the markers and html used by the side_bar
      // because the function closure trick doesnt work there
      var gmarkers = [];


      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers.push(marker);
        // add a line to the side_bar html
        side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + name + '<\/a><br>';
         return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        GEvent.trigger(gmarkers[i], "click");
      }


      // create the map
      var map;
      function initialize() {
        var mapOptions = {
          zoom: 8,
          center: new google.maps.LatLng(-34.397, 150.644),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('map'),
            mapOptions);
      }
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng( 43.907787,-79.359741), 8);

      // add the points    
      var point = new GLatLng(43.65654,-79.90138);
      var marker = createMarker(point,"This place","Some stuff to display in the<br>First Info Window")
      map.addOverlay(marker);

      var point = new GLatLng(43.91892,-78.89231);
      var marker = createMarker(point,"That place","Some stuff to display in the<br>Second Info Window")
      map.addOverlay(marker);

      var point = new GLatLng(43.82589,-78.89231);
      var marker = createMarker(point,"The other place","Some stuff to display in the<br>Third Info Window")
      map.addOverlay(marker);


      // put the assembled side_bar_html contents into the side_bar div
      document.getElementById("side_bar").innerHTML = side_bar_html;

    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </body>
  • 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-14T06:35:08+00:00Added an answer on June 14, 2026 at 6:35 am

    Ok, try this code:

    <!DOCTYPE html>
    <html>
      <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
      </head>
      <body>
        <div style="position:relative;width:600px;height:400px">
          <div id="map" style="position:absolute;left:0;top:0;width:75%; height:100%"></div>
          <div id="side_bar" style="position:absolute;right:0;top:0;width:25%; height:100%"></div>
        </div>
    
        <script type="text/javascript">
          //<![CDATA[
    
          // this variable will collect the html which will eventually be placed in the side_bar
          var side_bar_html = "";
    
          // arrays to hold copies of the markers and html used by the side_bar
          // because the function closure trick doesnt work there
          var gmarkers = [];
    
          var infoWnd = new google.maps.InfoWindow();
    
          // A function to create the marker and set up the event window
          function createMarker(point, name, html) {
            var marker = new google.maps.Marker({
              position : point
            });
            google.maps.event.addListener(marker, "click", function() {
              infoWnd.setContent(html);
              infoWnd.open(marker.getMap(), marker);
            });
            // save the info we need to use later for the side_bar
            gmarkers.push(marker);
            // add a line to the side_bar html
            side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length - 1) + ')">' + name + '<\/a><br>';
            return marker;
          }
    
          // This function picks up the click and opens the corresponding info window
          function myclick(i) {
            google.maps.event.trigger(gmarkers[i], "click");
          }
    
          // create the map
          var map;
          function initialize() {
            var mapOptions = {
              zoom : 8,
              center : new google.maps.LatLng(43.91892, -78.89231),
              mapTypeId : google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById('map'), mapOptions);
    
            // add the points
            var point = new google.maps.LatLng(43.65654, -79.90138);
            var marker = createMarker(point, "This place", "Some stuff to display in the<br>First Info Window");
            marker.setMap(map);
    
            var point = new google.maps.LatLng(43.91892, -78.89231);
            var marker = createMarker(point, "That place", "Some stuff to display in the<br>Second Info Window");
            marker.setMap(map);
    
            var point = new google.maps.LatLng(43.82589, -78.89231);
            var marker = createMarker(point, "The other place", "Some stuff to display in the<br>Third Info Window");
            marker.setMap(map);
    
            // put the assembled side_bar_html contents into the side_bar div
            document.getElementById("side_bar").innerHTML = side_bar_html;
          }
    
          google.maps.event.addDomListener(window, 'load', initialize);
        </script>
      </body>
    </html>
    

    enter image description here

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

Sidebar

Related Questions

I'm trying to develop my own map service then display my generated images into
I want to display Satellite Map view in Android without Road/city/country label overlapped on
I want to display google map in Android ,i have map API even map
I want to Display Google Map into my wordpress site. I have used below
I have a map ` { key1=[button1,button2,button3,button4],key2=[button1],key3=[button1,button2],key4=[button1,button2,button3]} ` i want to display this map
I want to display the keyset of a map in a drop down list
I want to create application which would display spatial data on Map. I'm thinking
I have a database of map points, and I want to limit the display
I have got two images one that i want to display on the top
I have a page where I want to display some points on map. I

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.