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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:37:24+00:00 2026-06-18T05:37:24+00:00

I am working with google maps api(v3) and i have to add markers on

  • 0

I am working with google maps api(v3) and i have to add markers on a map.
Actually, I had no problem with displaying them or whatever but after a while the markers started not to be displayed or more precisly, they are displayed from time to time.

Here is some code so you can see what i’m doing and where the problem could come from:

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <link rel="stylesheet" href="style.css" type="text/css" media="screen" />

        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[KEY]&sensor=true"></script>
        <script type="text/javascript" src="google.js"></script>
        <script type="text/javascript" src="dataLoading.js"></script>
    </head>
    <body onload="initializeMaps();">
        <div id="map_canvas"></div>
        <script type="text/javascript">
            loadSpots();
        </script>
    </body>
</html>

And here is the javascript code:

var map;
var yMarker = 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png';
var gMarker = 'http://maps.google.com/mapfiles/ms/icons/green-dot.png';
var bMarker = 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png';
var pMarker = 'http://maps.google.com/mapfiles/ms/icons/pink-dot.png';

function initializeMaps()
{
    geocoder = new google.maps.Geocoder();
var mapOptions =
{
    center: new google.maps.LatLng(46.52863469527167, 2.4389648437),
    zoom: 6,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
    mapOptions);
}

function getLatlng(address, name, type)
{
geocoder.geocode({'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK)
    {
        var marker = new google.maps.Marker({
            title: name,
            map: map,
            animation: google.maps.Animation.DROP,
            position: results[0].geometry.location
        });
        marker.setIcon((type == 2 ? gMarker : (type == 3 ? bMarker : (type == 4 ? pMarker : yMarker))));
    }
});
}

function addMarker(address, name, type)
{
if (address != null && address != "")
    getLatlng(address, name, type);
}

EDIT1

LoadSpots() is a function that gets data from DB with an ajax request and then calls addMarker function

  • 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-18T05:37:25+00:00Added an answer on June 18, 2026 at 5:37 am

    Call loadSpots() at the end of initializeMaps(), otherwise it may happen that the map will be accessed before it’s initialized.

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

Sidebar

Related Questions

I'm working with Google Maps API v3 and I have an array of markers
I have a jqueryMobile app that uses google maps api and is working properly
I'm working on google maps API V3. I need to place markers dynamically on
I'm working on an advanced map application in Google Maps API V3. I'm using
From the google maps API documentation I have got this working: var flightPlanCoordinates =
I am working my way through the Google Maps API and have the following
I've been working with Google Maps API v3 and created a map which allows
This is my first time working with the Google Maps API. I have a
I'm working on an application that uses the Google Maps API. I have no
Hi I am working with google maps API I have this huge code, so

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.