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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:08:12+00:00 2026-06-11T11:08:12+00:00

I am using google maps api to display some points on a map. I

  • 0

I am using google maps api to display some points on a map. I need each marker to appear on the map with different icon depending on its type. For example houses a red dot and stores a blue dot. The type is pointed out by a variable “exacttype” .
Right now there is a variable var icon that includes the path like this icon.image='....apath/iconred.png';
How can i include this variable in the icons path so i wont need to create a different icon variable? something like this : icon.image='...apth/icon"exacttype".png;
The reason i am doing this is i already have 2 types of icons A and B but lets say icons A do need to differentiate from eachother according to their details.

  • 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-11T11:08:13+00:00Added an answer on June 11, 2026 at 11:08 am

    How about this:

    icon.image = '....apath/iconred.png'
    icon.image = icon.image.replace(/icon[^.]+(?=[.]png)/, 'icon' + exacttype);
    

    In other word, you replace ‘icon’ and all non-dot symbols that follow it with concatenation of ‘icon’ and that string stored in exacttype variable. It could be made even more concise with help of look-behind expression /(?<=icon)[^.]+(?=[.]png)/, but JS does not support it.

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

Sidebar

Related Questions

I'm using Google Maps API to display a map and some markers on it.
I am using Google Maps V3 API to display my map. Problem: How can
I'm using Google Maps' API and added a few markers in a map. Each
I am using Google Maps API to display a map on a certain page.
I am using Google Maps Api v3 to display a map. This is the
I'm using the google maps javascript API v3 to display a map in a
Hi I've been using Google Maps API v3 and geocoder to display a map
I'm using the Google Maps API to plot several points on a map. However,
I'm using the GWT google maps V3 API and I need to display custom
I am using Google Maps API V3 to create a marker and the Infobox

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.