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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:56:18+00:00 2026-05-27T13:56:18+00:00

This is inside the google initialize function and works fine. It’s the code below

  • 0

This is inside the google initialize function and works fine. It’s the code below which loops through the markers which is getting marker[i] is undefined

$.each(places, function(index, value) {
    x++;
    var pos = new google.maps.LatLng(value[1], value[2]);
    var icon = value[3];

    if(value[3] == 'HI') icon = "NF";
    if(value[3] == '') icon = "WH";

    marker[x] = new google.maps.Marker({     
        position: pos,
        map:map,
        title: value[0],
        shadow: shadow,
        icon: "../img/markers/" + icon + ".png"
    });

    marker[x].locType = icon;
});

Here’s the loop outside the initialize function – Getting marker[i] is undefined, doing an alert(marker) gives me [object Object],[object Object],[object Object],[object Object],[object Object] etc….

$(".team").click(function() {
    var type = $(this).attr("id");
    $.each(marker, function(i, val) {
        if(marker[i].locType == type) marker[i].setVisible(false);
    })
});
  • 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-27T13:56:19+00:00Added an answer on May 27, 2026 at 1:56 pm

    I think the problem is the

    x++;
    

    this probably indicates that your array start at index 1 instead of 0

    so you result probably is:

    [1] = Object
    [2] = Object
    etc.
    

    when running the $.each method it tries

    marker[0].locType
    

    Solution is to move the x++ to the end of the $.each(places, function(index, value) {

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

Sidebar

Related Questions

I have this code inside the success function of a jQuery ajax call success:
It seems that i cannot access $(this) inside jquery ajax success function. please see
if in a literal object i try to reference a function using this inside
I have this code inside a class that is used by an application and
So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value
I have created a function that loops through a set of returned JSON. I
I need some guidance on how to initialize this hash inside a singleton. So
How can I add support for plural forms in this Yii class: http://code.google.com/p/yii/source/browse/tags/1.1.8/framework/i18n/gettext/CGettextPoFile.php ?
I have this: <td onclick=window.location='http://www.google.com/';> </td> The problem is that I have this inside
I'm using this example script, provided by Google inside a rails app (so it's

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.