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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:12:38+00:00 2026-05-23T14:12:38+00:00

I used to have something like this – var gicons = []; var baseIcon

  • 0

I used to have something like this –

var gicons = [];

var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.iconAnchor = new GPoint(9,34);
baseIcon.iconSize = new GSize(20,34);
baseIcon.infoWindowAnchor = new GPoint(9,2);

gicons["home"] = new GIcon(baseIcon,"yellow.png"); 
gicons["red"] = new GIcon(baseIcon,"red.png");
gicons["green"] = new GIcon(baseIcon,"green.png");
gicons["blue"] = new GIcon(baseIcon,"blue.png");`

It works fine.
Instead of that, I would like something like –

var tags = ["home", "red","green", "blue"];
var tags_colors = ["yellow.png", "red.png", "green.png", "blue.png"];

for(var i=0; i<tags.length; i++){

   if(tags[i]!=null){ 
      gicons[tags[i]] = new GIcon(baseIcon,tags_colors[i]); 
   }
}

::::::EDIT::::

` GDownloadUrl(“genxml.php”, function(doc) {
var xmlDoc = GXml.parse(doc);
var markers = xmlDoc.documentElement.getElementsByTagName(“marker”);

            for (var i = 0; i < markers.length; i++) {
              // obtain the attribues of each marker
                var lat = parseFloat(markers[i].getAttribute("lat"));
                var lng = parseFloat(markers[i].getAttribute("lng"));
                var point = new GLatLng(lat,lng);
                var address = markers[i].getAttribute("area");
                var name = markers[i].getAttribute("street");
                var html = "<b>"+name+"<\/b><p>"+address;
                var category = markers[i].getAttribute("tag");
                // create the marker
                var marker = createMarker(point,name,html,category);
                map.addOverlay(marker);
                tags[i] = markers[i].getAttribute('tag');

            }

            // hadnling the tags dynamically, to make it unique

           for (var i=0; i<tags.length-1 ; i++){
                var temp = tags[i];
                for(var j=i+1; j<tags.length; j++){
                     if(temp == tags[j]){
                        tags[j] = null; 
                     }
                }`

It is not working. No idea why. Can anyone help me please?

  • 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-23T14:12:38+00:00Added an answer on May 23, 2026 at 2:12 pm

    There is a typo:

    var tag_colors =.....
        tags_colors[i]
    

    However, i would prefer to use 1 object instead of 2 arrays:

    var gicons={};
    var tags = {'home'  :'yellow.png',
                'red'   :'red.png',
                'green' :'green.png',
                'blue'  :'blue.png'
               };
    
    for(var k in tags){
      gicons[k] = new GIcon(baseIcon,tags[k]); 
    }
    

    EDIT:

    See the callback-function for GDownloadUrl("genxml.xml")

    You create the marker there in line 224 of the linked document, inside the callback

    var marker = createMarker(point,name,html,category);
    

    But you create the GIcon later inside the callback-function(line 257)

    gicons[temp_tag] = new GIcon(baseIcon,tags_colors[i]);
    

    The result is: inside createMarker() the gicons-object is still empty, gicons[category] is unknown when supplied as argument to new GMarker()

    So the dynamic creation of the GIcons works fine(you can inspect it inside firebugs DOM-tab), but it comes to late.

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

Sidebar

Related Questions

In our code we used to have something like this: *(controller->bigstruct) = ( struct
I used to have something like this: We suggest you read our @Html.ActionLink(help page,
In the past I have used something like this to send form fields in
I used to have my permalinks to standard format, something like http://example.com/?page_id=2 . Now
This is the code i have. The NSDictionary did used to be something, but
I am converting my app to use NDB. I used to have something like
Sitation: overview: I have something like this: std::vector<SomeType> values; std::vector<int> indexes; struct Range{ int
So I keep having this small problem where I have something like func ::
let's say we have something like this public class Person { public string Name
I have often seen stylesheets written where you have something like this: #anyelement {

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.