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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:42:41+00:00 2026-06-14T00:42:41+00:00

I am trying to solve a conundrum using google maps and js. I never

  • 0

I am trying to solve a conundrum using google maps and js.
I never worked with google maps and my knowledge of JS is limited.

My MAIN question is: How do I Create multiple independent markers on google map, store them into some sort of data structure and then delete particular markers when I need it?

For example, each marker has it’s own id number, I get its lat and lon and them I use this function to add it to map:

function createMarkers(geocoder, map, name, latitude, longitude, ib, image) {                
//Setting the onclick marker function
var onMarkerClick = function() {
    var marker = this;
    var latLng = marker.getPosition();
    ib.setContent(name);
    ib.open(map, marker); 
};

google.maps.event.addListener(map, 'click', function() {
    ib.close();
});

//In array lat long is saved as an string, so need to convert it into int.
var lat = parseFloat(latitude);
var lng = parseFloat(longitude);

var marker = new google.maps.Marker({
    map: map,
    icon: image,
    position: new google.maps.LatLng(lat, lng),
    title: name
});

//Adding the marker.
google.maps.event.addListener(marker, 'click', onMarkerClick);
}
  • 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-14T00:42:42+00:00Added an answer on June 14, 2026 at 12:42 am

    According to Google Maps API V3, marker instance has the method setMap. it
    “Renders the marker on the specified map or panorama. If map is set to null, the marker will be removed.” extrated from Google Maps API V3 Documentation

    something like this

    marker.setMap(null);
    

    by other side, if you want to remove an specific marker, as well you said, u will have to hold marker instances in some data strucutre, in order to be able to get access to specific markers. As you have an id, considering that marker’s id is unique, you can use a hash. Something like that.

    // this variable must be global and accesible from your createMarkers method
    var all_markers = {};
    
    
    function createMarkers(geocoder, map, name, latitude, longitude, id, image) {   
    
    //........
    
    var marker = new google.maps.Marker({
        map: map,
        icon: image,
        position: new google.maps.LatLng(lat, lng),
        title: name
    });
    
    all_markers[id] = marker;
    
    //.....................
    
    }
    
    function removeMarker(id) {
      all_markers[id].setMap(null);
      delete all_markers[id];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve a tricky problem in Google Maps (api V3) Works nicely:
trying to solve a puzzle which i found here: http://zcasper.blogspot.com/2005/10/google-phone-interview.html the goal is to
Am trying to solve a labyrinth by DFS, using adj List to represent the
I am trying to solve the following problem with Puppet: I have multiple nodes.
Trying to solve a very simple problem using mvvm-light, but after days of sifting
I am trying to solve a specific problem using prologs constraint solvers, and I'm
I am currently trying to solve a problem, that I have using Hibernate 4
I'm trying to solve an equation. I'm using MASM32. I think that I'm using
I have been trying to solve some crackmes (from http://crackmes.de ) using WinDbg. Most
Im trying to solve Euler's Project 9 using PHP. Im pretty sure my logic

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.