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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:10:35+00:00 2026-06-03T02:10:35+00:00

I need to automatically change Google Maps marker icons based on the inner content

  • 0

I need to automatically change Google Maps marker icons based on the inner content of an automatically updating DOM element.

I’ve looked at the documentation for addListener and addDomListener, but it’s all mouseovers and clicks and stuff. I need it to detect a change in the pure HTML content of the element in question, and if that value meets certain conditions, change the marker’s icon based on it.

Here is the code I am using:

infowindow=new google.maps.InfoWindow();
for (i=0;i<buildings.length;i++){
    marker=new google.maps.Marker({
        position:new google.maps.LatLng(buildings[i][4],buildings[i][5]),
        map:map,
        shadow:shadow,
        icon:greenIcon,
        title:buildings[i][0]+" \n"+buildings[i][1],
        zIndex:buildings[i][6]
    });
}

I am thinking about adding a setInterval in conjunction with jQuery to force the buildings[i][7] array value (not included above) to equal the content of the div in question, and then running a few conditional statements to determine if it meets the right criteria for changing the icon of the marker.

But after that, I’m lost about how to get the marker to actually change based on the dynamically updating value.

  • 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-03T02:10:36+00:00Added an answer on June 3, 2026 at 2:10 am

    To set the icon associated with the Marker, try out the Marker.setIcon function. It accepts one parameter, which may be either:

    1. A string that contains the relative location of the icon image file (as in your code), OR –
    2. A MarkerImage, which gives you more control (anchor, origin, size, etc.) over how the icon image is displayed
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to change the automatically generated index.html flex output to admin.anotherExtension. I understand
I need to create a view that will automatically change from month to month
I need the keyboard change automatically from normal to numeric keyboard only for particular
I need to reset a MySQL Field value automatically at midnight. It is a
I need to create a page that will automatically create a thumbnail from all
I need to create a landing page that will automatically redirect a visitor to
I need to be able to write a script to automatically connect mysql in
I need to restore a backup from a production database and then automatically reapply
I need to automate a process whereby attachments are automatically downloaded from messages in
I need to find an easy way to know if the local machine's 'automatically

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.