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

  • Home
  • SEARCH
  • 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 6211641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:22:26+00:00 2026-05-24T06:22:26+00:00

I am needing to clear a DIV that is created from Google maps function.

  • 0

I am needing to clear a DIV that is created from Google maps function.
There are two HTML DIVs. The DIV I am having trouble with is MarkerCount

 <div id="sidebar"></div>
 <div id="MarkerCount"></div>

 function createMarkerCount(count) {
 var div = document.createElement('div');
 var html = "Results: " + count + " Facilities";
 div.innerHTML = html;
 div.style.marginBottom = '5px'; 
 return div;
 }

This is created when markers are returned to the Google Map. This is basically performing a count on the amount of records currently displayed on the map. This function works fine.

Here is my function to reset the map and clear the markers and another innerhtml DIV called sidebar:

function clearLocations() {
infoWindow.close();
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
markers.length = 0; 
sidebar.innerHTML = "";
 map.setCenter(new google.maps.LatLng(36.1611, -116.4775), 6);
}

This function works just fine. Now when I want to clear the MarkerCount,
I tried to add the following line to the function clearLocations()

MarkerCount.innerHTML = "";

However when the page first loads, and you perform a search, the clearLocations() function is called before the search is started, because there is not currently an innerhtml created for the CreateMarker function. this throws back an error which states that CreateMarker is NULL as there is nothing there.

So the skinny is, sidebar.innerhtml gets cleared just fine, but when I add the line of code to clear the CreateMarker.innerhtml DIV, I receive an error. Not sure why this might be happening….

EDIT — Function To Show How CountMarker Gets Count

var markercountEntry = createMarkerCount(markerNodes.length);
MarkerCount.appendChild(markercountEntry); 
  • 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-24T06:22:28+00:00Added an answer on May 24, 2026 at 6:22 am

    It sounds like you are having problems with setting an innerHTML on an element that is not defined yet, in your clearLocations() function. I suggest you just handle the case where CreateMarker or MarkerCount is not defined yet.

    Something like:

    function clearLocations() {
       if(CreateMarker && CreateMarker.innerHTML)
          CreateMarker.innerHTML = "";
       infoWindow.close();
       for (var i = 0; i < markers.length; i++) {
         markers[i].setMap(null);
       }
       markers.length = 0; 
       sidebar.innerHTML = "";
       map.setCenter(new google.maps.LatLng(36.1611, -116.4775), 6);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm needing to check the differences between two XMLs but not blindly, Given that
I'm needing to load an XML document into PHP that comes from an external
I'm needing to make this layout editor that uses a good bit of jQuery
Is there a way to pass an unlimited amount of arguments to a function,
I am needing to create a foreach statement that will run through and create
We're needing to store integer values of up to 2^38 . Are there any
I'm needing to delete a value in Isolated storage from javascript code. If this
I often find myself needing to write functions to load/save from/to ASCII (or similar)
Having a bit of a brain fart right now, but I'm needing help converting
In a desktop application needing some serious re-factoring, I have several chunks of code

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.