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

The Archive Base Latest Questions

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

I have my current google maps code working to the point where if I

  • 0

I have my current google maps code working to the point where if I click on the on the sidebar link, a marker event is fired then the infowindow is opened. What do I need to do to highlight the block on the sidebar when the marker is clicked??

function createMarkers(point, username, st) {
    var html = '<b>' + username + '</b> <br/> ' + st;

    var marker = new google.maps.Marker({
        position: point, 
        map: map, 
        //zIndex: Math.round(point.lat()*-100000)<<5,
        title: username
    });

    //Closes any open infowindow while clicking on another marker
    infowindow = new google.maps.InfoWindow();
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.close();
        infowindow.setContent(html);
        infowindow.open(map, marker);
    });

    markersArray.push(marker);

    return marker;
}

When the marker is being created, I also created the sidebar entries:

sidebar.innerHTML += '<span id="sidebarTxt">'
                                     +'<a href="javascript:sidebar_click(' + i + ')">' 
                                     + '<b>' + name + '</b> </a> <br/> ' 
                                     + 'St: ' + st + '<br />' 
                                     + 'St Preference: ' + location + '<br />' 
                                     + 'Distance from me: ' + Number(distance).toFixed(2) + 'miles <br />' 
                                     +' </span>';

What do I need to do to highlight the block on the sidebar when the marker is clicked??

  • 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-31T20:14:18+00:00Added an answer on May 31, 2026 at 8:14 pm

    Modify the click listener like this :

     google.maps.event.addListener(marker, 'click', function() {
        infowindow.close();
        infowindow.setContent(html);
        infowindow.open(map, marker);
        $("#sidebarTxt").toggleClass("new_style"); // this line adds the new_style to  sidebarTxt span
    });
    

    Where have some style

    .new_style {
        border: 1px solid red;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code for google maps. The purpose of this code is
In my project, i have imported some third party frameworks like google-maps. EveryThing work
This code have been working until I updated last night. The code works perfectly
In my google maps activity,the map is shown based on the current position.So i
1) I have a site, using jQuery and the gMap Google Maps plugin. This
I have been trying to compile the project from http://www.shabdar.org/google-maps-user-control-for-ASP-Net-part1.html but it is complaining
Hi I have created the core parts of a web app with Google Maps
I have written the following code to find the current location. It works well
I have a Map object created through the google maps api and I want
I am having some trouble with the Google Maps API . I have an

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.